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.

(cherry picked from commit 9caaf7b109)
pull/49167/head
Felix Fontein 6 years ago committed by Toshio Kuratomi
parent 316d3abb42
commit 29e2454f7c

@ -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."

@ -1438,6 +1438,9 @@ class Container(DockerBaseClass):
differences = [] differences = []
for key, value in config_mapping.items(): 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)] 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)) 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: if getattr(self.parameters, key, None) is not None:
@ -2223,7 +2226,7 @@ class AnsibleDockerClientContainer(AnsibleDockerClient):
# Helper function to detect whether any specified network uses ipv4_address or ipv6_address # Helper function to detect whether any specified network uses ipv4_address or ipv6_address
def detect_ipvX_address_usage(): def detect_ipvX_address_usage():
for network in self.module.params.get("networks") or []: 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 True
return False return False

Loading…
Cancel
Save