summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorSteve Milner <smilner@redhat.com>2017-05-25 13:43:17 -0400
committerSteve Milner <smilner@redhat.com>2017-05-25 13:43:19 -0400
commitcbad3cf9bb5a3f82ac9b328a64083e82caa1f661 (patch)
tree7c36ad4179d3c4821a0111319a75c91b7db51977 /roles
parent4ece7ca92210a18879d6ceff2c54ae5563e1c7fc (diff)
downloadopenshift-cbad3cf9bb5a3f82ac9b328a64083e82caa1f661.tar.gz
openshift-cbad3cf9bb5a3f82ac9b328a64083e82caa1f661.tar.bz2
openshift-cbad3cf9bb5a3f82ac9b328a64083e82caa1f661.tar.xz
openshift-cbad3cf9bb5a3f82ac9b328a64083e82caa1f661.zip
oc_atomic_container: Workaround for invalid json from atomic command
When no other containers are present and one attempts to list containers via the atomic command with the --json flag an empty string is returned. If a json.loads is used on this value an error is raised. This change adds a workaround to fall back to '[]' when an empty string is returned from the atomic containers command.
Diffstat (limited to 'roles')
-rw-r--r--roles/lib_openshift/library/oc_atomic_container.py4
-rw-r--r--roles/lib_openshift/src/ansible/oc_atomic_container.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/roles/lib_openshift/library/oc_atomic_container.py b/roles/lib_openshift/library/oc_atomic_container.py
index e19e5169e..1e017a576 100644
--- a/roles/lib_openshift/library/oc_atomic_container.py
+++ b/roles/lib_openshift/library/oc_atomic_container.py
@@ -159,7 +159,9 @@ def core(module):
module.fail_json(rc=rc, msg=err)
return
- containers = json.loads(out)
+ # NOTE: "or '[]' is a workaround until atomic containers list --json
+ # provides an empty list when no containers are present.
+ containers = json.loads(out or '[]')
present = len(containers) > 0
old_image = containers[0]["image_name"] if present else None
diff --git a/roles/lib_openshift/src/ansible/oc_atomic_container.py b/roles/lib_openshift/src/ansible/oc_atomic_container.py
index e80349572..1a5ab6869 100644
--- a/roles/lib_openshift/src/ansible/oc_atomic_container.py
+++ b/roles/lib_openshift/src/ansible/oc_atomic_container.py
@@ -95,7 +95,9 @@ def core(module):
module.fail_json(rc=rc, msg=err)
return
- containers = json.loads(out)
+ # NOTE: "or '[]' is a workaround until atomic containers list --json
+ # provides an empty list when no containers are present.
+ containers = json.loads(out or '[]')
present = len(containers) > 0
old_image = containers[0]["image_name"] if present else None