Skip to content

Commit fa08a48

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 d9ff833 commit fa08a48

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
@@ -301,6 +301,8 @@ def wait_for_init(pod_name, timeout=300, namespace: Optional[str] = None):
301301
):
302302
pod = event["object"]
303303
if pod.metadata.name == pod_name:
304+
if not pod.status.init_container_statuses:
305+
continue
304306
for init_container_status in pod.status.init_container_statuses:
305307
if init_container_status.state.running:
306308
print(f"initContainer in pod {pod_name} ({namespace}) is ready")

0 commit comments

Comments
 (0)