Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15442385
D14160.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
16 KB
Referenced Files
None
Subscribers
None
D14160.id.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1002,11 +1002,13 @@
'HarbormasterController' => 'applications/harbormaster/controller/HarbormasterController.php',
'HarbormasterCreateArtifactConduitAPIMethod' => 'applications/harbormaster/conduit/HarbormasterCreateArtifactConduitAPIMethod.php',
'HarbormasterDAO' => 'applications/harbormaster/storage/HarbormasterDAO.php',
+ 'HarbormasterDrydockLeaseArtifact' => 'applications/harbormaster/artifact/HarbormasterDrydockLeaseArtifact.php',
'HarbormasterExternalBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterExternalBuildStepGroup.php',
'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',
'HarbormasterManagePlansCapability' => 'applications/harbormaster/capability/HarbormasterManagePlansCapability.php',
@@ -1047,6 +1049,7 @@
'HarbormasterUploadArtifactBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterUploadArtifactBuildStepImplementation.php',
'HarbormasterWaitForPreviousBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterWaitForPreviousBuildStepImplementation.php',
'HarbormasterWorker' => 'applications/harbormaster/worker/HarbormasterWorker.php',
+ 'HarbormasterWorkingCopyArtifact' => 'applications/harbormaster/artifact/HarbormasterWorkingCopyArtifact.php',
'HeraldAction' => 'applications/herald/action/HeraldAction.php',
'HeraldActionGroup' => 'applications/herald/action/HeraldActionGroup.php',
'HeraldActionRecord' => 'applications/herald/storage/HeraldActionRecord.php',
@@ -4786,11 +4789,13 @@
'HarbormasterController' => 'PhabricatorController',
'HarbormasterCreateArtifactConduitAPIMethod' => 'HarbormasterConduitAPIMethod',
'HarbormasterDAO' => 'PhabricatorLiskDAO',
+ 'HarbormasterDrydockLeaseArtifact' => 'HarbormasterArtifact',
'HarbormasterExternalBuildStepGroup' => 'HarbormasterBuildStepGroup',
'HarbormasterFileArtifact' => 'HarbormasterArtifact',
'HarbormasterHTTPRequestBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
- 'HarbormasterHostArtifact' => 'HarbormasterArtifact',
+ 'HarbormasterHostArtifact' => 'HarbormasterDrydockLeaseArtifact',
'HarbormasterLeaseHostBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
+ 'HarbormasterLeaseWorkingCopyBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
'HarbormasterLintMessagesController' => 'HarbormasterController',
'HarbormasterLintPropertyView' => 'AphrontView',
'HarbormasterManagePlansCapability' => 'PhabricatorPolicyCapability',
@@ -4831,6 +4836,7 @@
'HarbormasterUploadArtifactBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
'HarbormasterWaitForPreviousBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
'HarbormasterWorker' => 'PhabricatorWorker',
+ 'HarbormasterWorkingCopyArtifact' => 'HarbormasterDrydockLeaseArtifact',
'HeraldAction' => 'Phobject',
'HeraldActionGroup' => 'HeraldGroup',
'HeraldActionRecord' => 'HeraldDAO',
diff --git a/src/applications/differential/storage/DifferentialDiff.php b/src/applications/differential/storage/DifferentialDiff.php
--- a/src/applications/differential/storage/DifferentialDiff.php
+++ b/src/applications/differential/storage/DifferentialDiff.php
@@ -443,6 +443,7 @@
if ($repo) {
$results['repository.callsign'] = $repo->getCallsign();
+ $results['repository.phid'] = $repo->getPHID();
$results['repository.vcs'] = $repo->getVersionControlSystem();
$results['repository.uri'] = $repo->getPublicCloneURI();
}
@@ -459,6 +460,8 @@
pht('The differential revision ID, if applicable.'),
'repository.callsign' =>
pht('The callsign of the repository in Phabricator.'),
+ 'repository.phid' =>
+ pht('The PHID of the repository in Phabricator.'),
'repository.vcs' =>
pht('The version control system, either "svn", "hg" or "git".'),
'repository.uri' =>
diff --git a/src/applications/drydock/storage/DrydockLease.php b/src/applications/drydock/storage/DrydockLease.php
--- a/src/applications/drydock/storage/DrydockLease.php
+++ b/src/applications/drydock/storage/DrydockLease.php
@@ -126,22 +126,23 @@
return $this;
}
- public function isActive() {
- switch ($this->status) {
+ public function isActivating() {
+ switch ($this->getStatus()) {
+ case DrydockLeaseStatus::STATUS_PENDING:
case DrydockLeaseStatus::STATUS_ACQUIRED:
- case DrydockLeaseStatus::STATUS_ACTIVE:
return true;
}
+
return false;
}
- private function assertActive() {
- if (!$this->isActive()) {
- throw new Exception(
- pht(
- 'Lease is not active! You can not interact with resources through '.
- 'an inactive lease.'));
+ public function isActive() {
+ switch ($this->getStatus()) {
+ case DrydockLeaseStatus::STATUS_ACTIVE:
+ return true;
}
+
+ return false;
}
public function waitUntilActive() {
diff --git a/src/applications/drydock/view/DrydockLeaseListView.php b/src/applications/drydock/view/DrydockLeaseListView.php
--- a/src/applications/drydock/view/DrydockLeaseListView.php
+++ b/src/applications/drydock/view/DrydockLeaseListView.php
@@ -41,7 +41,10 @@
$item->addAttribute($status);
$item->setEpoch($lease->getDateCreated());
- if ($lease->isActive()) {
+ // TODO: Tailor this for clarity.
+ if ($lease->isActivating()) {
+ $item->setStatusIcon('fa-dot-circle-o yellow');
+ } else if ($lease->isActive()) {
$item->setStatusIcon('fa-dot-circle-o green');
} else {
$item->setStatusIcon('fa-dot-circle-o red');
diff --git a/src/applications/harbormaster/artifact/HarbormasterHostArtifact.php b/src/applications/harbormaster/artifact/HarbormasterDrydockLeaseArtifact.php
copy from src/applications/harbormaster/artifact/HarbormasterHostArtifact.php
copy to src/applications/harbormaster/artifact/HarbormasterDrydockLeaseArtifact.php
--- a/src/applications/harbormaster/artifact/HarbormasterHostArtifact.php
+++ b/src/applications/harbormaster/artifact/HarbormasterDrydockLeaseArtifact.php
@@ -1,17 +1,7 @@
<?php
-final class HarbormasterHostArtifact extends HarbormasterArtifact {
-
- const ARTIFACTCONST = 'host';
-
- public function getArtifactTypeName() {
- return pht('Drydock Host');
- }
-
- public function getArtifactTypeDescription() {
- return pht('References a host lease from Drydock.');
- }
-
+abstract class HarbormasterDrydockLeaseArtifact
+ extends HarbormasterArtifact {
public function getArtifactParameterSpecification() {
return array(
@@ -22,7 +12,7 @@
public function getArtifactParameterDescriptions() {
return array(
'drydockLeasePHID' => pht(
- 'Drydock host lease to create an artifact from.'),
+ 'Drydock working copy lease to create an artifact from.'),
);
}
@@ -34,8 +24,8 @@
public function renderArtifactSummary(PhabricatorUser $viewer) {
$artifact = $this->getBuildArtifact();
- $file_phid = $artifact->getProperty('drydockLeasePHID');
- return $viewer->renderHandle($file_phid);
+ $lease_phid = $artifact->getProperty('drydockLeasePHID');
+ return $viewer->renderHandle($lease_phid);
}
public function willCreateArtifact(PhabricatorUser $actor) {
@@ -66,8 +56,14 @@
return;
}
+ $author_phid = $actor->getPHID();
+ if (!$author_phid) {
+ $author_phid = id(new PhabricatorHarbormasterApplication())->getPHID();
+ }
+
$command = DrydockCommand::initializeNewCommand($actor)
->setTargetPHID($lease->getPHID())
+ ->setAuthorPHID($author_phid)
->setCommand(DrydockCommand::COMMAND_RELEASE)
->save();
diff --git a/src/applications/harbormaster/artifact/HarbormasterHostArtifact.php b/src/applications/harbormaster/artifact/HarbormasterHostArtifact.php
--- a/src/applications/harbormaster/artifact/HarbormasterHostArtifact.php
+++ b/src/applications/harbormaster/artifact/HarbormasterHostArtifact.php
@@ -1,6 +1,7 @@
<?php
-final class HarbormasterHostArtifact extends HarbormasterArtifact {
+final class HarbormasterHostArtifact
+ extends HarbormasterDrydockLeaseArtifact {
const ARTIFACTCONST = 'host';
@@ -12,66 +13,4 @@
return pht('References a host lease from Drydock.');
}
-
- public function getArtifactParameterSpecification() {
- return array(
- 'drydockLeasePHID' => 'string',
- );
- }
-
- public function getArtifactParameterDescriptions() {
- return array(
- 'drydockLeasePHID' => pht(
- 'Drydock host lease to create an artifact from.'),
- );
- }
-
- public function getArtifactDataExample() {
- return array(
- 'drydockLeasePHID' => 'PHID-DRYL-abcdefghijklmnopqrst',
- );
- }
-
- public function renderArtifactSummary(PhabricatorUser $viewer) {
- $artifact = $this->getBuildArtifact();
- $file_phid = $artifact->getProperty('drydockLeasePHID');
- return $viewer->renderHandle($file_phid);
- }
-
- public function willCreateArtifact(PhabricatorUser $actor) {
- $this->loadArtifactLease($actor);
- }
-
- public function loadArtifactLease(PhabricatorUser $viewer) {
- $artifact = $this->getBuildArtifact();
- $lease_phid = $artifact->getProperty('drydockLeasePHID');
-
- $lease = id(new DrydockLeaseQuery())
- ->setViewer($viewer)
- ->withPHIDs(array($lease_phid))
- ->executeOne();
- if (!$lease) {
- throw new Exception(
- pht(
- 'Drydock lease PHID "%s" does not correspond to a valid lease.',
- $lease_phid));
- }
-
- return $lease;
- }
-
- public function releaseArtifact(PhabricatorUser $actor) {
- $lease = $this->loadArtifactLease($actor);
- if (!$lease->canRelease()) {
- return;
- }
-
- $command = DrydockCommand::initializeNewCommand($actor)
- ->setTargetPHID($lease->getPHID())
- ->setCommand(DrydockCommand::COMMAND_RELEASE)
- ->save();
-
- $lease->scheduleUpdate();
- }
-
}
diff --git a/src/applications/harbormaster/artifact/HarbormasterWorkingCopyArtifact.php b/src/applications/harbormaster/artifact/HarbormasterWorkingCopyArtifact.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/artifact/HarbormasterWorkingCopyArtifact.php
@@ -0,0 +1,16 @@
+<?php
+
+final class HarbormasterWorkingCopyArtifact
+ extends HarbormasterDrydockLeaseArtifact {
+
+ const ARTIFACTCONST = 'working-copy';
+
+ public function getArtifactTypeName() {
+ return pht('Drydock Working Copy');
+ }
+
+ public function getArtifactTypeDescription() {
+ return pht('References a working copy lease from Drydock.');
+ }
+
+}
diff --git a/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php
@@ -0,0 +1,106 @@
+<?php
+
+final class HarbormasterLeaseWorkingCopyBuildStepImplementation
+ extends HarbormasterBuildStepImplementation {
+
+ public function getName() {
+ return pht('Lease Working Copy');
+ }
+
+ public function getGenericDescription() {
+ return pht('Build a working copy in Drydock.');
+ }
+
+ public function getBuildStepGroupKey() {
+ return HarbormasterPrototypeBuildStepGroup::GROUPKEY;
+ }
+
+ public function execute(
+ HarbormasterBuild $build,
+ HarbormasterBuildTarget $build_target) {
+ $viewer = PhabricatorUser::getOmnipotentUser();
+
+ $settings = $this->getSettings();
+
+ // TODO: We should probably have a separate temporary storage area for
+ // execution stuff that doesn't step on configuration state?
+ $lease_phid = $build_target->getDetail('exec.leasePHID');
+
+ if ($lease_phid) {
+ $lease = id(new DrydockLeaseQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($lease_phid))
+ ->executeOne();
+ if (!$lease) {
+ throw new PhabricatorWorkerPermanentFailureException(
+ pht(
+ 'Lease "%s" could not be loaded.',
+ $lease_phid));
+ }
+ } else {
+ $working_copy_type = id(new DrydockWorkingCopyBlueprintImplementation())
+ ->getType();
+
+ $lease = id(new DrydockLease())
+ ->setResourceType($working_copy_type)
+ ->setOwnerPHID($build_target->getPHID());
+
+ $variables = $build_target->getVariables();
+
+ $repository_phid = idx($variables, 'repository.phid');
+ $commit = idx($variables, 'repository.commit');
+
+ $lease
+ ->setAttribute('repositoryPHID', $repository_phid)
+ ->setAttribute('commit', $commit);
+
+ $lease->queueForActivation();
+
+ $build_target
+ ->setDetail('exec.leasePHID', $lease->getPHID())
+ ->save();
+ }
+
+ if ($lease->isActivating()) {
+ // TODO: Smart backoff?
+ throw new PhabricatorWorkerYieldException(15);
+ }
+
+ if (!$lease->isActive()) {
+ // TODO: We could just forget about this lease and retry?
+ throw new PhabricatorWorkerPermanentFailureException(
+ pht(
+ 'Lease "%s" never activated.',
+ $lease->getPHID()));
+ }
+
+ $artifact = $build_target->createArtifact(
+ $viewer,
+ $settings['name'],
+ HarbormasterWorkingCopyArtifact::ARTIFACTCONST,
+ array(
+ 'drydockLeasePHID' => $lease->getPHID(),
+ ));
+ }
+
+ public function getArtifactOutputs() {
+ return array(
+ array(
+ 'name' => pht('Working Copy'),
+ 'key' => $this->getSetting('name'),
+ 'type' => HarbormasterHostArtifact::ARTIFACTCONST,
+ ),
+ );
+ }
+
+ public function getFieldSpecifications() {
+ return array(
+ 'name' => array(
+ 'name' => pht('Artifact Name'),
+ 'type' => 'text',
+ 'required' => true,
+ ),
+ );
+ }
+
+}
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuild.php b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuild.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
@@ -251,6 +251,7 @@
'buildable.revision' => null,
'buildable.commit' => null,
'repository.callsign' => null,
+ 'repository.phid' => null,
'repository.vcs' => null,
'repository.uri' => null,
'step.timestamp' => null,
diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommit.php b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
--- a/src/applications/repository/storage/PhabricatorRepositoryCommit.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
@@ -332,6 +332,7 @@
$repo = $this->getRepository();
$results['repository.callsign'] = $repo->getCallsign();
+ $results['repository.phid'] = $repo->getPHID();
$results['repository.vcs'] = $repo->getVersionControlSystem();
$results['repository.uri'] = $repo->getPublicCloneURI();
@@ -343,6 +344,8 @@
'buildable.commit' => pht('The commit identifier, if applicable.'),
'repository.callsign' =>
pht('The callsign of the repository in Phabricator.'),
+ 'repository.phid' =>
+ pht('The PHID of the repository in Phabricator.'),
'repository.vcs' =>
pht('The version control system, either "svn", "hg" or "git".'),
'repository.uri' =>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 27, 11:05 PM (1 w, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7417840
Default Alt Text
D14160.id.diff (16 KB)
Attached To
Mode
D14160: Allow Harbormaster to lease working copies from Drydock
Attached
Detach File
Event Timeline
Log In to Comment