Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15379583
D13420.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D13420.diff
View Options
Index: src/applications/drydock/blueprint/DrydockMinMaxBlueprintImplementation.php
===================================================================
--- src/applications/drydock/blueprint/DrydockMinMaxBlueprintImplementation.php
+++ src/applications/drydock/blueprint/DrydockMinMaxBlueprintImplementation.php
@@ -79,6 +79,16 @@
return true;
}
+ // If the lease requests a specific resource, then bypass
+ // `leases-per-instance` limit, as it requires data provided by
+ // another lease on the same resource.
+ if ($lease->getAttribute('resourceID') !== null) {
+ $this->log(pht(
+ 'Lease requested a specific resource; bypassing limit checks.'));
+
+ return true;
+ }
+
// We don't have enough room under the `leases-per-instance` limit, but
// this limit can be bypassed if we've allocated all of the resources
// we allow.
Index: src/applications/drydock/blueprint/DrydockMinMaxExpiryBlueprintImplementation.php
===================================================================
--- src/applications/drydock/blueprint/DrydockMinMaxExpiryBlueprintImplementation.php
+++ src/applications/drydock/blueprint/DrydockMinMaxExpiryBlueprintImplementation.php
@@ -56,6 +56,15 @@
return parent::shouldAllocateLease($context, $resource, $lease);
}
+ // If the lease requests a specific resource, then bypass expiry checks
+ // as it requires data provided by another lease on the same resource.
+ if ($lease->getAttribute('resourceID') !== null) {
+ $this->log(pht(
+ 'Lease requested a specific resource; bypassing expiry checks'));
+
+ return parent::shouldAllocateLease($context, $resource, $lease);
+ }
+
$expiry = $this->getDetail('expiry');
if ($expiry !== null) {
@@ -87,8 +96,7 @@
if ($lifetime > $expiry) {
$this->log(pht(
- 'Current lifetime of resource exceeds expiry; triggering close',
- $resource->getID()));
+ 'Current lifetime of resource exceeds expiry; triggering close'));
// Force closure of resources that have expired.
return true;
Index: src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
===================================================================
--- src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
+++ src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
@@ -307,22 +307,30 @@
$this->log(pht(
'Limiting lease acquisition to resource ID %d.',
$resource_id));
- }
- $this->log('Acquiring new host lease for working copy...');
+ $resource_lease = $this->acquireHostLeaseOnSpecificResource(
+ $resource_id,
+ $lease->getAttribute('platform'));
+ } else {
+ $this->log('Acquiring new host lease for working copy...');
- $resource_lease = id(new DrydockLease())
- ->setResourceType('host')
- ->setAttributes(
- array(
- 'resourceID' => $resource_id,
- 'platform' => $lease->getAttribute('platform'),
- ))
- ->waitUntilActive();
+ $resource_lease = id(new DrydockLease())
+ ->setResourceType('host')
+ ->setAttributes(
+ array(
+ 'platform' => $lease->getAttribute('platform'),
+ ))
+ ->waitUntilActive();
- $this->log(pht(
- 'Lease %d acquired for working copy resource.',
- $resource_lease->getID()));
+ $this->log(pht(
+ 'Lease %d acquired for working copy resource.',
+ $resource_lease->getID()));
+ }
+
+ $resource->setName(
+ $resource->getName().' on '.
+ $resource_lease->getResource()->getName());
+ $resource->save();
if ($lease->getAttribute('platform') === 'windows') {
$cmd = $resource_lease->getInterface(
@@ -448,19 +456,10 @@
'Using existing host lease %d for working copy resource.',
$host_lease_id));
} else {
- $this->log('Acquiring new host lease for working copy...');
- $host_lease = id(new DrydockLease())
- ->setResourceType('host')
- ->setAttributes(
- array(
- 'resourceID' => $resource->getAttribute('host.resource'),
- 'platform' => $lease->getAttribute('platform'),
- ))
- ->waitUntilActive();
+ $host_lease = $this->acquireHostLeaseOnSpecificResource(
+ $resource->getAttribute('host.resource'),
+ $lease->getAttribute('platform'));
$host_lease_id = $host_lease->getID();
- $this->log(pht(
- 'Lease %d acquired for working copy resource.',
- $host_lease_id));
}
$lease->setAttribute('host.lease', $host_lease_id);
@@ -515,6 +514,29 @@
}
}
+ private function acquireHostLeaseOnSpecificResource(
+ $resource_id,
+ $platform) {
+
+ $host_lease = id(new DrydockLease())
+ ->setResourceType('host')
+ ->setAttributes(
+ array(
+ 'resourceID' => $resource_id,
+ 'platform' => $platform,
+ ))
+ ->queueForActivation();
+ $this->log(pht(
+ 'Acquiring new host lease %d for working copy (on resource %d)...',
+ $host_lease->getID(),
+ $resource_id));
+ $host_lease->waitUntilActive();
+ $this->log(pht(
+ 'Lease %d acquired for working copy resource.',
+ $host_lease->getID()));
+ return $host_lease;
+ }
+
private function initializeSubmodules(
DrydockLease $working_directory_lease,
$working_directory_path = null) {
Index: src/applications/drydock/worker/DrydockAllocatorWorker.php
===================================================================
--- src/applications/drydock/worker/DrydockAllocatorWorker.php
+++ src/applications/drydock/worker/DrydockAllocatorWorker.php
@@ -185,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();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 14 2025, 10:04 PM (5 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7673148
Default Alt Text
D13420.diff (6 KB)
Attached To
Mode
D13420: Fix issues with working copies not leasing against correct resources
Attached
Detach File
Event Timeline
Log In to Comment