1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-21 22:32:41 +01:00

Add an "--ignore-locality" flag to "bin/repository pull"

Summary:
Ref T13600. When migrating observed repositories between cluster services, impact can be better controlled by fetching a copy of the repository on the target host before clusterizing it.

In particular, in the Phacility cluster, migrations are generally from one shared shard to one dedicated shard. It's helpful to perform these migrations synchronously without waiting for the cluster to sync in the background (helpful in the sense that there are fewer steps and fewer commands to run).

This supports an "--observe" mode to the internal "bin/services load-repository" workflow, which transfers repository data by refetching it from the remote rather than by getting it from the older host. This fetch occurs before cluster configuration is adjusted.

Test Plan: Ran locally as a sanity check, will apply in production.

Maniphest Tasks: T13600

Differential Revision: https://secure.phabricator.com/D21544
This commit is contained in:
epriestley 2021-02-04 10:13:34 -08:00
parent a7bd58c4bb
commit 00cf93548b
2 changed files with 14 additions and 2 deletions

View file

@ -14,6 +14,12 @@ final class PhabricatorRepositoryManagementPullWorkflow
'name' => 'verbose',
'help' => pht('Show additional debugging information.'),
),
array(
'name' => 'ignore-locality',
'help' => pht(
'Pull even if the repository should not be present on this '.
'host according to repository cluster configuration.'),
),
array(
'name' => 'repos',
'wildcard' => true,
@ -22,8 +28,9 @@ final class PhabricatorRepositoryManagementPullWorkflow
}
public function execute(PhutilArgumentParser $args) {
$repos = $this->loadLocalRepositories($args, 'repos');
$ignore_locality = (bool)$args->getArg('ignore-locality');
$repos = $this->loadLocalRepositories($args, 'repos', $ignore_locality);
if (!$repos) {
throw new PhutilArgumentUsageException(
pht('Specify one or more repositories to pull.'));

View file

@ -35,13 +35,18 @@ abstract class PhabricatorRepositoryManagementWorkflow
protected function loadLocalRepositories(
PhutilArgumentParser $args,
$param) {
$param,
$ignore_locality = false) {
$repositories = $this->loadRepositories($args, $param);
if (!$repositories) {
return $repositories;
}
if ($ignore_locality) {
return $repositories;
}
$device = AlmanacKeys::getLiveDevice();
$viewer = $this->getViewer();