Index: src/applications/drydock/worker/DrydockAllocatorWorker.php =================================================================== --- src/applications/drydock/worker/DrydockAllocatorWorker.php +++ src/applications/drydock/worker/DrydockAllocatorWorker.php @@ -104,6 +104,12 @@ continue; } + if ($lease->getAttribute('resourceID') !== null && + $candidate->getID() !== $lease->getAttribute('resourceID')) { + unset($pool[$key]); + continue; + } + $blueprint = $blueprints[$candidate->getBlueprintPHID()]; $implementation = $blueprint->getImplementation(); @@ -144,6 +150,12 @@ continue; } + if ($lease->getAttribute('resourceID') !== null && + $candidate->getID() !== $lease->getAttribute('resourceID')) { + unset($pool[$key]); + continue; + } + $blueprint = $blueprints[$candidate->getBlueprintPHID()]; $implementation = $blueprint->getImplementation(); @@ -173,6 +185,21 @@ if ($resource) { $lock->unlock(); } else { + if ($lease->getAttribute('resourceID') !== null) { + $reason = pht( + 'Could not lease against specific resource %d.', + $lease->getAttribute('resourceID')); + + $lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN); + $lease->setBrokenReason($reason); + $lease->save(); + + $this->logToDrydock($reason); + + $lock->unlock(); + return; + } + $blueprints = id(new DrydockBlueprintQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->execute();