Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15408076
D10208.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D10208.diff
View Options
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
@@ -66,6 +66,9 @@
$build->save();
$lock->unlock();
+
+ $this->releaseAllArtifacts($build);
+
throw $ex;
}
@@ -87,6 +90,11 @@
if ($new_status != $old_status || $this->shouldForceBuildableUpdate()) {
$this->updateBuildable($build->getBuildable());
}
+
+ // If we are no longer building for any reason, release all artifacts.
+ if (!$build->isBuilding()) {
+ $this->releaseAllArtifacts($build);
+ }
}
private function updateBuild(HarbormasterBuild $build) {
@@ -115,6 +123,8 @@
}
private function destroyBuildTargets(HarbormasterBuild $build) {
+ $this->releaseAllArtifacts($build);
+
$targets = id(new HarbormasterBuildTargetQuery())
->setViewer($this->getViewer())
->withBuildPHIDs(array($build->getPHID()))
@@ -440,4 +450,27 @@
}
}
+ private function releaseAllArtifacts(HarbormasterBuild $build) {
+ $targets = id(new HarbormasterBuildTargetQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withBuildPHIDs(array($build->getPHID()))
+ ->execute();
+
+ if (count($targets) === 0) {
+ return;
+ }
+
+ $target_phids = mpull($targets, 'getPHID');
+
+ $artifacts = id(new HarbormasterBuildArtifactQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withBuildTargetPHIDs($target_phids)
+ ->execute();
+
+ foreach ($artifacts as $artifact) {
+ $artifact->release();
+ }
+
+ }
+
}
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php b/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
@@ -125,6 +125,24 @@
return $file;
}
+ public function release() {
+ switch ($this->getArtifactType()) {
+ case self::TYPE_HOST:
+ $this->releaseDrydockLease();
+ break;
+ }
+ }
+
+ public function releaseDrydockLease() {
+ $lease = $this->loadDrydockLease();
+ $resource = $lease->getResource();
+ $blueprint = $resource->getBlueprint();
+
+ if ($lease->isActive()) {
+ $blueprint->releaseLease($resource, $lease);
+ }
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 19, 9:14 PM (21 h, 53 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7230409
Default Alt Text
D10208.diff (2 KB)
Attached To
Mode
D10208: Implement artifact release for Harbormaster
Attached
Detach File
Event Timeline
Log In to Comment