@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't require a device be registered in Almanac to do cluster init/resync steps

Summary:
Fixes T12893. See also PHI15. This is complicated but:

- In the documentation, we say "register your web devices with Almanac". We do this ourselves on `secure` and in the production Phacility cluster.
- We don't actually require you to do this, don't detect that you didn't, and there's no actual reason you need to.
- If you don't register your "web" devices, the only bad thing that really happens is that creating repositories skips version initialization, creating the bug in T12893. This process does not actually require the devices be registered, but the code currently just kind of fails silently if they aren't.

Instead, just move forward on these init/resync phases even if the device isn't registered. These steps are safe to run from unregistered hosts since they just wipe the whole table and don't affect specific devices.

If this sticks, I'll probably update the docs to not tell you to register `web` devices, or at least add "Optionally, ...". I don't think there's any future reason we'd need them to be registered.

Test Plan:
This is a bit tough to test without multiple hosts, but I added this piece of code to `AlmanacKeys` so we'd pretend to be a nameless "web" device when creating a repository:

```
if ($_REQUEST['__path__'] == '/diffusion/edit/form/default/') {
return null;
}
```

Then I created some Git repositories. Before the patch, they came up with `-` versions (no version information). After the patch, they came up with `0` versions (correctly initialized).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12893

Differential Revision: https://secure.phabricator.com/D18273

+12 -10
+12 -10
src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
··· 58 58 * @task sync 59 59 */ 60 60 public function synchronizeWorkingCopyAfterCreation() { 61 - if (!$this->shouldEnableSynchronization()) { 61 + if (!$this->shouldEnableSynchronization(false)) { 62 62 return; 63 63 } 64 64 ··· 86 86 * @task sync 87 87 */ 88 88 public function synchronizeWorkingCopyAfterHostingChange() { 89 - if (!$this->shouldEnableSynchronization()) { 89 + if (!$this->shouldEnableSynchronization(false)) { 90 90 return; 91 91 } 92 92 ··· 133 133 * @task sync 134 134 */ 135 135 public function synchronizeWorkingCopyBeforeRead() { 136 - if (!$this->shouldEnableSynchronization()) { 136 + if (!$this->shouldEnableSynchronization(true)) { 137 137 return; 138 138 } 139 139 ··· 288 288 * @task sync 289 289 */ 290 290 public function synchronizeWorkingCopyBeforeWrite() { 291 - if (!$this->shouldEnableSynchronization()) { 291 + if (!$this->shouldEnableSynchronization(true)) { 292 292 return; 293 293 } 294 294 ··· 382 382 383 383 384 384 public function synchronizeWorkingCopyAfterDiscovery($new_version) { 385 - if (!$this->shouldEnableSynchronization()) { 385 + if (!$this->shouldEnableSynchronization(true)) { 386 386 return; 387 387 } 388 388 ··· 426 426 * @task sync 427 427 */ 428 428 public function synchronizeWorkingCopyAfterWrite() { 429 - if (!$this->shouldEnableSynchronization()) { 429 + if (!$this->shouldEnableSynchronization(true)) { 430 430 return; 431 431 } 432 432 ··· 551 551 /** 552 552 * @task internal 553 553 */ 554 - private function shouldEnableSynchronization() { 554 + private function shouldEnableSynchronization($require_device) { 555 555 $repository = $this->getRepository(); 556 556 557 557 $service_phid = $repository->getAlmanacServicePHID(); ··· 563 563 return false; 564 564 } 565 565 566 - $device = AlmanacKeys::getLiveDevice(); 567 - if (!$device) { 568 - return false; 566 + if ($require_device) { 567 + $device = AlmanacKeys::getLiveDevice(); 568 + if (!$device) { 569 + return false; 570 + } 569 571 } 570 572 571 573 return true;