Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15392015
D13751.id33214.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13751.id33214.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D13751: [harbormaster/core] Fix issue where exception during artifact save would result in orphaned lease
Attached
Detach File
Event Timeline
Log In to Comment