@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 localhost Drydock allocator

Summary: This has never been enabled by default, and isn't safe. Remove it since people can use preallocated or EC2 hosts.

Test Plan: Removed it; didn't see it appear on the "Create Blueprint" page.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

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

-99
-2
src/__phutil_library_map__.php
··· 605 605 'DrydockLeaseStatus' => 'applications/drydock/constants/DrydockLeaseStatus.php', 606 606 'DrydockLeaseViewController' => 'applications/drydock/controller/DrydockLeaseViewController.php', 607 607 'DrydockLocalCommandInterface' => 'applications/drydock/interface/command/DrydockLocalCommandInterface.php', 608 - 'DrydockLocalHostBlueprintImplementation' => 'applications/drydock/blueprint/DrydockLocalHostBlueprintImplementation.php', 609 608 'DrydockLog' => 'applications/drydock/storage/DrydockLog.php', 610 609 'DrydockLogController' => 'applications/drydock/controller/DrydockLogController.php', 611 610 'DrydockLogListController' => 'applications/drydock/controller/DrydockLogListController.php', ··· 3357 3356 'DrydockLeaseStatus' => 'DrydockConstants', 3358 3357 'DrydockLeaseViewController' => 'DrydockLeaseController', 3359 3358 'DrydockLocalCommandInterface' => 'DrydockCommandInterface', 3360 - 'DrydockLocalHostBlueprintImplementation' => 'DrydockBlueprintImplementation', 3361 3359 'DrydockLog' => array( 3362 3360 'DrydockDAO', 3363 3361 'PhabricatorPolicyInterface',
-97
src/applications/drydock/blueprint/DrydockLocalHostBlueprintImplementation.php
··· 1 - <?php 2 - 3 - final class DrydockLocalHostBlueprintImplementation 4 - extends DrydockBlueprintImplementation { 5 - 6 - public function isEnabled() { 7 - return false; 8 - } 9 - 10 - public function getBlueprintName() { 11 - return pht('Local Host'); 12 - } 13 - 14 - public function getDescription() { 15 - return pht( 16 - 'Allows Drydock to run on the local host.'); 17 - } 18 - 19 - public function canAllocateMoreResources(array $pool) { 20 - assert_instances_of($pool, 'DrydockResource'); 21 - 22 - // The localhost can be allocated only once. 23 - foreach ($pool as $resource) { 24 - if ($resource->getBlueprintClass() == $this->getBlueprintClass()) { 25 - return false; 26 - } 27 - } 28 - 29 - return true; 30 - } 31 - 32 - protected function executeAllocateResource(DrydockLease $lease) { 33 - // TODO: Don't hard-code this. 34 - $path = '/var/drydock/'; 35 - 36 - if (!Filesystem::pathExists($path)) { 37 - throw new Exception( 38 - "Path '{$path}' does not exist!"); 39 - } 40 - Filesystem::assertIsDirectory($path); 41 - Filesystem::assertWritable($path); 42 - 43 - $resource = $this->newResourceTemplate('Host (localhost)'); 44 - $resource->setStatus(DrydockResourceStatus::STATUS_OPEN); 45 - $resource->setAttribute('path', $path); 46 - $resource->setAttribute('remote', 'false'); 47 - $resource->setAttribute('preallocated', 'false'); 48 - $resource->save(); 49 - 50 - return $resource; 51 - } 52 - 53 - protected function canAllocateLease( 54 - DrydockResource $resource, 55 - DrydockLease $lease) { 56 - return false; 57 - } 58 - 59 - protected function shouldAllocateLease( 60 - DrydockResource $resource, 61 - DrydockLease $lease, 62 - array $other_leases) { 63 - return true; 64 - } 65 - 66 - protected function executeAcquireLease( 67 - DrydockResource $resource, 68 - DrydockLease $lease) { 69 - 70 - $lease_id = $lease->getID(); 71 - 72 - $full_path = $resource->getAttribute('path').$lease_id.'/'; 73 - 74 - $cmd = $lease->getInterface('command'); 75 - $cmd->execx('mkdir %s', $full_path); 76 - 77 - $lease->setAttribute('path', $full_path); 78 - } 79 - 80 - public function getType() { 81 - return 'host'; 82 - } 83 - 84 - public function getInterface( 85 - DrydockResource $resource, 86 - DrydockLease $lease, 87 - $type) { 88 - 89 - switch ($type) { 90 - case 'command': 91 - return new DrydockLocalCommandInterface(); 92 - } 93 - 94 - throw new Exception("No interface of type '{$type}'."); 95 - } 96 - 97 - }