From 5f774f7008b48d22839ced7040fbe5b1d48c2d34 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 27 Apr 2018 11:22:49 -0700 Subject: [PATCH] Stop build target start times from being overwritten on reentry Summary: See PHI615. Ref T13130. An install is reporting that "Lease Working Copy" build steps always report "Built instantly" after completion. I'm not 100% sure that this is the fix, but I'm like 99% sure: "Lease Working Copy" build steps yield after they ask Drydock for a lease. They will later reenter `doWork()`, see that the lease is filled, and complete. Right now, we reset the start time every time we enter `doWork()`. Instead, set it only if it hasn't been set yet. Test Plan: This is low-risk and a bit tricky to reproduce locally, but I'll run some production builds and see what they look like. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13130 Differential Revision: https://secure.phabricator.com/D19412 --- .../harbormaster/worker/HarbormasterTargetWorker.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/applications/harbormaster/worker/HarbormasterTargetWorker.php b/src/applications/harbormaster/worker/HarbormasterTargetWorker.php index fa3a01272b..a6860f579c 100644 --- a/src/applications/harbormaster/worker/HarbormasterTargetWorker.php +++ b/src/applications/harbormaster/worker/HarbormasterTargetWorker.php @@ -46,7 +46,13 @@ final class HarbormasterTargetWorker extends HarbormasterWorker { $build = $target->getBuild(); $viewer = $this->getViewer(); - $target->setDateStarted(time()); + // If this is the first time we're starting work on this target, mark the + // current time as the start time. If the target yields or waits, we may + // end up here again later, so we don't want to overwrite the start time if + // we already have a value. + if (!$target->getDateStarted()) { + $target->setDateStarted(PhabricatorTime::getNow()); + } try { if ($target->getBuildGeneration() !== $build->getBuildGeneration()) {