Skip to content

Commit 0dbeac8

Browse files
committed
k8s: add continue to wait_for_init
When this function encounters a matching pod, it attempts to retrieve that pod's init_container_statuses. The problem seems to be that this metadata is not available (perhaps because the pod is not read?). This means that the metadata is set to None which is not iterable and therefore causes a crash. This fix allows the program to proceed to the next element in the for loop stream if the init_container_statuses metadata is not ready (aka is None).
1 parent cff7685 commit 0dbeac8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/warnet/k8s.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ def wait_for_init(pod_name, timeout=300, namespace: Optional[str] = None):
294294
):
295295
pod = event["object"]
296296
if pod.metadata.name == pod_name:
297+
if not pod.status.init_container_statuses:
298+
continue
297299
for init_container_status in pod.status.init_container_statuses:
298300
if init_container_status.state.running:
299301
print(f"initContainer in pod {pod_name} ({namespace}) is ready")

0 commit comments

Comments
 (0)