mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 21:40:55 +01:00
Add an "Activated Epoch" and an "Acquired Epoch" to Drydock Leases
Summary: Ref T13189. See PHI690. When a lease is first acquired or activated, note the time. This supports better visibility into queue lengths. For now, this is only queryable via DB and visible in the UI, but can be more broadly exposed in the future. Test Plan: Landed a revision, saw the leases get sensible timestamps for acquisition/activation. Reviewers: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13189 Differential Revision: https://secure.phabricator.com/D19613
This commit is contained in:
parent
ee823982a4
commit
2f5c6541fc
4 changed files with 48 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_drydock.drydock_lease
|
||||
ADD acquiredEpoch INT UNSIGNED;
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_drydock.drydock_lease
|
||||
ADD activatedEpoch INT UNSIGNED;
|
|
@ -163,6 +163,30 @@ final class DrydockLeaseViewController extends DrydockLeaseController {
|
|||
}
|
||||
$view->addProperty(pht('Expires'), $until_display);
|
||||
|
||||
$acquired_epoch = $lease->getAcquiredEpoch();
|
||||
$activated_epoch = $lease->getActivatedEpoch();
|
||||
|
||||
if ($acquired_epoch) {
|
||||
$acquired_display = phabricator_datetime($acquired_epoch, $viewer);
|
||||
} else {
|
||||
if ($activated_epoch) {
|
||||
$acquired_display = phutil_tag(
|
||||
'em',
|
||||
array(),
|
||||
pht('Activated on Acquisition'));
|
||||
} else {
|
||||
$acquired_display = phutil_tag('em', array(), pht('Not Acquired'));
|
||||
}
|
||||
}
|
||||
$view->addProperty(pht('Acquired'), $acquired_display);
|
||||
|
||||
if ($activated_epoch) {
|
||||
$activated_display = phabricator_datetime($activated_epoch, $viewer);
|
||||
} else {
|
||||
$activated_display = phutil_tag('em', array(), pht('Not Activated'));
|
||||
}
|
||||
$view->addProperty(pht('Activated'), $activated_display);
|
||||
|
||||
$attributes = $lease->getAttributes();
|
||||
if ($attributes) {
|
||||
$view->addSectionHeader(
|
||||
|
|
|
@ -10,6 +10,8 @@ final class DrydockLease extends DrydockDAO
|
|||
protected $authorizingPHID;
|
||||
protected $attributes = array();
|
||||
protected $status = DrydockLeaseStatus::STATUS_PENDING;
|
||||
protected $acquiredEpoch;
|
||||
protected $activatedEpoch;
|
||||
|
||||
private $resource = self::ATTACHABLE;
|
||||
private $unconsumedCommands = self::ATTACHABLE;
|
||||
|
@ -62,6 +64,22 @@ final class DrydockLease extends DrydockDAO
|
|||
$this->scheduleUpdate();
|
||||
}
|
||||
|
||||
public function setStatus($status) {
|
||||
if ($status == DrydockLeaseStatus::STATUS_ACQUIRED) {
|
||||
if (!$this->getAcquiredEpoch()) {
|
||||
$this->setAcquiredEpoch(PhabricatorTime::getNow());
|
||||
}
|
||||
}
|
||||
|
||||
if ($status == DrydockLeaseStatus::STATUS_ACTIVE) {
|
||||
if (!$this->getActivatedEpoch()) {
|
||||
$this->setActivatedEpoch(PhabricatorTime::getNow());
|
||||
}
|
||||
}
|
||||
|
||||
return parent::setStatus($status);
|
||||
}
|
||||
|
||||
public function getLeaseName() {
|
||||
return pht('Lease %d', $this->getID());
|
||||
}
|
||||
|
@ -78,6 +96,8 @@ final class DrydockLease extends DrydockDAO
|
|||
'resourceType' => 'text128',
|
||||
'ownerPHID' => 'phid?',
|
||||
'resourcePHID' => 'phid?',
|
||||
'acquiredEpoch' => 'epoch?',
|
||||
'activatedEpoch' => 'epoch?',
|
||||
),
|
||||
self::CONFIG_KEY_SCHEMA => array(
|
||||
'key_resource' => array(
|
||||
|
|
Loading…
Reference in a new issue