Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15411122
D10409.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
D10409.diff
View Options
diff --git a/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
@@ -171,7 +171,10 @@
}
if ($allocation_exception) {
+ $lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
+ $lease->save();
$this->logException($allocation_exception);
+ $this->closeResourceIfDesired($resource);
}
return $allocated;
@@ -236,7 +239,10 @@
try {
$this->executeAcquireLease($resource, $ephemeral_lease);
} catch (Exception $ex) {
+ $lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
+ $lease->save();
$this->logException($ex);
+ $this->closeResourceIfDesired($resource);
throw $ex;
}
@@ -319,25 +325,30 @@
}
if (!$caused_by_closing_resource) {
- // Check to see if the resource has no more leases, and if so, ask the
- // blueprint as to whether this resource should be closed.
- $context = new DrydockAllocationContext(
- $this->getInstance(),
- $resource,
- $lease);
-
- if ($context->getCurrentResourceLeaseCount() === 0) {
- if ($this->shouldCloseUnleasedResource($context, $resource)) {
- self::writeLog(
- $resource,
- null,
- pht('Closing resource because it has no more active leases'));
- $this->closeResource($resource);
- }
- }
+ $this->closeResourceIfDesired($resource);
}
}
+ private function closeResourceIfDesired(
+ DrydockResource $resource) {
+
+ // Check to see if the resource has no more leases, and if so, ask the
+ // blueprint as to whether this resource should be closed.
+ $context = new DrydockAllocationContext(
+ $this->getInstance(),
+ $resource,
+ null);
+
+ if ($context->getCurrentResourceLeaseCount() === 0) {
+ if ($this->shouldCloseUnleasedResource($context, $resource)) {
+ self::writeLog(
+ $resource,
+ null,
+ pht('Closing resource because it has no more active leases'));
+ $this->closeResource($resource);
+ }
+ }
+ }
/* -( Resource Allocation )------------------------------------------------ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 8:51 AM (18 h, 37 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7709290
Default Alt Text
D10409.diff (2 KB)
Attached To
Mode
D10409: [drydock/core] Mark leases as broken when failing to acquiring lease
Attached
Detach File
Event Timeline
Log In to Comment