Page MenuHomePhabricator

D15835.diff
No OneTemporary

D15835.diff

diff --git a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
--- a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
+++ b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
@@ -45,6 +45,44 @@
$repository->setVersionControlSystem($vcs);
}
+ // Pick a random open service to allocate this repository on, if any exist.
+ // If there are no services, we aren't in cluster mode and will allocate
+ // locally. If there are services but none permit allocations, we fail.
+
+ // Eventually we can make this more flexible, but this rule is a reasonable
+ // starting point as we begin to deploy cluster services.
+
+ $services = id(new AlmanacServiceQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withServiceTypes(
+ array(
+ AlmanacClusterRepositoryServiceType::SERVICETYPE,
+ ))
+ ->needProperties(true)
+ ->execute();
+ if ($services) {
+ // Filter out services which do not permit new allocations.
+ foreach ($services as $key => $possible_service) {
+ if ($possible_service->getAlmanacPropertyValue('closed')) {
+ unset($services[$key]);
+ }
+ }
+
+ if (!$services) {
+ throw new Exception(
+ pht(
+ 'This install is configured in cluster mode, but all available '.
+ 'repository cluster services are closed to new allocations. '.
+ 'At least one service must be open to allow new allocations to '.
+ 'take place.'));
+ }
+
+ shuffle($services);
+ $service = head($services);
+
+ $repository->setAlmanacServicePHID($service->getPHID());
+ }
+
return $repository;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 8, 11:50 PM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7385062
Default Alt Text
D15835.diff (1 KB)

Event Timeline