Browse Source

Catch devops error if inspecting containers goes wrong

In case something is wrong with inspecting containers catch DevopsError
instead of failing whole deployment

Change-Id: Ib4888c30c6b1dcae8d6094f769246fac6b41e164
Volodymyr Shypyguzov 2 years ago
parent
commit
27e62c6f13
1 changed files with 17 additions and 12 deletions
  1. 17
    12
      fuel_ccp_tests/helpers/post_install_k8s_checks.py

+ 17
- 12
fuel_ccp_tests/helpers/post_install_k8s_checks.py View File

@@ -16,6 +16,7 @@ import re
16 16
 import json
17 17
 
18 18
 from devops.helpers import helpers
19
+from devops.error import DevopsError
19 20
 
20 21
 from fuel_ccp_tests import logger
21 22
 
@@ -75,15 +76,19 @@ def inspect_docker_containers(image_name, underlay, host_ip):
75 76
     if result:
76 77
         LOG.info("Inspecting running containers with name={name}: on: {node}".
77 78
                  format(name=image_name, node=host_ip))
78
-        for container in result.stdout_json:
79
-            raw_out = container['Config']['Labels']
80
-            labels = json.dumps(
81
-                raw_out,
82
-                indent=4,
83
-                separators=(',', ': '),
84
-                sort_keys=True
85
-            )
86
-            LOG.info("Docker container {name} Labels: {labels}".format(
87
-                name=container['Name'],
88
-                labels=labels)
89
-            )
79
+        try:
80
+            for container in result.stdout_json:
81
+                raw_out = container['Config']['Labels']
82
+                labels = json.dumps(
83
+                    raw_out,
84
+                    indent=4,
85
+                    separators=(',', ': '),
86
+                    sort_keys=True
87
+                )
88
+                LOG.info("Docker container {name} Labels: {labels}".format(
89
+                    name=container['Name'],
90
+                    labels=labels)
91
+                )
92
+        except DevopsError:
93
+            LOG.info("{} stdout is not a valid json. Stdout:{}".format(
94
+                cmd, result.stdout))

Loading…
Cancel
Save