mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Don't stop on read-only mode for read-only storage workflows
Summary: Fixes T11042. Currently, all `bin/storage` workflows stop if `cluster.read-only` is set: ``` $ ./bin/storage adjust Usage Exception: Phabricator is currently in read-only mode. Use --force to override this mode. ``` However, some of them (`status`, `dump`, `databases`, etc) are read-only anyway and safe to run. Don't prompt in these cases. Test Plan: - Set `cluster.read-only` to `true`. - Ran `bin/storage dump`, `bin/storage status`, etc. No longer received messages. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11042 Differential Revision: https://secure.phabricator.com/D15987
This commit is contained in:
parent
10cc633b88
commit
b352cae97d
7 changed files with 37 additions and 10 deletions
|
@ -10,6 +10,10 @@ final class PhabricatorStorageManagementDatabasesWorkflow
|
|||
->setSynopsis(pht('List Phabricator databases.'));
|
||||
}
|
||||
|
||||
protected function isReadOnlyWorkflow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function didExecute(PhutilArgumentParser $args) {
|
||||
$api = $this->getAPI();
|
||||
$patches = $this->getPatches();
|
||||
|
|
|
@ -19,6 +19,10 @@ final class PhabricatorStorageManagementDumpWorkflow
|
|||
));
|
||||
}
|
||||
|
||||
protected function isReadOnlyWorkflow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function didExecute(PhutilArgumentParser $args) {
|
||||
$api = $this->getAPI();
|
||||
$patches = $this->getPatches();
|
||||
|
|
|
@ -10,6 +10,10 @@ final class PhabricatorStorageManagementProbeWorkflow
|
|||
->setSynopsis(pht('Show approximate table sizes.'));
|
||||
}
|
||||
|
||||
protected function isReadOnlyWorkflow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function didExecute(PhutilArgumentParser $args) {
|
||||
$console = PhutilConsole::getConsole();
|
||||
$console->writeErr(
|
||||
|
|
|
@ -30,6 +30,10 @@ final class PhabricatorStorageManagementRenamespaceWorkflow
|
|||
));
|
||||
}
|
||||
|
||||
protected function isReadOnlyWorkflow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function didExecute(PhutilArgumentParser $args) {
|
||||
$console = PhutilConsole::getConsole();
|
||||
|
||||
|
|
|
@ -10,9 +10,11 @@ final class PhabricatorStorageManagementShellWorkflow
|
|||
->setSynopsis(pht('Launch an interactive shell.'));
|
||||
}
|
||||
|
||||
protected function isReadOnlyWorkflow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function execute(PhutilArgumentParser $args) {
|
||||
|
||||
|
||||
$api = $this->getAPI();
|
||||
list($host, $port) = $this->getBareHostAndPort($api->getHost());
|
||||
|
||||
|
|
|
@ -10,6 +10,10 @@ final class PhabricatorStorageManagementStatusWorkflow
|
|||
->setSynopsis(pht('Show patch application status.'));
|
||||
}
|
||||
|
||||
protected function isReadOnlyWorkflow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function didExecute(PhutilArgumentParser $args) {
|
||||
$api = $this->getAPI();
|
||||
$patches = $this->getPatches();
|
||||
|
|
|
@ -45,19 +45,24 @@ abstract class PhabricatorStorageManagementWorkflow
|
|||
return $this;
|
||||
}
|
||||
|
||||
protected function isReadOnlyWorkflow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function execute(PhutilArgumentParser $args) {
|
||||
$this->setDryRun($args->getArg('dryrun'));
|
||||
$this->setForce($args->getArg('force'));
|
||||
|
||||
if (PhabricatorEnv::isReadOnly()) {
|
||||
if ($this->isForce()) {
|
||||
PhabricatorEnv::setReadOnly(false, null);
|
||||
} else {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht(
|
||||
'Phabricator is currently in read-only mode. Use --force to '.
|
||||
'override this mode.'));
|
||||
if (!$this->isReadOnlyWorkflow()) {
|
||||
if (PhabricatorEnv::isReadOnly()) {
|
||||
if ($this->isForce()) {
|
||||
PhabricatorEnv::setReadOnly(false, null);
|
||||
} else {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht(
|
||||
'Phabricator is currently in read-only mode. Use --force to '.
|
||||
'override this mode.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue