Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15333093
D15835.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D15835.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D15835: When creating a repository with EditEngine, allocate it onto a random cluster service
Attached
Detach File
Event Timeline
Log In to Comment