@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove DrydockPreallocatedHostBlueprintImplementation

Summary:
Ref T9253. This comes from a time before Almanac. Now that we have Almanac, it makes much more sense to put this logic there than to try to put it in Drydock itself.

Remove the preallocated host blueprint, a relic of a bygone time.

Test Plan: Grepped for callsites.

Reviewers: hach-que, chad

Reviewed By: hach-que, chad

Maniphest Tasks: T9253

Differential Revision: https://secure.phabricator.com/D14110

-118
-2
src/__phutil_library_map__.php
··· 849 849 'DrydockManagementLeaseWorkflow' => 'applications/drydock/management/DrydockManagementLeaseWorkflow.php', 850 850 'DrydockManagementReleaseWorkflow' => 'applications/drydock/management/DrydockManagementReleaseWorkflow.php', 851 851 'DrydockManagementWorkflow' => 'applications/drydock/management/DrydockManagementWorkflow.php', 852 - 'DrydockPreallocatedHostBlueprintImplementation' => 'applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php', 853 852 'DrydockQuery' => 'applications/drydock/query/DrydockQuery.php', 854 853 'DrydockResource' => 'applications/drydock/storage/DrydockResource.php', 855 854 'DrydockResourceCloseController' => 'applications/drydock/controller/DrydockResourceCloseController.php', ··· 4567 4566 'DrydockManagementLeaseWorkflow' => 'DrydockManagementWorkflow', 4568 4567 'DrydockManagementReleaseWorkflow' => 'DrydockManagementWorkflow', 4569 4568 'DrydockManagementWorkflow' => 'PhabricatorManagementWorkflow', 4570 - 'DrydockPreallocatedHostBlueprintImplementation' => 'DrydockBlueprintImplementation', 4571 4569 'DrydockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 4572 4570 'DrydockResource' => array( 4573 4571 'DrydockDAO',
-116
src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
··· 1 - <?php 2 - 3 - final class DrydockPreallocatedHostBlueprintImplementation 4 - extends DrydockBlueprintImplementation { 5 - 6 - public function isEnabled() { 7 - return true; 8 - } 9 - 10 - public function getBlueprintName() { 11 - return pht('Preallocated Remote Hosts'); 12 - } 13 - 14 - public function getDescription() { 15 - return pht('Allows Drydock to run on specific remote hosts you configure.'); 16 - } 17 - 18 - public function canAllocateMoreResources(array $pool) { 19 - return false; 20 - } 21 - 22 - protected function executeAllocateResource(DrydockLease $lease) { 23 - throw new Exception( 24 - pht("Preallocated hosts can't be dynamically allocated.")); 25 - } 26 - 27 - protected function canAllocateLease( 28 - DrydockResource $resource, 29 - DrydockLease $lease) { 30 - return 31 - $lease->getAttribute('platform') === $resource->getAttribute('platform'); 32 - } 33 - 34 - protected function shouldAllocateLease( 35 - DrydockResource $resource, 36 - DrydockLease $lease, 37 - array $other_leases) { 38 - return true; 39 - } 40 - 41 - protected function executeAcquireLease( 42 - DrydockResource $resource, 43 - DrydockLease $lease) { 44 - 45 - // Because preallocated resources are manually created, we should verify 46 - // we have all the information we need. 47 - PhutilTypeSpec::checkMap( 48 - $resource->getAttributesForTypeSpec( 49 - array('platform', 'host', 'port', 'credential', 'path')), 50 - array( 51 - 'platform' => 'string', 52 - 'host' => 'string', 53 - 'port' => 'string', // Value is a string from the command line 54 - 'credential' => 'string', 55 - 'path' => 'string', 56 - )); 57 - $v_platform = $resource->getAttribute('platform'); 58 - $v_path = $resource->getAttribute('path'); 59 - 60 - // Similar to DrydockLocalHostBlueprint, we create a folder 61 - // on the remote host that the lease can use. 62 - 63 - $lease_id = $lease->getID(); 64 - 65 - // Can't use DIRECTORY_SEPERATOR here because that is relevant to 66 - // the platform we're currently running on, not the platform we are 67 - // remoting to. 68 - $separator = '/'; 69 - if ($v_platform === 'windows') { 70 - $separator = '\\'; 71 - } 72 - 73 - // Clean up the directory path a little. 74 - $base_path = rtrim($v_path, '/'); 75 - $base_path = rtrim($base_path, '\\'); 76 - $full_path = $base_path.$separator.$lease_id; 77 - 78 - $cmd = $lease->getInterface('command'); 79 - 80 - $cmd->execx('mkdir %s', $full_path); 81 - 82 - $lease->setAttribute('path', $full_path); 83 - } 84 - 85 - public function getType() { 86 - return 'host'; 87 - } 88 - 89 - public function getInterface( 90 - DrydockResource $resource, 91 - DrydockLease $lease, 92 - $type) { 93 - 94 - switch ($type) { 95 - case 'command': 96 - return id(new DrydockSSHCommandInterface()) 97 - ->setConfiguration(array( 98 - 'host' => $resource->getAttribute('host'), 99 - 'port' => $resource->getAttribute('port'), 100 - 'credential' => $resource->getAttribute('credential'), 101 - 'platform' => $resource->getAttribute('platform'), 102 - )) 103 - ->setWorkingDirectory($lease->getAttribute('path')); 104 - case 'filesystem': 105 - return id(new DrydockSFTPFilesystemInterface()) 106 - ->setConfiguration(array( 107 - 'host' => $resource->getAttribute('host'), 108 - 'port' => $resource->getAttribute('port'), 109 - 'credential' => $resource->getAttribute('credential'), 110 - )); 111 - } 112 - 113 - throw new Exception(pht("No interface of type '%s'.", $type)); 114 - } 115 - 116 - }