1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

Prevent "Wait for Build Commits" from creating billions of logs

Summary:
Resolves T5987.  This build step was at some point converted to use yielding, which meant that whenever the build step executes it will create a new log.  This checks to see if there is an existing log before creating a new one and uses that instead.

Long term we're going to need some way of attaching data to `PhabricatorWorkerYieldException` that can be read when the build step starts again; this will allow us to move more build steps off `while (...) { ... sleep(X); }` loops and onto yielding.

Test Plan: Tested locally.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley

Maniphest Tasks: T5987

Differential Revision: https://secure.phabricator.com/D10383
This commit is contained in:
James Rhodes 2014-08-30 02:11:45 +10:00
parent d1936711a0
commit f015cb50fe

View file

@ -28,14 +28,23 @@ final class HarbormasterWaitForPreviousBuildStepImplementation
// finished.
$plan = $build->getBuildPlan();
$existing_logs = id(new HarbormasterBuildLogQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withBuildTargetPHIDs(array($build_target->getPHID()))
->execute();
if ($existing_logs) {
$log = head($existing_logs);
} else {
$log = $build->createLog($build_target, 'waiting', 'blockers');
$log_start = $log->start();
}
$blockers = $this->getBlockers($object, $plan, $build);
if ($blockers) {
$log->start();
$log->append("Blocked by: ".implode(',', $blockers)."\n");
$log->finalize();
}
$log->finalize($log_start);
if ($blockers) {
throw new PhabricatorWorkerYieldException(15);