Page MenuHomePhabricator

D13751.id33213.diff
No OneTemporary

D13751.id33213.diff

Index: src/applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php
===================================================================
--- src/applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php
+++ src/applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php
@@ -29,21 +29,32 @@
'platform' => $settings['platform'],
) + $custom_attributes)
->queueForActivation();
+ try {
+ // Create the associated artifact.
+ $artifact = $build->createArtifact(
+ $build_target,
+ $settings['name'],
+ HarbormasterBuildArtifact::TYPE_HOST);
+ $artifact->setArtifactData(array(
+ 'drydock-lease' => $lease->getID(),
+ ));
+ $artifact->save();
- // Create the associated artifact.
- $artifact = $build->createArtifact(
- $build_target,
- $settings['name'],
- HarbormasterBuildArtifact::TYPE_HOST);
- $artifact->setArtifactData(array(
- 'drydock-lease' => $lease->getID(),
- ));
- $artifact->save();
-
- // Wait until the lease is fulfilled.
- // TODO: This will throw an exception if the lease can't be fulfilled;
- // we should treat that as build failure not build error.
- $lease->waitUntilActive();
+ // Wait until the lease is fulfilled.
+ // TODO: This will throw an exception if the lease can't be fulfilled;
+ // we should treat that as build failure not build error.
+ $lease->waitUntilActive();
+ } catch (Exception $ex) {
+ // Make sure the lease is released if we fail
+ // for any reason.
+ $lease->reload();
+ $lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
+ $lease->setBrokenReason(pht(
+ 'Failed to save artifact reference to lease, so the lease '.
+ 'was forcibly broken by Harbormaster.'));
+ $lease->save();
+ throw $ex;
+ }
}
public function getArtifactOutputs() {
Index: src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
===================================================================
--- src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
+++ src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
@@ -28,21 +28,32 @@
) + $this->getLeaseAttributes($build, $build_target, $settings)
+ $custom_attributes)
->queueForActivation();
+ try {
+ // Create the associated artifact.
+ $artifact = $build->createArtifact(
+ $build_target,
+ $settings['name'],
+ HarbormasterBuildArtifact::TYPE_HOST);
+ $artifact->setArtifactData(array(
+ 'drydock-lease' => $lease->getID(),
+ ));
+ $artifact->save();
- // Create the associated artifact.
- $artifact = $build->createArtifact(
- $build_target,
- $settings['name'],
- HarbormasterBuildArtifact::TYPE_HOST);
- $artifact->setArtifactData(array(
- 'drydock-lease' => $lease->getID(),
- ));
- $artifact->save();
-
- // Wait until the lease is fulfilled.
- // TODO: This will throw an exception if the lease can't be fulfilled;
- // we should treat that as build failure not build error.
- $lease->waitUntilActive();
+ // Wait until the lease is fulfilled.
+ // TODO: This will throw an exception if the lease can't be fulfilled;
+ // we should treat that as build failure not build error.
+ $lease->waitUntilActive();
+ } catch (Exception $ex) {
+ // Make sure the lease is released if we fail
+ // for any reason.
+ $lease->reload();
+ $lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
+ $lease->setBrokenReason(pht(
+ 'Failed to save artifact reference to lease, so the lease '.
+ 'was forcibly broken by Harbormaster.'));
+ $lease->save();
+ throw $ex;
+ }
}
public function getArtifactOutputs() {

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 20, 11:39 AM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7713042
Default Alt Text
D13751.id33213.diff (3 KB)

Event Timeline