Fix readiness-check exception 21/31721/1
authorBorislavG <Borislav.Glozman@amdocs.com>
Wed, 14 Feb 2018 13:23:51 +0000 (15:23 +0200)
committerBorislavG <Borislav.Glozman@amdocs.com>
Wed, 14 Feb 2018 13:26:13 +0000 (15:26 +0200)
The problem is that the script tried to
iterate on statuses of pod containers.
when some pod is in state "pending" or
some other case when there is no status,
the statuses is None.
Therefore python throws exception when trying to iterate None,
which is non-iterable.
Issue-ID: OOM-514
Signed-off-by: BorislavG <Borislav.Glozman@amdocs.com>
Change-Id: If57b8a632a83489fddb12373e4047396f5fa08a3

kubernetes/readiness/docker/init/ready.py

index c5b55ee..7cfb6cd 100644 (file)
@@ -36,6 +36,9 @@ def is_ready(container_name):
     try:
         response = v1.list_namespaced_pod(namespace=namespace, watch=False)
         for i in response.items:
+            # container_statuses can be None, which is non-iterable.
+            if i.status.container_statuses is None:
+               continue
             for s in i.status.container_statuses:
                 if s.name == container_name:
                     ready = s.ready