mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Formalize some more Drydock conditions and bookkeeping
Summary: Ref T13677. Track which resources a given lease has begun allocating or reclaiming in a more formal way, and add logging for waiting actions. The "allocating" mechanism is new. This will replace an existing similar "reclaiming" mechanism in a future change. Test Plan: See followup changes. Subscribers: yelirekim, PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13677 Differential Revision: https://secure.phabricator.com/D21806
This commit is contained in:
parent
1b6727ac3d
commit
13a37282bc
5 changed files with 106 additions and 5 deletions
|
@ -1229,6 +1229,8 @@ phutil_register_library_map(array(
|
|||
'DrydockLeaseStatus' => 'applications/drydock/constants/DrydockLeaseStatus.php',
|
||||
'DrydockLeaseUpdateWorker' => 'applications/drydock/worker/DrydockLeaseUpdateWorker.php',
|
||||
'DrydockLeaseViewController' => 'applications/drydock/controller/DrydockLeaseViewController.php',
|
||||
'DrydockLeaseWaitingForActivationLogType' => 'applications/drydock/logtype/DrydockLeaseWaitingForActivationLogType.php',
|
||||
'DrydockLeaseWaitingForReclamationLogType' => 'applications/drydock/logtype/DrydockLeaseWaitingForReclamationLogType.php',
|
||||
'DrydockLeaseWaitingForResourcesLogType' => 'applications/drydock/logtype/DrydockLeaseWaitingForResourcesLogType.php',
|
||||
'DrydockLog' => 'applications/drydock/storage/DrydockLog.php',
|
||||
'DrydockLogController' => 'applications/drydock/controller/DrydockLogController.php',
|
||||
|
@ -7294,6 +7296,8 @@ phutil_register_library_map(array(
|
|||
'DrydockLeaseStatus' => 'PhabricatorObjectStatus',
|
||||
'DrydockLeaseUpdateWorker' => 'DrydockWorker',
|
||||
'DrydockLeaseViewController' => 'DrydockLeaseController',
|
||||
'DrydockLeaseWaitingForActivationLogType' => 'DrydockLogType',
|
||||
'DrydockLeaseWaitingForReclamationLogType' => 'DrydockLogType',
|
||||
'DrydockLeaseWaitingForResourcesLogType' => 'DrydockLogType',
|
||||
'DrydockLog' => array(
|
||||
'DrydockDAO',
|
||||
|
|
|
@ -43,11 +43,6 @@ final class DrydockWorkingCopyBlueprintImplementation
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO: If we have a pending resource which is compatible with the
|
||||
// configuration for this lease, prevent a new allocation? Otherwise the
|
||||
// queue can fill up with copies of requests from the same lease. But
|
||||
// maybe we can deal with this with "pre-leasing"?
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
final class DrydockLeaseWaitingForActivationLogType extends DrydockLogType {
|
||||
|
||||
const LOGCONST = 'core.lease.waiting-for-activation';
|
||||
|
||||
public function getLogTypeName() {
|
||||
return pht('Waiting For Activation');
|
||||
}
|
||||
|
||||
public function getLogTypeIcon(array $data) {
|
||||
return 'fa-clock-o yellow';
|
||||
}
|
||||
|
||||
public function renderLog(array $data) {
|
||||
$resource_phids = idx($data, 'resourcePHIDs', array());
|
||||
|
||||
return pht(
|
||||
'Waiting for activation of resources: %s.',
|
||||
$this->renderHandleList($resource_phids));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
final class DrydockLeaseWaitingForReclamationLogType extends DrydockLogType {
|
||||
|
||||
const LOGCONST = 'core.lease.waiting-for-reclamation';
|
||||
|
||||
public function getLogTypeName() {
|
||||
return pht('Waiting For Reclamation');
|
||||
}
|
||||
|
||||
public function getLogTypeIcon(array $data) {
|
||||
return 'fa-clock-o yellow';
|
||||
}
|
||||
|
||||
public function renderLog(array $data) {
|
||||
$resource_phids = idx($data, 'resourcePHIDs', array());
|
||||
|
||||
return pht(
|
||||
'Waiting for reclamation of resources: %s.',
|
||||
$this->renderHandleList($resource_phids));
|
||||
}
|
||||
|
||||
}
|
|
@ -392,6 +392,62 @@ final class DrydockLease extends DrydockDAO
|
|||
));
|
||||
}
|
||||
|
||||
public function getAllocatedResourcePHIDs() {
|
||||
return $this->getAttribute('internal.resourcePHIDs.allocated', array());
|
||||
}
|
||||
|
||||
public function setAllocatedResourcePHIDs(array $phids) {
|
||||
return $this->setAttribute('internal.resourcePHIDs.allocated', $phids);
|
||||
}
|
||||
|
||||
public function addAllocatedResourcePHIDs(array $phids) {
|
||||
$allocated_phids = $this->getAllocatedResourcePHIDs();
|
||||
|
||||
foreach ($phids as $phid) {
|
||||
$allocated_phids[$phid] = $phid;
|
||||
}
|
||||
|
||||
return $this->setAllocatedResourcePHIDs($allocated_phids);
|
||||
}
|
||||
|
||||
public function removeAllocatedResourcePHIDs(array $phids) {
|
||||
$allocated_phids = $this->getAllocatedResourcePHIDs();
|
||||
|
||||
foreach ($phids as $phid) {
|
||||
unset($allocated_phids[$phid]);
|
||||
}
|
||||
|
||||
return $this->setAllocatedResourcePHIDs($allocated_phids);
|
||||
}
|
||||
|
||||
public function getReclaimedResourcePHIDs() {
|
||||
return $this->getAttribute('internal.resourcePHIDs.reclaimed', array());
|
||||
}
|
||||
|
||||
public function setReclaimedResourcePHIDs(array $phids) {
|
||||
return $this->setAttribute('internal.resourcePHIDs.reclaimed', $phids);
|
||||
}
|
||||
|
||||
public function addReclaimedResourcePHIDs(array $phids) {
|
||||
$reclaimed_phids = $this->getReclaimedResourcePHIDs();
|
||||
|
||||
foreach ($phids as $phid) {
|
||||
$reclaimed_phids[$phid] = $phid;
|
||||
}
|
||||
|
||||
return $this->setReclaimedResourcePHIDs($reclaimed_phids);
|
||||
}
|
||||
|
||||
public function removeReclaimedResourcePHIDs(array $phids) {
|
||||
$reclaimed_phids = $this->getReclaimedResourcePHIDs();
|
||||
|
||||
foreach ($phids as $phid) {
|
||||
unset($reclaimed_phids[$phid]);
|
||||
}
|
||||
|
||||
return $this->setReclaimedResourcePHIDs($reclaimed_phids);
|
||||
}
|
||||
|
||||
public function setAwakenTaskIDs(array $ids) {
|
||||
$this->setAttribute('internal.awakenTaskIDs', $ids);
|
||||
return $this;
|
||||
|
|
Loading…
Reference in a new issue