mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 07:20:57 +01:00
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
This commit is contained in:
parent
b3e4743ad7
commit
f3e154eb02
2 changed files with 15 additions and 4 deletions
|
@ -222,8 +222,10 @@ abstract class DiffusionSSHWorkflow extends PhabricatorSSHWorkflow {
|
|||
pht('No repository "%s" exists!', $identifier));
|
||||
}
|
||||
|
||||
$is_cluster = $this->getIsClusterRequest();
|
||||
|
||||
$protocol = PhabricatorRepositoryURI::BUILTIN_PROTOCOL_SSH;
|
||||
if (!$repository->canServeProtocol($protocol, false)) {
|
||||
if (!$repository->canServeProtocol($protocol, false, $is_cluster)) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'This repository ("%s") is not available over SSH.',
|
||||
|
|
|
@ -1506,9 +1506,18 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
return $this->setDetail('hosting-enabled', $enabled);
|
||||
}
|
||||
|
||||
public function canServeProtocol($protocol, $write) {
|
||||
if (!$this->isTracked()) {
|
||||
return false;
|
||||
public function canServeProtocol(
|
||||
$protocol,
|
||||
$write,
|
||||
$is_intracluster = false) {
|
||||
|
||||
// See T13192. If a repository is inactive, don't serve it to users. We
|
||||
// still synchronize it within the cluster and serve it to other repository
|
||||
// nodes.
|
||||
if (!$is_intracluster) {
|
||||
if (!$this->isTracked()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$clone_uris = $this->getCloneURIs();
|
||||
|
|
Loading…
Reference in a new issue