mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Remove obsolete, confusing Harbormaster builds steps
Summary: Fixes T10458. These steps are obsolete and have not worked since the last updates to Drydock. They may eventually return in some form, but get rid of them for now since they're confusing. Test Plan: - Created a build plan with these steps. - Removed these steps. - Verified the build plan showed that the steps were invalid, and that I could delete them. - Deleted them. - Added new steps, no obsolete steps were available for selection. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10458 Differential Revision: https://secure.phabricator.com/D15352
This commit is contained in:
parent
0290cf0816
commit
c64b822bee
7 changed files with 42 additions and 242 deletions
|
@ -1094,7 +1094,6 @@ phutil_register_library_map(array(
|
|||
'HarbormasterBuildableTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildableTransactionQuery.php',
|
||||
'HarbormasterBuildableViewController' => 'applications/harbormaster/controller/HarbormasterBuildableViewController.php',
|
||||
'HarbormasterBuiltinBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterBuiltinBuildStepGroup.php',
|
||||
'HarbormasterCommandBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterCommandBuildStepImplementation.php',
|
||||
'HarbormasterConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterConduitAPIMethod.php',
|
||||
'HarbormasterController' => 'applications/harbormaster/controller/HarbormasterController.php',
|
||||
'HarbormasterCreateArtifactConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php',
|
||||
|
@ -1108,7 +1107,6 @@ phutil_register_library_map(array(
|
|||
'HarbormasterFileArtifact' => 'applications/harbormaster/artifact/HarbormasterFileArtifact.php',
|
||||
'HarbormasterHTTPRequestBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php',
|
||||
'HarbormasterHostArtifact' => 'applications/harbormaster/artifact/HarbormasterHostArtifact.php',
|
||||
'HarbormasterLeaseHostBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php',
|
||||
'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php',
|
||||
'HarbormasterLintMessagesController' => 'applications/harbormaster/controller/HarbormasterLintMessagesController.php',
|
||||
'HarbormasterLintPropertyView' => 'applications/harbormaster/view/HarbormasterLintPropertyView.php',
|
||||
|
@ -5259,7 +5257,6 @@ phutil_register_library_map(array(
|
|||
'HarbormasterBuildableTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
'HarbormasterBuildableViewController' => 'HarbormasterController',
|
||||
'HarbormasterBuiltinBuildStepGroup' => 'HarbormasterBuildStepGroup',
|
||||
'HarbormasterCommandBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
||||
'HarbormasterConduitAPIMethod' => 'ConduitAPIMethod',
|
||||
'HarbormasterController' => 'PhabricatorController',
|
||||
'HarbormasterCreateArtifactConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
|
||||
|
@ -5273,7 +5270,6 @@ phutil_register_library_map(array(
|
|||
'HarbormasterFileArtifact' => 'HarbormasterArtifact',
|
||||
'HarbormasterHTTPRequestBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
||||
'HarbormasterHostArtifact' => 'HarbormasterDrydockLeaseArtifact',
|
||||
'HarbormasterLeaseHostBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
||||
'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
|
||||
'HarbormasterLintMessagesController' => 'HarbormasterController',
|
||||
'HarbormasterLintPropertyView' => 'AphrontView',
|
||||
|
|
|
@ -105,31 +105,31 @@ final class HarbormasterPlanViewController extends HarbormasterPlanController {
|
|||
$i++;
|
||||
}
|
||||
|
||||
$step_id = $step->getID();
|
||||
$view_uri = $this->getApplicationURI("step/view/{$step_id}/");
|
||||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName(pht('Step %d.%d', $depth, $i))
|
||||
->setHeader($step->getName())
|
||||
->setHref($view_uri);
|
||||
|
||||
$step_list->addItem($item);
|
||||
|
||||
$implementation = null;
|
||||
try {
|
||||
$implementation = $step->getStepImplementation();
|
||||
} catch (Exception $ex) {
|
||||
// We can't initialize the implementation. This might be because
|
||||
// it's been renamed or no longer exists.
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName(pht('Step %d.%d', $depth, $i))
|
||||
->setHeader(pht('Unknown Implementation'))
|
||||
$item
|
||||
->setStatusIcon('fa-warning red')
|
||||
->addAttribute(pht(
|
||||
'This step has an invalid implementation (%s).',
|
||||
$step->getClassName()));
|
||||
$step_list->addItem($item);
|
||||
continue;
|
||||
}
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName(pht('Step %d.%d', $depth, $i))
|
||||
->setHeader($step->getName());
|
||||
|
||||
$item->addAttribute($implementation->getDescription());
|
||||
|
||||
$step_id = $step->getID();
|
||||
|
||||
$view_uri = $this->getApplicationURI("step/view/{$step_id}/");
|
||||
$item->setHref($view_uri);
|
||||
|
||||
$depends = $step->getStepImplementation()->getDependencies($step);
|
||||
|
|
|
@ -18,8 +18,6 @@ final class HarbormasterStepViewController extends HarbormasterController {
|
|||
$plan_id = $plan->getID();
|
||||
$plan_uri = $this->getApplicationURI("plan/{$plan_id}/");
|
||||
|
||||
$implementation = $step->getStepImplementation();
|
||||
|
||||
$field_list = PhabricatorCustomField::getObjectFields(
|
||||
$step,
|
||||
PhabricatorCustomField::ROLE_VIEW);
|
||||
|
@ -65,6 +63,25 @@ final class HarbormasterStepViewController extends HarbormasterController {
|
|||
->setUser($viewer)
|
||||
->setObject($step);
|
||||
|
||||
try {
|
||||
$implementation = $step->getStepImplementation();
|
||||
} catch (Exception $ex) {
|
||||
$implementation = null;
|
||||
}
|
||||
|
||||
if ($implementation) {
|
||||
$type = $implementation->getName();
|
||||
} else {
|
||||
$type = phutil_tag(
|
||||
'em',
|
||||
array(),
|
||||
pht(
|
||||
'Invalid Implementation ("%s")!',
|
||||
$step->getClassName()));
|
||||
}
|
||||
|
||||
$view->addProperty(pht('Step Type'), $type);
|
||||
|
||||
$view->addProperty(
|
||||
pht('Created'),
|
||||
phabricator_datetime($step->getDateCreated(), $viewer));
|
||||
|
|
|
@ -9,7 +9,12 @@ final class HarbormasterBuildStepCoreCustomField
|
|||
}
|
||||
|
||||
public function createFields($object) {
|
||||
$impl = $object->getStepImplementation();
|
||||
try {
|
||||
$impl = $object->getStepImplementation();
|
||||
} catch (Exception $ex) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$specs = $impl->getFieldSpecifications();
|
||||
|
||||
if ($impl->supportsWaitForMessage()) {
|
||||
|
|
|
@ -48,7 +48,12 @@ final class HarbormasterBuildGraph extends AbstractDirectedGraph {
|
|||
$map = array();
|
||||
foreach ($nodes as $node) {
|
||||
$step = $this->stepMap[$node];
|
||||
$deps = $step->getStepImplementation()->getDependencies($step);
|
||||
|
||||
try {
|
||||
$deps = $step->getStepImplementation()->getDependencies($step);
|
||||
} catch (Exception $ex) {
|
||||
$deps = array();
|
||||
}
|
||||
|
||||
$map[$node] = array();
|
||||
foreach ($deps as $dep) {
|
||||
|
|
|
@ -1,149 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class HarbormasterCommandBuildStepImplementation
|
||||
extends HarbormasterBuildStepImplementation {
|
||||
|
||||
private $platform;
|
||||
|
||||
public function getName() {
|
||||
return pht('Run Command');
|
||||
}
|
||||
|
||||
public function getGenericDescription() {
|
||||
return pht('Run a command on Drydock host.');
|
||||
}
|
||||
|
||||
public function getBuildStepGroupKey() {
|
||||
return HarbormasterPrototypeBuildStepGroup::GROUPKEY;
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return pht(
|
||||
'Run command %s on host %s.',
|
||||
$this->formatSettingForDescription('command'),
|
||||
$this->formatSettingForDescription('hostartifact'));
|
||||
}
|
||||
|
||||
public function escapeCommand($pattern, array $args) {
|
||||
array_unshift($args, $pattern);
|
||||
|
||||
$mode = PhutilCommandString::MODE_DEFAULT;
|
||||
if ($this->platform == 'windows') {
|
||||
$mode = PhutilCommandString::MODE_POWERSHELL;
|
||||
}
|
||||
|
||||
return id(new PhutilCommandString($args))
|
||||
->setEscapingMode($mode);
|
||||
}
|
||||
|
||||
public function execute(
|
||||
HarbormasterBuild $build,
|
||||
HarbormasterBuildTarget $build_target) {
|
||||
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||
|
||||
$settings = $this->getSettings();
|
||||
$variables = $build_target->getVariables();
|
||||
|
||||
$artifact = $build_target->loadArtifact($settings['hostartifact']);
|
||||
$impl = $artifact->getArtifactImplementation();
|
||||
$lease = $impl->loadArtifactLease($viewer);
|
||||
|
||||
$this->platform = $lease->getAttribute('platform');
|
||||
|
||||
$command = $this->mergeVariables(
|
||||
array($this, 'escapeCommand'),
|
||||
$settings['command'],
|
||||
$variables);
|
||||
|
||||
$this->platform = null;
|
||||
|
||||
$interface = $lease->getInterface('command');
|
||||
|
||||
$future = $interface->getExecFuture('%C', $command);
|
||||
|
||||
$log_stdout = $build->createLog($build_target, 'remote', 'stdout');
|
||||
$log_stderr = $build->createLog($build_target, 'remote', 'stderr');
|
||||
|
||||
$start_stdout = $log_stdout->start();
|
||||
$start_stderr = $log_stderr->start();
|
||||
|
||||
$build_update = 5;
|
||||
|
||||
// Read the next amount of available output every second.
|
||||
$futures = new FutureIterator(array($future));
|
||||
foreach ($futures->setUpdateInterval(1) as $key => $future_iter) {
|
||||
if ($future_iter === null) {
|
||||
|
||||
// Check to see if we should abort.
|
||||
if ($build_update <= 0) {
|
||||
$build->reload();
|
||||
if ($this->shouldAbort($build, $build_target)) {
|
||||
$future->resolveKill();
|
||||
throw new HarbormasterBuildAbortedException();
|
||||
} else {
|
||||
$build_update = 5;
|
||||
}
|
||||
} else {
|
||||
$build_update -= 1;
|
||||
}
|
||||
|
||||
// Command is still executing.
|
||||
|
||||
// Read more data as it is available.
|
||||
list($stdout, $stderr) = $future->read();
|
||||
$log_stdout->append($stdout);
|
||||
$log_stderr->append($stderr);
|
||||
$future->discardBuffers();
|
||||
} else {
|
||||
// Command execution is complete.
|
||||
|
||||
// Get the return value so we can log that as well.
|
||||
list($err) = $future->resolve();
|
||||
|
||||
// Retrieve the last few bits of information.
|
||||
list($stdout, $stderr) = $future->read();
|
||||
$log_stdout->append($stdout);
|
||||
$log_stderr->append($stderr);
|
||||
$future->discardBuffers();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$log_stdout->finalize($start_stdout);
|
||||
$log_stderr->finalize($start_stderr);
|
||||
|
||||
if ($err) {
|
||||
throw new HarbormasterBuildFailureException();
|
||||
}
|
||||
}
|
||||
|
||||
public function getArtifactInputs() {
|
||||
return array(
|
||||
array(
|
||||
'name' => pht('Run on Host'),
|
||||
'key' => $this->getSetting('hostartifact'),
|
||||
'type' => HarbormasterHostArtifact::ARTIFACTCONST,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function getFieldSpecifications() {
|
||||
return array(
|
||||
'command' => array(
|
||||
'name' => pht('Command'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'caption' => pht(
|
||||
"Under Windows, this is executed under PowerShell. ".
|
||||
"Under UNIX, this is executed using the user's shell."),
|
||||
),
|
||||
'hostartifact' => array(
|
||||
'name' => pht('Host'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class HarbormasterLeaseHostBuildStepImplementation
|
||||
extends HarbormasterBuildStepImplementation {
|
||||
|
||||
public function getName() {
|
||||
return pht('Lease Host');
|
||||
}
|
||||
|
||||
public function getGenericDescription() {
|
||||
return pht('Obtain a lease on a Drydock host for performing builds.');
|
||||
}
|
||||
|
||||
public function getBuildStepGroupKey() {
|
||||
return HarbormasterPrototypeBuildStepGroup::GROUPKEY;
|
||||
}
|
||||
|
||||
public function execute(
|
||||
HarbormasterBuild $build,
|
||||
HarbormasterBuildTarget $build_target) {
|
||||
|
||||
$settings = $this->getSettings();
|
||||
|
||||
// Create the lease.
|
||||
$lease = id(new DrydockLease())
|
||||
->setResourceType('host')
|
||||
->setOwnerPHID($build_target->getPHID())
|
||||
->setAttributes(
|
||||
array(
|
||||
'platform' => $settings['platform'],
|
||||
))
|
||||
->queueForActivation();
|
||||
|
||||
// Wait until the lease is fulfilled.
|
||||
// TODO: This will throw an exception if the lease can't be fulfilled;
|
||||
// we should treat that as build failure not build error.
|
||||
$lease->waitUntilActive();
|
||||
|
||||
// Create the associated artifact.
|
||||
$artifact = $build_target->createArtifact(
|
||||
PhabricatorUser::getOmnipotentUser(),
|
||||
$settings['name'],
|
||||
HarbormasterHostArtifact::ARTIFACTCONST,
|
||||
array(
|
||||
'drydockLeasePHID' => $lease->getPHID(),
|
||||
));
|
||||
}
|
||||
|
||||
public function getArtifactOutputs() {
|
||||
return array(
|
||||
array(
|
||||
'name' => pht('Leased Host'),
|
||||
'key' => $this->getSetting('name'),
|
||||
'type' => HarbormasterHostArtifact::ARTIFACTCONST,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function getFieldSpecifications() {
|
||||
return array(
|
||||
'name' => array(
|
||||
'name' => pht('Artifact Name'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
),
|
||||
'platform' => array(
|
||||
'name' => pht('Platform'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue