From 580790cd6e35920b2bfd713a0c3f8ad7a1cf9d1e Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 6 Aug 2015 09:54:17 -0700 Subject: [PATCH] Prevent Harbormaster autobuilds from being stopped, paused or restarted Summary: Fixes T8657. "Auto" builds are pushed into Harbormaster by an external system (currently, `arc`) so it does not make sense to stop or resume them: Harbormaster has no way to control the external system. Test Plan: - Tried to restart an autobuild, got an error. - Restarted a normal build. - Did "Restart All" on a buildable, got restarts on non-autoplans and no restarts on autoplans. Reviewers: chad Reviewed By: chad Maniphest Tasks: T8657 Differential Revision: https://secure.phabricator.com/D13812 --- .../storage/build/HarbormasterBuild.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuild.php b/src/applications/harbormaster/storage/build/HarbormasterBuild.php index 439780e466..8d1128d009 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuild.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuild.php @@ -214,6 +214,10 @@ final class HarbormasterBuild extends HarbormasterDAO $this->getBuildStatus() === self::STATUS_BUILDING; } + public function isAutobuild() { + return ($this->getPlanAutoKey() !== null); + } + public function createLog( HarbormasterBuildTarget $build_target, $log_source, @@ -336,16 +340,28 @@ final class HarbormasterBuild extends HarbormasterDAO } public function canRestartBuild() { + if ($this->isAutobuild()) { + return false; + } + return !$this->isRestarting(); } public function canStopBuild() { + if ($this->isAutobuild()) { + return false; + } + return !$this->isComplete() && !$this->isStopped() && !$this->isStopping(); } public function canResumeBuild() { + if ($this->isAutobuild()) { + return false; + } + return $this->isStopped() && !$this->isResuming(); }