From dc6aeee471ca3500a461ec546e12ae0876ea5ac0 Mon Sep 17 00:00:00 2001 From: evangelostsak Date: Wed, 9 Sep 2026 14:00:05 +0200 Subject: [PATCH] fix(sys-svc-compose): let docker stack deploy adopt pre-created overlays A network pre-created by the util carried only the compose labels, so `docker stack deploy` could not recognise it as belonging to the stack: `getStackNetworks` filters on `com.docker.stack.namespace`, finds nothing, and the deploy retries the create and aborts with "network with name already exists". This is reachable whenever a network is pre-created for a role whose stack has not deployed yet. web-app-prometheus does exactly that for every native-metrics app, which broke the swarm deploy of web-app-openbao. Stamping the namespace label makes the owning stack adopt the existing network instead of recreating it. Verified against docker 29.1.3 on a throwaway swarm: without the label the deploy fails as above, with it the stack adopts the same network id, and an external consumer stack deploying with --prune leaves the network intact. --- roles/sys-svc-compose/tasks/utils/network/create.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/roles/sys-svc-compose/tasks/utils/network/create.yml b/roles/sys-svc-compose/tasks/utils/network/create.yml index 75d80f9235..6085953094 100644 --- a/roles/sys-svc-compose/tasks/utils/network/create.yml +++ b/roles/sys-svc-compose/tasks/utils/network/create.yml @@ -39,6 +39,10 @@ - "com.docker.compose.network={{ lookup('shared_network_key', network_role_id) }}" - --label - "com.docker.compose.project={{ network_role_id | get_entity_name }}" + # Exception: without the stack namespace label `docker stack deploy` cannot see this + # network as one of its own, so it retries the create and dies on "already exists". + - --label + - "com.docker.stack.namespace={{ network_role_id | get_entity_name }}" - "{{ network_role_id | get_entity_name }}" when: - (SWARM_CLUSTER_AVAILABLE | bool) and not (lookup('config', network_role_id, 'networks.local.force_bridge', false) | bool)