mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Improve consistency in use of "via", "objectPHID", and "containerPHID" parameters in repository workers
Summary: Ref T13591. Improve how parameters are passed between commit worker tasks: - Always pass "via", to track where tasks came from. - Always provide "objectPHID" (with the commit PHID). - Always provide "containerPHID" (with the repository PHID). Test Plan: - Pushed a new commit. - Ran `bin/repository pull` + `bin/repository discover`, saw commit with all parameters. - Ran `bin/worker execute ...`, saw a Change worker and then a Publish worker with appropriate parameters. - Ran `bin/repository reparse ... --background`, saw workers queue with appropriate parameters. Maniphest Tasks: T13591 Differential Revision: https://secure.phabricator.com/D21532
This commit is contained in:
parent
201e0d2943
commit
de70a4ff26
6 changed files with 47 additions and 24 deletions
|
@ -119,6 +119,7 @@ abstract class PhabricatorRepositoryEngine extends Phobject {
|
||||||
$options = array(
|
$options = array(
|
||||||
'priority' => $task_priority,
|
'priority' => $task_priority,
|
||||||
'objectPHID' => $commit_phid,
|
'objectPHID' => $commit_phid,
|
||||||
|
'containerPHID' => $repository->getPHID(),
|
||||||
);
|
);
|
||||||
|
|
||||||
PhabricatorWorker::scheduleTask($class, $data, $options);
|
PhabricatorWorker::scheduleTask($class, $data, $options);
|
||||||
|
|
|
@ -249,6 +249,7 @@ final class PhabricatorRepositoryManagementReparseWorkflow
|
||||||
$spec = array(
|
$spec = array(
|
||||||
'commitID' => $commit->getID(),
|
'commitID' => $commit->getID(),
|
||||||
'only' => !$importing,
|
'only' => !$importing,
|
||||||
|
'via' => 'reparse',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($classes as $class) {
|
foreach ($classes as $class) {
|
||||||
|
@ -258,6 +259,8 @@ final class PhabricatorRepositoryManagementReparseWorkflow
|
||||||
$spec,
|
$spec,
|
||||||
array(
|
array(
|
||||||
'priority' => PhabricatorWorker::PRIORITY_IMPORT,
|
'priority' => PhabricatorWorker::PRIORITY_IMPORT,
|
||||||
|
'objectPHID' => $commit->getPHID(),
|
||||||
|
'containerPHID' => $repository->getPHID(),
|
||||||
));
|
));
|
||||||
} catch (PhabricatorWorkerPermanentFailureException $ex) {
|
} catch (PhabricatorWorkerPermanentFailureException $ex) {
|
||||||
// See T13315. We expect some reparse steps to occasionally raise
|
// See T13315. We expect some reparse steps to occasionally raise
|
||||||
|
|
|
@ -51,10 +51,42 @@ abstract class PhabricatorRepositoryCommitParserWorker
|
||||||
$this->parseCommit($repository, $this->commit);
|
$this->parseCommit($repository, $this->commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function shouldQueueFollowupTasks() {
|
private function shouldQueueFollowupTasks() {
|
||||||
return !idx($this->getTaskData(), 'only');
|
return !idx($this->getTaskData(), 'only');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final protected function queueCommitTask($task_class) {
|
||||||
|
if (!$this->shouldQueueFollowupTasks()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$commit = $this->loadCommit();
|
||||||
|
$repository = $commit->getRepository();
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'commitID' => $commit->getID(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$task_data = $this->getTaskData();
|
||||||
|
if (isset($task_data['via'])) {
|
||||||
|
$data['via'] = $task_data['via'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = array(
|
||||||
|
// We queue followup tasks at default priority so that the queue finishes
|
||||||
|
// work it has started before starting more work. If followups are queued
|
||||||
|
// at the same priority level, we do all message parses first, then all
|
||||||
|
// change parses, etc. This makes progress uneven. See T11677 for
|
||||||
|
// discussion.
|
||||||
|
'priority' => parent::PRIORITY_DEFAULT,
|
||||||
|
|
||||||
|
'objectPHID' => $commit->getPHID(),
|
||||||
|
'containerPHID' => $repository->getPHID(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->queueTask($task_class, $data, $options);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getImportStepFlag() {
|
protected function getImportStepFlag() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,6 +396,8 @@ final class PhabricatorChangeParserTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubversionParser() {
|
public function testSubversionParser() {
|
||||||
|
$this->requireBinaryForTest('svn');
|
||||||
|
|
||||||
$repository = $this->buildDiscoveredRepository('CHC');
|
$repository = $this->buildDiscoveredRepository('CHC');
|
||||||
$viewer = PhabricatorUser::getOmnipotentUser();
|
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||||
|
|
||||||
|
@ -955,6 +957,8 @@ final class PhabricatorChangeParserTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubversionPartialParser() {
|
public function testSubversionPartialParser() {
|
||||||
|
$this->requireBinaryForTest('svn');
|
||||||
|
|
||||||
$repository = $this->buildBareRepository('CHD');
|
$repository = $this->buildBareRepository('CHD');
|
||||||
$repository->setDetail('svn-subpath', 'trunk/');
|
$repository->setDetail('svn-subpath', 'trunk/');
|
||||||
|
|
||||||
|
@ -1059,6 +1063,8 @@ final class PhabricatorChangeParserTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubversionValidRootParser() {
|
public function testSubversionValidRootParser() {
|
||||||
|
$this->requireBinaryForTest('svn');
|
||||||
|
|
||||||
// First, automatically configure the root correctly.
|
// First, automatically configure the root correctly.
|
||||||
$repository = $this->buildBareRepository('CHD');
|
$repository = $this->buildBareRepository('CHD');
|
||||||
id(new PhabricatorRepositoryPullEngine())
|
id(new PhabricatorRepositoryPullEngine())
|
||||||
|
@ -1104,6 +1110,8 @@ final class PhabricatorChangeParserTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubversionForeignStubsParser() {
|
public function testSubversionForeignStubsParser() {
|
||||||
|
$this->requireBinaryForTest('svn');
|
||||||
|
|
||||||
$repository = $this->buildBareRepository('CHE');
|
$repository = $this->buildBareRepository('CHE');
|
||||||
$repository->setDetail('svn-subpath', 'branch/');
|
$repository->setDetail('svn-subpath', 'branch/');
|
||||||
|
|
||||||
|
|
|
@ -99,14 +99,7 @@ abstract class PhabricatorRepositoryCommitChangeParserWorker
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function finishParse() {
|
protected function finishParse() {
|
||||||
$commit = $this->commit;
|
$this->queueCommitTask('PhabricatorRepositoryCommitPublishWorker');
|
||||||
if ($this->shouldQueueFollowupTasks()) {
|
|
||||||
$this->queueTask(
|
|
||||||
'PhabricatorRepositoryCommitPublishWorker',
|
|
||||||
array(
|
|
||||||
'commitID' => $commit->getID(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function writeCommitChanges(
|
private function writeCommitChanges(
|
||||||
|
|
|
@ -24,21 +24,7 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
||||||
$this->updateCommitData($commit, $data);
|
$this->updateCommitData($commit, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->shouldQueueFollowupTasks()) {
|
$this->queueCommitTask($this->getFollowupTaskClass());
|
||||||
$this->queueTask(
|
|
||||||
$this->getFollowupTaskClass(),
|
|
||||||
array(
|
|
||||||
'commitID' => $commit->getID(),
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
// We queue followup tasks at default priority so that the queue
|
|
||||||
// finishes work it has started before starting more work. If
|
|
||||||
// followups are queued at the same priority level, we do all
|
|
||||||
// message parses first, then all change parses, etc. This makes
|
|
||||||
// progress uneven. See T11677 for discussion.
|
|
||||||
'priority' => PhabricatorWorker::PRIORITY_DEFAULT,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function updateCommitData(
|
final protected function updateCommitData(
|
||||||
|
|
Loading…
Reference in a new issue