Merge pull request #2827 from Megumiso/fix-placement-constraints

fix placement constraints were ignored
This commit is contained in:
Andras Bacsai 2024-07-15 11:18:27 +02:00 committed by GitHub
commit a815240f4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1624,12 +1624,15 @@ private function generate_compose_file()
],
],
];
if (data_get($this->application, 'swarm_placement_constraints')) {
$swarm_placement_constraints = Yaml::parse(base64_decode(data_get($this->application, 'swarm_placement_constraints')));
$docker_compose['services'][$this->container_name]['deploy'] = array_merge(
$docker_compose['services'][$this->container_name]['deploy'],
$swarm_placement_constraints
);
}
if (data_get($this->application, 'settings.is_swarm_only_worker_nodes')) {
$docker_compose['services'][$this->container_name]['deploy']['placement'] = [
'constraints' => [
'node.role == worker',
],
];
$docker_compose['services'][$this->container_name]['deploy']['placement']['constraints'][] = 'node.role == worker';
}
if ($this->pull_request_id !== 0) {
$docker_compose['services'][$this->container_name]['deploy']['replicas'] = 1;