Skip to content

Commit

Permalink
k8s: add continue to wait_for_init
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
mplsgrant committed Oct 2, 2024
1 parent d9ff833 commit fa08a48
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/warnet/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ def wait_for_init(pod_name, timeout=300, namespace: Optional[str] = None):
):
pod = event["object"]
if pod.metadata.name == pod_name:
if not pod.status.init_container_statuses:
continue
for init_container_status in pod.status.init_container_statuses:
if init_container_status.state.running:
print(f"initContainer in pod {pod_name} ({namespace}) is ready")
Expand Down

0 comments on commit fa08a48

Please sign in to comment.