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:
		| @@ -10,6 +10,10 @@ final class PhabricatorStorageManagementDatabasesWorkflow | |||||||
|       ->setSynopsis(pht('List Phabricator databases.')); |       ->setSynopsis(pht('List Phabricator databases.')); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   protected function isReadOnlyWorkflow() { | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public function didExecute(PhutilArgumentParser $args) { |   public function didExecute(PhutilArgumentParser $args) { | ||||||
|     $api     = $this->getAPI(); |     $api     = $this->getAPI(); | ||||||
|     $patches = $this->getPatches(); |     $patches = $this->getPatches(); | ||||||
|   | |||||||
| @@ -19,6 +19,10 @@ final class PhabricatorStorageManagementDumpWorkflow | |||||||
|         )); |         )); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   protected function isReadOnlyWorkflow() { | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public function didExecute(PhutilArgumentParser $args) { |   public function didExecute(PhutilArgumentParser $args) { | ||||||
|     $api = $this->getAPI(); |     $api = $this->getAPI(); | ||||||
|     $patches = $this->getPatches(); |     $patches = $this->getPatches(); | ||||||
|   | |||||||
| @@ -10,6 +10,10 @@ final class PhabricatorStorageManagementProbeWorkflow | |||||||
|       ->setSynopsis(pht('Show approximate table sizes.')); |       ->setSynopsis(pht('Show approximate table sizes.')); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   protected function isReadOnlyWorkflow() { | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public function didExecute(PhutilArgumentParser $args) { |   public function didExecute(PhutilArgumentParser $args) { | ||||||
|     $console = PhutilConsole::getConsole(); |     $console = PhutilConsole::getConsole(); | ||||||
|     $console->writeErr( |     $console->writeErr( | ||||||
|   | |||||||
| @@ -30,6 +30,10 @@ final class PhabricatorStorageManagementRenamespaceWorkflow | |||||||
|         )); |         )); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   protected function isReadOnlyWorkflow() { | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public function didExecute(PhutilArgumentParser $args) { |   public function didExecute(PhutilArgumentParser $args) { | ||||||
|     $console = PhutilConsole::getConsole(); |     $console = PhutilConsole::getConsole(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,9 +10,11 @@ final class PhabricatorStorageManagementShellWorkflow | |||||||
|       ->setSynopsis(pht('Launch an interactive shell.')); |       ->setSynopsis(pht('Launch an interactive shell.')); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   protected function isReadOnlyWorkflow() { | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public function execute(PhutilArgumentParser $args) { |   public function execute(PhutilArgumentParser $args) { | ||||||
|  |  | ||||||
|  |  | ||||||
|     $api = $this->getAPI(); |     $api = $this->getAPI(); | ||||||
|     list($host, $port) = $this->getBareHostAndPort($api->getHost()); |     list($host, $port) = $this->getBareHostAndPort($api->getHost()); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,6 +10,10 @@ final class PhabricatorStorageManagementStatusWorkflow | |||||||
|       ->setSynopsis(pht('Show patch application status.')); |       ->setSynopsis(pht('Show patch application status.')); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   protected function isReadOnlyWorkflow() { | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public function didExecute(PhutilArgumentParser $args) { |   public function didExecute(PhutilArgumentParser $args) { | ||||||
|     $api     = $this->getAPI(); |     $api     = $this->getAPI(); | ||||||
|     $patches = $this->getPatches(); |     $patches = $this->getPatches(); | ||||||
|   | |||||||
| @@ -45,11 +45,15 @@ abstract class PhabricatorStorageManagementWorkflow | |||||||
|     return $this; |     return $this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   protected function isReadOnlyWorkflow() { | ||||||
|  |     return false; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public function execute(PhutilArgumentParser $args) { |   public function execute(PhutilArgumentParser $args) { | ||||||
|     $this->setDryRun($args->getArg('dryrun')); |     $this->setDryRun($args->getArg('dryrun')); | ||||||
|     $this->setForce($args->getArg('force')); |     $this->setForce($args->getArg('force')); | ||||||
|  |  | ||||||
|  |     if (!$this->isReadOnlyWorkflow()) { | ||||||
|       if (PhabricatorEnv::isReadOnly()) { |       if (PhabricatorEnv::isReadOnly()) { | ||||||
|         if ($this->isForce()) { |         if ($this->isForce()) { | ||||||
|           PhabricatorEnv::setReadOnly(false, null); |           PhabricatorEnv::setReadOnly(false, null); | ||||||
| @@ -60,6 +64,7 @@ abstract class PhabricatorStorageManagementWorkflow | |||||||
|               'override this mode.')); |               'override this mode.')); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     return $this->didExecute($args); |     return $this->didExecute($args); | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 epriestley
					epriestley