Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/worker/DrydockLeaseUpdateWorker.php
Show First 20 Lines • Show All 660 Lines • ▼ Show 20 Lines | private function validateAllocatedResource( | ||||
} | } | ||||
} | } | ||||
private function reclaimResources( | private function reclaimResources( | ||||
DrydockBlueprint $blueprint, | DrydockBlueprint $blueprint, | ||||
DrydockLease $lease) { | DrydockLease $lease) { | ||||
$viewer = $this->getViewer(); | $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()) | $resources = id(new DrydockResourceQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withBlueprintPHIDs(array($blueprint->getPHID())) | ->withBlueprintPHIDs(array($blueprint->getPHID())) | ||||
->withStatuses( | ->withStatuses( | ||||
array( | array( | ||||
DrydockResourceStatus::STATUS_ACTIVE, | DrydockResourceStatus::STATUS_ACTIVE, | ||||
)) | )) | ||||
->execute(); | ->execute(); | ||||
▲ Show 20 Lines • Show All 251 Lines • Show Last 20 Lines |