From 613fe54908eb406ca942e15aa340259fdd6f0837 Mon Sep 17 00:00:00 2001 From: Micheal Waltz Date: Thu, 23 Jul 2015 12:17:26 -0700 Subject: [PATCH] Use a if/else instead to avoid loading possibly invalid values for Memory --- cloud/docker/docker.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cloud/docker/docker.py b/cloud/docker/docker.py index 8055fbf23c9..df7eb141aec 100644 --- a/cloud/docker/docker.py +++ b/cloud/docker/docker.py @@ -1011,10 +1011,10 @@ class DockerManager(object): except ValueError as e: self.module.fail_json(msg=str(e)) - actual_mem = container['HostConfig']['Memory'] - - #Use v1.18 API and earlier Memory element location - if docker_api_version <= 1.18: + #For v1.19 API and above use HostConfig, otherwise use Config + if docker_api_version >= 1.19: + actual_mem = container['HostConfig']['Memory'] + else: actual_mem = container['Config']['Memory'] if expected_mem and actual_mem != expected_mem: