1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

docker_container: fix init option idempotency with old docker-py versions (#49078)

* Don't check options for idempotency which are not supported.

This check should be superfluous if every option would adhere to
the convention that options not specified should have value None.
Unfortunately, some options (such as init) which correspond to
container properties have an explicit default set.
This commit is contained in:
Felix Fontein 2018-11-26 14:53:01 +01:00 committed by John R Barker
parent 35049a148a
commit 9caaf7b109
2 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- "docker_container - fix idempotency problems with docker-py caused by previous ``init`` idempotency fix."
- "docker_container - fix interplay of docker-py version check with argument_spec validation improvements."

View file

@ -1854,6 +1854,9 @@ class Container(DockerBaseClass):
differences = DifferenceTracker()
for key, value in config_mapping.items():
minimal_version = self.parameters.client.option_minimal_versions.get(key, {})
if not minimal_version.get('supported', True):
continue
compare = self.parameters.client.comparisons[self.parameters_map.get(key, key)]
self.log('check differences %s %s vs %s (%s)' % (key, getattr(self.parameters, key), str(value), compare))
if getattr(self.parameters, key, None) is not None:
@ -2290,7 +2293,7 @@ class ContainerManager(DockerBaseClass):
if image_different:
self.diff['image_different'] = True
self.log("differences")
self.log(differences, pretty_print=True)
self.log(differences.get_legacy_docker_container_diffs(), pretty_print=True)
image_to_use = self.parameters.image
if not image_to_use and container and container.Image:
image_to_use = container.Image
@ -2740,7 +2743,7 @@ class AnsibleDockerClientContainer(AnsibleDockerClient):
# Helper function to detect whether any specified network uses ipv4_address or ipv6_address
def detect_ipvX_address_usage():
for network in self.module.params.get("networks") or []:
if 'ipv4_address' in network or 'ipv6_address' in network:
if network.get('ipv4_address') is not None or network.get('ipv6_address') is not None:
return True
return False