@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.

Allow "inactive" repositories to be read over SSH for cluster sync

Summary:
Fixes T13192. See PHI1015. When you deactivate a repository, we currently stop serving it.

This creates a problem for intracluster sync, since new nodes can't sync it. If nothing else, this means that if you "ship of theseus" your cluster and turn nodes over one at a time, you will eventually lose the entire repository. Since that's clearly a bad outcome, support sync.

Test Plan:
Testing this requires a "real" cluster, so I mostly used `secure`.

I deactivated rGITTEST and ran this on `secure002`:

```
./bin/repository thaw --demote secure002.phacility.net --force GITTEST && ./bin/repository update GITTEST
```

Before the patch, this failed:

```
[2019-01-31 19:40:37] EXCEPTION: (CommandException) Command failed with error #128!
COMMAND
git fetch --prune -- 'ssh://172.30.0.64:22/diffusion/GITTEST/' '+refs/*:refs/*'

STDOUT
(empty)

STDERR
Warning: Permanently added '172.30.0.64' (RSA) to the list of known hosts.
phabricator-ssh-exec: This repository ("rGITTEST") is not available over SSH.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```

After applying (a similar patch to) this patch to `secure001`, the sync worked.

I'll repeat this test with the actual patch once this deploys to `secure`.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13192

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

+15 -4
+3 -1
src/applications/diffusion/ssh/DiffusionSSHWorkflow.php
··· 222 222 pht('No repository "%s" exists!', $identifier)); 223 223 } 224 224 225 + $is_cluster = $this->getIsClusterRequest(); 226 + 225 227 $protocol = PhabricatorRepositoryURI::BUILTIN_PROTOCOL_SSH; 226 - if (!$repository->canServeProtocol($protocol, false)) { 228 + if (!$repository->canServeProtocol($protocol, false, $is_cluster)) { 227 229 throw new Exception( 228 230 pht( 229 231 'This repository ("%s") is not available over SSH.',
+12 -3
src/applications/repository/storage/PhabricatorRepository.php
··· 1506 1506 return $this->setDetail('hosting-enabled', $enabled); 1507 1507 } 1508 1508 1509 - public function canServeProtocol($protocol, $write) { 1510 - if (!$this->isTracked()) { 1511 - return false; 1509 + public function canServeProtocol( 1510 + $protocol, 1511 + $write, 1512 + $is_intracluster = false) { 1513 + 1514 + // See T13192. If a repository is inactive, don't serve it to users. We 1515 + // still synchronize it within the cluster and serve it to other repository 1516 + // nodes. 1517 + if (!$is_intracluster) { 1518 + if (!$this->isTracked()) { 1519 + return false; 1520 + } 1512 1521 } 1513 1522 1514 1523 $clone_uris = $this->getCloneURIs();