docker_compose - Fix idempotency when services have no enabled profiles (#192)

* Initial Commit

* Adding integration tests

* Fixing integration and adding changelog fragment
This commit is contained in:
Ajpantuso
2021-08-20 07:33:35 -04:00
committed by GitHub
parent 50d3b9c280
commit 4dfc3ae5d7
3 changed files with 28 additions and 12 deletions
+10
View File
@@ -790,6 +790,8 @@ class ContainerManager(DockerBaseClass):
# In case the only action is starting, and the user requested
# that the service should be stopped, ignore this service.
continue
if not self._service_profile_enabled(service):
continue
if plan.action != 'noop':
result['changed'] = True
result_action = dict(service=service.name)
@@ -1010,6 +1012,14 @@ class ContainerManager(DockerBaseClass):
))
return result
def _service_profile_enabled(self, service):
"""Returns `True` if the service has no profiles defined or has a profile which is among
the profiles passed to the `docker compose up` command. Otherwise returns `False`.
"""
if LooseVersion(compose_version) < LooseVersion('1.28.0'):
return True
return service.enabled_for_profiles(self.profiles or [])
def cmd_down(self):
result = dict(
changed=False,