From 2326d5f8d090f5ca50c90d23d0e344869a7bee0a Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 26 Oct 2015 20:00:49 +0000 Subject: [PATCH] Show lease on Repository Operation detail view and awaken on failures Summary: Ref T182. Couple of minor improvements here: - Show the Drydock lease when viewing a Repository Operation detail screen. This just makes it easier to jump around between relevant objects. - When tasks are waiting for a lease, awaken them when it breaks or is released, not just when it is acquired. This makes the queue move forward faster when errors occur. Test Plan: - Viewed a repository operation and saw a link to the lease. - Did a bad land (intentional merge problem) and got an error in about ~3 seconds instead of ~17. Reviewers: chad Reviewed By: chad Maniphest Tasks: T182 Differential Revision: https://secure.phabricator.com/D14341 --- ...rydockRepositoryOperationViewController.php | 9 +++++++++ .../drydock/storage/DrydockLease.php | 18 ++++++++++++++---- .../storage/DrydockRepositoryOperation.php | 9 +++++++++ .../worker/DrydockLeaseUpdateWorker.php | 18 +++++++++++------- .../DrydockRepositoryOperationUpdateWorker.php | 2 +- 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/applications/drydock/controller/DrydockRepositoryOperationViewController.php b/src/applications/drydock/controller/DrydockRepositoryOperationViewController.php index e740073dd9..9a509a5c04 100644 --- a/src/applications/drydock/controller/DrydockRepositoryOperationViewController.php +++ b/src/applications/drydock/controller/DrydockRepositoryOperationViewController.php @@ -83,6 +83,15 @@ final class DrydockRepositoryOperationViewController pht('Object'), $viewer->renderHandle($operation->getObjectPHID())); + $lease_phid = $operation->getWorkingCopyLeasePHID(); + if ($lease_phid) { + $lease_display = $viewer->renderHandle($lease_phid); + } else { + $lease_display = phutil_tag('em', array(), pht('None')); + } + + $view->addProperty(pht('Working Copy'), $lease_display); + return $view; } diff --git a/src/applications/drydock/storage/DrydockLease.php b/src/applications/drydock/storage/DrydockLease.php index af475c5d61..0dd4e36b48 100644 --- a/src/applications/drydock/storage/DrydockLease.php +++ b/src/applications/drydock/storage/DrydockLease.php @@ -429,10 +429,7 @@ final class DrydockLease extends DrydockDAO $this->scheduleUpdate($expires); } - $awaken_ids = $this->getAttribute('internal.awakenTaskIDs'); - if (is_array($awaken_ids) && $awaken_ids) { - PhabricatorWorker::awakenTaskIDs($awaken_ids); - } + $this->awakenTasks(); } public function logEvent($type, array $data = array()) { @@ -454,6 +451,19 @@ final class DrydockLease extends DrydockDAO return $log->save(); } + /** + * Awaken yielded tasks after a state change. + * + * @return this + */ + public function awakenTasks() { + $awaken_ids = $this->getAttribute('internal.awakenTaskIDs'); + if (is_array($awaken_ids) && $awaken_ids) { + PhabricatorWorker::awakenTaskIDs($awaken_ids); + } + + return $this; + } /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/applications/drydock/storage/DrydockRepositoryOperation.php b/src/applications/drydock/storage/DrydockRepositoryOperation.php index 32e6ded9f3..6d7151b25d 100644 --- a/src/applications/drydock/storage/DrydockRepositoryOperation.php +++ b/src/applications/drydock/storage/DrydockRepositoryOperation.php @@ -167,6 +167,15 @@ final class DrydockRepositoryOperation extends DrydockDAO $this); } + public function setWorkingCopyLeasePHID($lease_phid) { + return $this->setProperty('exec.leasePHID', $lease_phid); + } + + public function getWorkingCopyLeasePHID() { + return $this->getProperty('exec.leasePHID'); + } + + /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/applications/drydock/worker/DrydockLeaseUpdateWorker.php b/src/applications/drydock/worker/DrydockLeaseUpdateWorker.php index 7d8cc98219..0c93647b89 100644 --- a/src/applications/drydock/worker/DrydockLeaseUpdateWorker.php +++ b/src/applications/drydock/worker/DrydockLeaseUpdateWorker.php @@ -751,6 +751,15 @@ final class DrydockLeaseUpdateWorker extends DrydockWorker { ->setStatus(DrydockLeaseStatus::STATUS_BROKEN) ->save(); + $lease->logEvent( + DrydockLeaseActivationFailureLogType::LOGCONST, + array( + 'class' => get_class($ex), + 'message' => $ex->getMessage(), + )); + + $lease->awakenTasks(); + $this->queueTask( __CLASS__, array( @@ -760,13 +769,6 @@ final class DrydockLeaseUpdateWorker extends DrydockWorker { 'objectPHID' => $lease->getPHID(), )); - $lease->logEvent( - DrydockLeaseActivationFailureLogType::LOGCONST, - array( - 'class' => get_class($ex), - 'message' => $ex->getMessage(), - )); - throw new PhabricatorWorkerPermanentFailureException( pht( 'Permanent failure while activating lease ("%s"): %s', @@ -796,6 +798,8 @@ final class DrydockLeaseUpdateWorker extends DrydockWorker { ->save(); $lease->logEvent(DrydockLeaseDestroyedLogType::LOGCONST); + + $lease->awakenTasks(); } } diff --git a/src/applications/drydock/worker/DrydockRepositoryOperationUpdateWorker.php b/src/applications/drydock/worker/DrydockRepositoryOperationUpdateWorker.php index e0361d3eed..a0dc1e5ebd 100644 --- a/src/applications/drydock/worker/DrydockRepositoryOperationUpdateWorker.php +++ b/src/applications/drydock/worker/DrydockRepositoryOperationUpdateWorker.php @@ -127,7 +127,7 @@ final class DrydockRepositoryOperationUpdateWorker } $operation - ->setProperty('exec.leasePHID', $lease->getPHID()) + ->setWorkingCopyLeasePHID($lease->getPHID()) ->save(); $lease->queueForActivation();