Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15415546
D19761.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
D19761.diff
View Options
diff --git a/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockAlmanacServiceHostBlueprintImplementation.php
@@ -113,6 +113,14 @@
DrydockBlueprint $blueprint,
DrydockResource $resource,
DrydockLease $lease) {
+
+ // Require the binding to a given host be active before we'll hand out more
+ // leases on the corresponding resource.
+ $binding = $this->loadBindingForResource($resource);
+ if ($binding->getIsDisabled()) {
+ return false;
+ }
+
return true;
}
@@ -154,24 +162,10 @@
DrydockLease $lease,
$type) {
- $viewer = PhabricatorUser::getOmnipotentUser();
-
switch ($type) {
case DrydockCommandInterface::INTERFACE_TYPE:
$credential_phid = $blueprint->getFieldValue('credentialPHID');
- $binding_phid = $resource->getAttribute('almanacBindingPHID');
-
- $binding = id(new AlmanacBindingQuery())
- ->setViewer($viewer)
- ->withPHIDs(array($binding_phid))
- ->executeOne();
- if (!$binding) {
- throw new Exception(
- pht(
- 'Unable to load binding "%s" to create command interface.',
- $binding_phid));
- }
-
+ $binding = $this->loadBindingForResource($resource);
$interface = $binding->getInterface();
return id(new DrydockSSHCommandInterface())
@@ -213,7 +207,7 @@
$blueprint->getBlueprintName()));
}
- $viewer = PhabricatorUser::getOmnipotentUser();
+ $viewer = $this->getViewer();
$services = id(new AlmanacServiceQuery())
->setViewer($viewer)
->withPHIDs($service_phids)
@@ -246,7 +240,7 @@
private function loadFreeBindings(DrydockBlueprint $blueprint) {
if ($this->freeBindings === null) {
- $viewer = PhabricatorUser::getOmnipotentUser();
+ $viewer = $this->getViewer();
$pool = id(new DrydockResourceQuery())
->setViewer($viewer)
@@ -293,5 +287,31 @@
);
}
+ private function loadBindingForResource(DrydockResource $resource) {
+ $binding_phid = $resource->getAttribute('almanacBindingPHID');
+ if (!$binding_phid) {
+ throw new Exception(
+ pht(
+ 'Drydock resource ("%s") has no Almanac binding PHID, so its '.
+ 'binding can not be loaded.',
+ $resource->getPHID()));
+ }
+
+ $viewer = $this->getViewer();
+
+ $binding = id(new AlmanacBindingQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($binding_phid))
+ ->executeOne();
+ if (!$binding) {
+ throw new Exception(
+ pht(
+ 'Unable to load Almanac binding ("%s") for resource ("%s").',
+ $binding_phid,
+ $resource->getPHID()));
+ }
+
+ return $binding;
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 21, 6:36 AM (15 h, 51 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7715101
Default Alt Text
D19761.diff (2 KB)
Attached To
Mode
D19761: When a Drydock host based on an Almanac blueprint has its binding disabled, stop handing out leases
Attached
Detach File
Event Timeline
Log In to Comment