Page MenuHomePhabricator

D7935.id17956.diff
No OneTemporary

D7935.id17956.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -767,6 +767,7 @@
'HarbormasterStepDeleteController' => 'applications/harbormaster/controller/HarbormasterStepDeleteController.php',
'HarbormasterStepEditController' => 'applications/harbormaster/controller/HarbormasterStepEditController.php',
'HarbormasterTargetWorker' => 'applications/harbormaster/worker/HarbormasterTargetWorker.php',
+ 'HarbormasterThrowExceptionBuildStep' => 'applications/harbormaster/step/HarbormasterThrowExceptionBuildStep.php',
'HarbormasterUIEventListener' => 'applications/harbormaster/event/HarbormasterUIEventListener.php',
'HarbormasterWorker' => 'applications/harbormaster/worker/HarbormasterWorker.php',
'HeraldAction' => 'applications/herald/storage/HeraldAction.php',
@@ -3260,6 +3261,7 @@
'HarbormasterStepDeleteController' => 'HarbormasterController',
'HarbormasterStepEditController' => 'HarbormasterController',
'HarbormasterTargetWorker' => 'HarbormasterWorker',
+ 'HarbormasterThrowExceptionBuildStep' => 'BuildStepImplementation',
'HarbormasterUIEventListener' => 'PhabricatorEventListener',
'HarbormasterWorker' => 'PhabricatorWorker',
'HeraldAction' => 'HeraldDAO',
Index: src/applications/harbormaster/engine/HarbormasterBuildEngine.php
===================================================================
--- src/applications/harbormaster/engine/HarbormasterBuildEngine.php
+++ src/applications/harbormaster/engine/HarbormasterBuildEngine.php
@@ -163,17 +163,17 @@
}
}
- // If every step is complete, we're done with this build. Mark it passed
- // and bail.
- if (count($complete) == count($steps)) {
- $build->setBuildStatus(HarbormasterBuild::STATUS_PASSED);
+ // If any step failed, fail the whole build, then bail.
+ if (count($failed)) {
+ $build->setBuildStatus(HarbormasterBuild::STATUS_FAILED);
$build->save();
return;
}
- // If any step failed, fail the whole build, then bail.
- if (count($failed)) {
- $build->setBuildStatus(HarbormasterBuild::STATUS_FAILED);
+ // If every step is complete, we're done with this build. Mark it passed
+ // and bail.
+ if (count($complete) == count($steps)) {
+ $build->setBuildStatus(HarbormasterBuild::STATUS_PASSED);
$build->save();
return;
}
Index: src/applications/harbormaster/step/CommandBuildStepImplementation.php
===================================================================
--- src/applications/harbormaster/step/CommandBuildStepImplementation.php
+++ src/applications/harbormaster/step/CommandBuildStepImplementation.php
@@ -53,16 +53,6 @@
$log_stderr->append($stderr);
$future->discardBuffers();
- // Check to see if we have moved from a "Building" status. This
- // can occur if the user cancels the build, in which case we want
- // to terminate whatever we're doing and return as quickly as possible.
- if ($build->checkForCancellation()) {
- $log_stdout->finalize($start_stdout);
- $log_stderr->finalize($start_stderr);
- $future->resolveKill();
- return;
- }
-
// Wait one second before querying for more data.
sleep(1);
}
@@ -80,7 +70,7 @@
$log_stderr->finalize($start_stderr);
if ($err) {
- $build->setBuildStatus(HarbormasterBuild::STATUS_FAILED);
+ throw new Exception(pht('Command failed with error %d.', $err));
}
}
Index: src/applications/harbormaster/step/HarbormasterThrowExceptionBuildStep.php
===================================================================
--- /dev/null
+++ src/applications/harbormaster/step/HarbormasterThrowExceptionBuildStep.php
@@ -0,0 +1,25 @@
+<?php
+
+final class HarbormasterThrowExceptionBuildStep
+ extends BuildStepImplementation {
+
+ public function getName() {
+ return pht('Throw Exception');
+ }
+
+ public function getGenericDescription() {
+ return pht('Throw an exception.');
+ }
+
+ public function getDescription() {
+ return pht('Throw an exception.');
+ }
+
+ public function execute(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target) {
+
+ throw new Exception(pht('(This is an explicit exception.)'));
+ }
+
+}
Index: src/applications/harbormaster/step/WaitForPreviousBuildStepImplementation.php
===================================================================
--- src/applications/harbormaster/step/WaitForPreviousBuildStepImplementation.php
+++ src/applications/harbormaster/step/WaitForPreviousBuildStepImplementation.php
@@ -30,10 +30,6 @@
return;
}
- // We are blocked until all previous builds finish.
- $build->setBuildStatus(HarbormasterBuild::STATUS_WAITING);
- $build->save();
-
// Block until all previous builds of the same build plan have
// finished.
$plan = $build->getBuildPlan();
@@ -42,13 +38,6 @@
$log_start = null;
$blockers = $this->getBlockers($object, $plan, $build);
while (count($blockers) > 0) {
- if ($build->checkForCancellation()) {
- if ($log !== null) {
- $log->finalize($log_start);
- }
- return;
- }
-
if ($log === null) {
$log = $build->createLog($build_target, "waiting", "blockers");
$log_start = $log->start();
@@ -56,16 +45,14 @@
$log->append("Blocked by: ".implode(",", $blockers)."\n");
+ // TODO: This should fail temporarily instead after setting the target to
+ // waiting, and thereby push the build into a waiting status.
sleep(1);
$blockers = $this->getBlockers($object, $plan, $build);
}
if ($log !== null) {
$log->finalize($log_start);
}
-
- // Move back into building status.
- $build->setBuildStatus(HarbormasterBuild::STATUS_BUILDING);
- $build->save();
}
private function getBlockers(
Index: src/applications/harbormaster/worker/HarbormasterTargetWorker.php
===================================================================
--- src/applications/harbormaster/worker/HarbormasterTargetWorker.php
+++ src/applications/harbormaster/worker/HarbormasterTargetWorker.php
@@ -46,6 +46,17 @@
$target->save();
}
} catch (Exception $ex) {
+ phlog($ex);
+
+ try {
+ $log = $build->createLog($target, 'core', 'exception');
+ $start = $log->start();
+ $log->append((string)$ex);
+ $log->finalize($start);
+ } catch (Exception $log_ex) {
+ phlog($log_ex);
+ }
+
$target->setTargetStatus(HarbormasterBuildTarget::STATUS_FAILED);
$target->save();
}

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 2, 2:20 AM (6 d, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7472709
Default Alt Text
D7935.id17956.diff (6 KB)

Event Timeline