Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14773176
D11870.id28588.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D11870.id28588.diff
View Options
diff --git a/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php b/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php
--- a/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php
+++ b/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php
@@ -65,7 +65,7 @@
),
'build/' => array(
'(?P<id>\d+)/' => 'HarbormasterBuildViewController',
- '(?P<action>stop|resume|restart)/(?P<id>\d+)/(?:(?P<via>[^/]+)/)?'
+ '(?P<action>stop|resume|restart|abort)/(?P<id>\d+)/(?:(?P<via>[^/]+)/)?'
=> 'HarbormasterBuildActionController',
),
'plan/' => array(
diff --git a/src/applications/harbormaster/controller/HarbormasterBuildActionController.php b/src/applications/harbormaster/controller/HarbormasterBuildActionController.php
--- a/src/applications/harbormaster/controller/HarbormasterBuildActionController.php
+++ b/src/applications/harbormaster/controller/HarbormasterBuildActionController.php
@@ -41,6 +41,9 @@
case HarbormasterBuildCommand::COMMAND_RESUME:
$can_issue = $build->canResumeBuild();
break;
+ case HarbormasterBuildCommand::COMMAND_ABORT:
+ $can_issue = $build->canAbortBuild();
+ break;
default:
return new Aphront400Response();
}
@@ -91,6 +94,18 @@
}
}
break;
+ case HarbormasterBuildCommand::COMMAND_ABORT:
+ if ($can_issue) {
+ $title = pht('Really abort build?');
+ $body = pht(
+ 'Progress on this build will be discarded. Really '.
+ 'abort build?');
+ $submit = pht('Abort Build');
+ } else {
+ $title = pht('Unable to Abort Build');
+ $body = pht('You can not abort this build.');
+ }
+ break;
case HarbormasterBuildCommand::COMMAND_STOP:
if ($can_issue) {
$title = pht('Really pause build?');
diff --git a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php
--- a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php
+++ b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php
@@ -39,6 +39,8 @@
$header->setStatus('fa-exclamation-triangle', 'red', pht('Pausing'));
} else if ($build->isResuming()) {
$header->setStatus('fa-exclamation-triangle', 'red', pht('Resuming'));
+ } else if ($build->isAborting()) {
+ $header->setStatus('fa-exclamation-triangle', 'red', pht('Aborting'));
}
$box = id(new PHUIObjectBoxView())
@@ -391,6 +393,7 @@
$can_restart = $build->canRestartBuild();
$can_stop = $build->canStopBuild();
$can_resume = $build->canResumeBuild();
+ $can_abort = $build->canAbortBuild();
$list->addAction(
id(new PhabricatorActionView())
@@ -418,6 +421,14 @@
->setWorkflow(true));
}
+ $list->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Abort Build'))
+ ->setIcon('fa-exclamation-triangle')
+ ->setHref($this->getApplicationURI('/build/abort/'.$id.'/'))
+ ->setDisabled(!$can_abort)
+ ->setWorkflow(true));
+
return $list;
}
diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
--- a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
+++ b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
@@ -87,6 +87,7 @@
$can_restart = false;
$can_resume = false;
$can_stop = false;
+ $can_abort = false;
foreach ($buildable->getBuilds() as $build) {
if ($build->canRestartBuild()) {
@@ -98,11 +99,15 @@
if ($build->canStopBuild()) {
$can_stop = true;
}
+ if ($build->canAbortBuild()) {
+ $can_abort = true;
+ }
}
$restart_uri = "buildable/{$id}/restart/";
$stop_uri = "buildable/{$id}/stop/";
$resume_uri = "buildable/{$id}/resume/";
+ $abort_uri = "buildable/{$id}/abort/";
$list->addAction(
id(new PhabricatorActionView())
@@ -128,6 +133,14 @@
->setWorkflow(true)
->setDisabled(!$can_resume || !$can_edit));
+ $list->addAction(
+ id(new PhabricatorActionView())
+ ->setIcon('fa-exclamation-triangle')
+ ->setName(pht('Abort All Builds'))
+ ->setHref($this->getApplicationURI($stop_uri))
+ ->setWorkflow(true)
+ ->setDisabled(!$can_abort || !$can_edit));
+
return $list;
}
diff --git a/src/applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php b/src/applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php
--- a/src/applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php
+++ b/src/applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php
@@ -77,6 +77,9 @@
case HarbormasterBuildCommand::COMMAND_RESUME:
$issuable = $build->canResumeBuild();
break;
+ case HarbormasterBuildCommand::COMMAND_ABORT:
+ $issuable = $build->canAbortBuild();
+ break;
default:
throw new Exception("Unknown command $command");
}
diff --git a/src/applications/harbormaster/engine/HarbormasterBuildEngine.php b/src/applications/harbormaster/engine/HarbormasterBuildEngine.php
--- a/src/applications/harbormaster/engine/HarbormasterBuildEngine.php
+++ b/src/applications/harbormaster/engine/HarbormasterBuildEngine.php
@@ -105,6 +105,12 @@
$build->save();
}
+ if ($build->isAborting()) {
+ $this->restartBuild($build);
+ $build->setBuildStatus(HarbormasterBuild::STATUS_FAILED);
+ $build->save();
+ }
+
if ($build->isResuming()) {
$build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING);
$build->save();
diff --git a/src/applications/harbormaster/storage/HarbormasterBuildCommand.php b/src/applications/harbormaster/storage/HarbormasterBuildCommand.php
--- a/src/applications/harbormaster/storage/HarbormasterBuildCommand.php
+++ b/src/applications/harbormaster/storage/HarbormasterBuildCommand.php
@@ -5,6 +5,7 @@
const COMMAND_STOP = 'stop';
const COMMAND_RESUME = 'resume';
const COMMAND_RESTART = 'restart';
+ const COMMAND_ABORT = 'abort';
protected $authorPHID;
protected $targetPHID;
diff --git a/src/applications/harbormaster/storage/HarbormasterBuildTransaction.php b/src/applications/harbormaster/storage/HarbormasterBuildTransaction.php
--- a/src/applications/harbormaster/storage/HarbormasterBuildTransaction.php
+++ b/src/applications/harbormaster/storage/HarbormasterBuildTransaction.php
@@ -31,6 +31,10 @@
return pht(
'%s restarted this build.',
$this->renderHandleLink($author_phid));
+ case HarbormasterBuildCommand::COMMAND_ABORT:
+ return pht(
+ '%s aborted this build.',
+ $this->renderHandleLink($author_phid));
case HarbormasterBuildCommand::COMMAND_RESUME:
return pht(
'%s resumed this build.',
@@ -61,6 +65,8 @@
return 'fa-play';
case HarbormasterBuildCommand::COMMAND_STOP:
return 'fa-stop';
+ case HarbormasterBuildCommand::COMMAND_ABORT:
+ return 'fa-exclamation-triangle';
}
}
@@ -79,6 +85,7 @@
case self::TYPE_COMMAND:
switch ($new) {
case HarbormasterBuildCommand::COMMAND_STOP:
+ case HarbormasterBuildCommand::COMMAND_ABORT:
return 'red';
}
}
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuild.php b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuild.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
@@ -339,6 +339,10 @@
!$this->isStopping();
}
+ public function canAbortBuild() {
+ return !$this->isComplete();
+ }
+
public function canResumeBuild() {
return $this->isStopped() &&
!$this->isResuming();
@@ -356,6 +360,9 @@
case HarbormasterBuildCommand::COMMAND_RESTART:
$is_stopping = false;
break;
+ case HarbormasterBuildCommand::COMMAND_ABORT:
+ $is_stopping = true;
+ break;
}
}
@@ -374,6 +381,9 @@
case HarbormasterBuildCommand::COMMAND_STOP:
$is_resuming = false;
break;
+ case HarbormasterBuildCommand::COMMAND_ABORT:
+ $is_resuming = false;
+ break;
}
}
@@ -394,6 +404,20 @@
return $is_restarting;
}
+ public function isAborting() {
+ $is_aborting = false;
+ foreach ($this->getUnprocessedCommands() as $command_object) {
+ $command = $command_object->getCommand();
+ switch ($command) {
+ case HarbormasterBuildCommand::COMMAND_ABORT:
+ $is_aborting = true;
+ break;
+ }
+ }
+
+ return $is_aborting;
+ }
+
public function deleteUnprocessedCommands() {
foreach ($this->getUnprocessedCommands() as $key => $command_object) {
$command_object->delete();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 25, 12:22 AM (1 h, 20 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7045163
Default Alt Text
D11870.id28588.diff (9 KB)
Attached To
Mode
D11870: [harbormaster/abort-builds] Support aborting builds in Harbormaster
Attached
Detach File
Event Timeline
Log In to Comment