Page MenuHomePhabricator

D13751.id33214.diff
No OneTemporary

D13751.id33214.diff

Index: src/applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php
===================================================================
--- src/applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php
+++ src/applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php
@@ -29,16 +29,27 @@
'platform' => $settings['platform'],
) + $custom_attributes)
->queueForActivation();
-
- // Create the associated artifact.
- $artifact = $build->createArtifact(
- $build_target,
- $settings['name'],
- HarbormasterBuildArtifact::TYPE_HOST);
- $artifact->setArtifactData(array(
- 'drydock-lease' => $lease->getID(),
- ));
- $artifact->save();
+ try {
+ // Create the associated artifact.
+ $artifact = $build->createArtifact(
+ $build_target,
+ $settings['name'],
+ HarbormasterBuildArtifact::TYPE_HOST);
+ $artifact->setArtifactData(array(
+ 'drydock-lease' => $lease->getID(),
+ ));
+ $artifact->save();
+ } 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;
+ }
// Wait until the lease is fulfilled.
// TODO: This will throw an exception if the lease can't be fulfilled;
Index: src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
===================================================================
--- src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
+++ src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
@@ -28,16 +28,27 @@
) + $this->getLeaseAttributes($build, $build_target, $settings)
+ $custom_attributes)
->queueForActivation();
-
- // Create the associated artifact.
- $artifact = $build->createArtifact(
- $build_target,
- $settings['name'],
- HarbormasterBuildArtifact::TYPE_HOST);
- $artifact->setArtifactData(array(
- 'drydock-lease' => $lease->getID(),
- ));
- $artifact->save();
+ try {
+ // Create the associated artifact.
+ $artifact = $build->createArtifact(
+ $build_target,
+ $settings['name'],
+ HarbormasterBuildArtifact::TYPE_HOST);
+ $artifact->setArtifactData(array(
+ 'drydock-lease' => $lease->getID(),
+ ));
+ $artifact->save();
+ } 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;
+ }
// Wait until the lease is fulfilled.
// TODO: This will throw an exception if the lease can't be fulfilled;

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 16, 12:52 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7707072
Default Alt Text
D13751.id33214.diff (3 KB)

Event Timeline