Page MenuHomePhabricator

D10504.id33798.diff
No OneTemporary

D10504.id33798.diff

diff --git a/resources/sql/autopatches/20140917.drydockbrokereason.1.sql b/resources/sql/autopatches/20140917.drydockbrokereason.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140917.drydockbrokereason.1.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_drydock.drydock_lease
+ ADD brokenReason LONGTEXT NULL COLLATE utf8_bin;
diff --git a/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
@@ -205,6 +205,7 @@
if ($allocation_exception) {
$lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
+ $lease->setBrokenReason($allocation_exception->getMessage());
$lease->save();
$this->logException($allocation_exception);
$this->closeResourceIfDesired($resource);
@@ -273,6 +274,7 @@
$this->executeAcquireLease($resource, $ephemeral_lease);
} catch (Exception $ex) {
$lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
+ $lease->setBrokenReason($ex->getMessage());
$lease->save();
$this->logException($ex);
$this->closeResourceIfDesired($resource);
@@ -450,6 +452,7 @@
case DrydockLeaseStatus::STATUS_PENDING:
$message = pht('Breaking pending lease (resource closing).');
$lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
+ $lease->setBrokenReason('Resource forcibly closed');
break;
case DrydockLeaseStatus::STATUS_ACTIVE:
$message = pht('Releasing active lease (resource closing).');
diff --git a/src/applications/drydock/controller/DrydockLeaseViewController.php b/src/applications/drydock/controller/DrydockLeaseViewController.php
--- a/src/applications/drydock/controller/DrydockLeaseViewController.php
+++ b/src/applications/drydock/controller/DrydockLeaseViewController.php
@@ -112,6 +112,12 @@
pht('Status'),
$status);
+ if ($lease->getBrokenReason() !== null) {
+ $view->addProperty(
+ pht('Reason for Broken Status'),
+ $lease->getBrokenReason());
+ }
+
$view->addProperty(
pht('Resource Type'),
$lease->getResourceType());
diff --git a/src/applications/drydock/storage/DrydockLease.php b/src/applications/drydock/storage/DrydockLease.php
--- a/src/applications/drydock/storage/DrydockLease.php
+++ b/src/applications/drydock/storage/DrydockLease.php
@@ -11,6 +11,7 @@
protected $status = DrydockLeaseStatus::STATUS_PENDING;
protected $taskID;
protected $isTransientLease = 0;
+ protected $brokenReason;
private $resource = self::ATTACHABLE;
private $ownerHandle = self::ATTACHABLE;
@@ -177,11 +178,18 @@
unset($unresolved[$key]);
break;
case DrydockLeaseStatus::STATUS_RELEASED:
- throw new Exception(pht('Lease has already been released!'));
+ throw new Exception(pht(
+ 'Lease %d has already been released!',
+ $lease->getID()));
case DrydockLeaseStatus::STATUS_EXPIRED:
- throw new Exception(pht('Lease has already expired!'));
+ throw new Exception(pht(
+ 'Lease %d has already expired!',
+ $lease->getID()));
case DrydockLeaseStatus::STATUS_BROKEN:
- throw new Exception(pht('Lease has been broken!'));
+ throw new Exception(pht(
+ 'Lease %d has been broken! Reason was: %s',
+ $lease->getID(),
+ $lease->getBrokenReason()));
case DrydockLeaseStatus::STATUS_PENDING:
case DrydockLeaseStatus::STATUS_ACQUIRING:
break;
diff --git a/src/applications/drydock/worker/DrydockAllocatorWorker.php b/src/applications/drydock/worker/DrydockAllocatorWorker.php
--- a/src/applications/drydock/worker/DrydockAllocatorWorker.php
+++ b/src/applications/drydock/worker/DrydockAllocatorWorker.php
@@ -64,8 +64,8 @@
$lease->reload();
if ($lease->getStatus() == DrydockLeaseStatus::STATUS_PENDING ||
$lease->getStatus() == DrydockLeaseStatus::STATUS_ACQUIRING) {
-
$lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
+ $lease->setBrokenReason($ex->getMessage());
$lease->save();
}
@@ -222,12 +222,22 @@
foreach ($blueprints as $key => $candidate_blueprint) {
if (!$candidate_blueprint->isEnabled()) {
+ $this->logToDrydock(
+ pht(
+ '%s is not currently enabled',
+ get_class($candidate_blueprint)));
+
unset($blueprints[$key]);
continue;
}
if ($candidate_blueprint->getType() !==
$lease->getResourceType()) {
+ $this->logToDrydock(
+ pht(
+ '%s does not allocate resources of the required type',
+ get_class($candidate_blueprint)));
+
unset($blueprints[$key]);
continue;
}

File Metadata

Mime Type
text/plain
Expires
Mar 16 2025, 9:05 AM (5 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706708
Default Alt Text
D10504.id33798.diff (4 KB)

Event Timeline