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

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

+37 -10
+4
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDatabasesWorkflow.php
··· 10 10 ->setSynopsis(pht('List Phabricator databases.')); 11 11 } 12 12 13 + protected function isReadOnlyWorkflow() { 14 + return true; 15 + } 16 + 13 17 public function didExecute(PhutilArgumentParser $args) { 14 18 $api = $this->getAPI(); 15 19 $patches = $this->getPatches();
+4
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php
··· 19 19 )); 20 20 } 21 21 22 + protected function isReadOnlyWorkflow() { 23 + return true; 24 + } 25 + 22 26 public function didExecute(PhutilArgumentParser $args) { 23 27 $api = $this->getAPI(); 24 28 $patches = $this->getPatches();
+4
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementProbeWorkflow.php
··· 10 10 ->setSynopsis(pht('Show approximate table sizes.')); 11 11 } 12 12 13 + protected function isReadOnlyWorkflow() { 14 + return true; 15 + } 16 + 13 17 public function didExecute(PhutilArgumentParser $args) { 14 18 $console = PhutilConsole::getConsole(); 15 19 $console->writeErr(
+4
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementRenamespaceWorkflow.php
··· 30 30 )); 31 31 } 32 32 33 + protected function isReadOnlyWorkflow() { 34 + return true; 35 + } 36 + 33 37 public function didExecute(PhutilArgumentParser $args) { 34 38 $console = PhutilConsole::getConsole(); 35 39
+4 -2
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementShellWorkflow.php
··· 10 10 ->setSynopsis(pht('Launch an interactive shell.')); 11 11 } 12 12 13 - public function execute(PhutilArgumentParser $args) { 14 - 13 + protected function isReadOnlyWorkflow() { 14 + return true; 15 + } 15 16 17 + public function execute(PhutilArgumentParser $args) { 16 18 $api = $this->getAPI(); 17 19 list($host, $port) = $this->getBareHostAndPort($api->getHost()); 18 20
+4
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementStatusWorkflow.php
··· 10 10 ->setSynopsis(pht('Show patch application status.')); 11 11 } 12 12 13 + protected function isReadOnlyWorkflow() { 14 + return true; 15 + } 16 + 13 17 public function didExecute(PhutilArgumentParser $args) { 14 18 $api = $this->getAPI(); 15 19 $patches = $this->getPatches();
+13 -8
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php
··· 45 45 return $this; 46 46 } 47 47 48 + protected function isReadOnlyWorkflow() { 49 + return false; 50 + } 48 51 49 52 public function execute(PhutilArgumentParser $args) { 50 53 $this->setDryRun($args->getArg('dryrun')); 51 54 $this->setForce($args->getArg('force')); 52 55 53 - if (PhabricatorEnv::isReadOnly()) { 54 - if ($this->isForce()) { 55 - PhabricatorEnv::setReadOnly(false, null); 56 - } else { 57 - throw new PhutilArgumentUsageException( 58 - pht( 59 - 'Phabricator is currently in read-only mode. Use --force to '. 60 - 'override this mode.')); 56 + if (!$this->isReadOnlyWorkflow()) { 57 + if (PhabricatorEnv::isReadOnly()) { 58 + if ($this->isForce()) { 59 + PhabricatorEnv::setReadOnly(false, null); 60 + } else { 61 + throw new PhutilArgumentUsageException( 62 + pht( 63 + 'Phabricator is currently in read-only mode. Use --force to '. 64 + 'override this mode.')); 65 + } 61 66 } 62 67 } 63 68