1
0
Fork 0
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:
epriestley 2016-05-30 08:30:57 -07:00
parent 10cc633b88
commit b352cae97d
7 changed files with 37 additions and 10 deletions

View file

@ -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();

View file

@ -19,6 +19,10 @@ final class PhabricatorStorageManagementDumpWorkflow
));
}
protected function isReadOnlyWorkflow() {
return true;
}
public function didExecute(PhutilArgumentParser $args) {
$api = $this->getAPI();
$patches = $this->getPatches();

View file

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

View file

@ -30,6 +30,10 @@ final class PhabricatorStorageManagementRenamespaceWorkflow
));
}
protected function isReadOnlyWorkflow() {
return true;
}
public function didExecute(PhutilArgumentParser $args) {
$console = PhutilConsole::getConsole();

View file

@ -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());

View file

@ -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();

View file

@ -45,11 +45,15 @@ 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 (!$this->isReadOnlyWorkflow()) {
if (PhabricatorEnv::isReadOnly()) {
if ($this->isForce()) {
PhabricatorEnv::setReadOnly(false, null);
@ -60,6 +64,7 @@ abstract class PhabricatorStorageManagementWorkflow
'override this mode.'));
}
}
}
return $this->didExecute($args);
}