Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14448199
D19753.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
D19753.diff
View Options
diff --git a/src/applications/drydock/worker/DrydockLeaseUpdateWorker.php b/src/applications/drydock/worker/DrydockLeaseUpdateWorker.php
--- a/src/applications/drydock/worker/DrydockLeaseUpdateWorker.php
+++ b/src/applications/drydock/worker/DrydockLeaseUpdateWorker.php
@@ -666,6 +666,26 @@
DrydockLease $lease) {
$viewer = $this->getViewer();
+ // If this lease is marked as already in the process of reclaiming a
+ // resource, don't let it reclaim another one until the first reclaim
+ // completes. This stops one lease from reclaiming a large number of
+ // resources if the reclaims take a while to complete.
+ $reclaiming_phid = $lease->getAttribute('drydock.reclaimingPHID');
+ if ($reclaiming_phid) {
+ $reclaiming_resource = id(new DrydockResourceQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($reclaiming_phid))
+ ->withStatuses(
+ array(
+ DrydockResourceStatus::STATUS_ACTIVE,
+ DrydockResourceStatus::STATUS_RELEASED,
+ ))
+ ->executeOne();
+ if ($reclaiming_resource) {
+ return null;
+ }
+ }
+
$resources = id(new DrydockResourceQuery())
->setViewer($viewer)
->withBlueprintPHIDs(array($blueprint->getPHID()))
diff --git a/src/applications/drydock/worker/DrydockWorker.php b/src/applications/drydock/worker/DrydockWorker.php
--- a/src/applications/drydock/worker/DrydockWorker.php
+++ b/src/applications/drydock/worker/DrydockWorker.php
@@ -241,16 +241,25 @@
DrydockLease $lease) {
$viewer = $this->getViewer();
+ // Mark the lease as reclaiming this resource. It won't be allowed to start
+ // another reclaim as long as this resource is still in the process of
+ // being reclaimed.
+ $lease->setAttribute('drydock.reclaimingPHID', $resource->getPHID());
+
// When the resource releases, we we want to reawaken this task since it
- // should be able to start building a new resource right away.
+ // should (usually) be able to start building a new resource right away.
$worker_task_id = $this->getCurrentWorkerTaskID();
$command = DrydockCommand::initializeNewCommand($viewer)
->setTargetPHID($resource->getPHID())
->setAuthorPHID($lease->getPHID())
->setCommand(DrydockCommand::COMMAND_RECLAIM)
- ->setProperty('awakenTaskIDs', array($worker_task_id))
- ->save();
+ ->setProperty('awakenTaskIDs', array($worker_task_id));
+
+ $lease->openTransaction();
+ $lease->save();
+ $command->save();
+ $lease->saveTransaction();
$resource->scheduleUpdate();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 27, 4:04 PM (9 h, 43 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6932423
Default Alt Text
D19753.diff (2 KB)
Attached To
Mode
D19753: After a Drydock lease triggers a resource to be reclaimed, stop it from triggering another reclaim until the first one completes
Attached
Detach File
Event Timeline
Log In to Comment