Skip to content

Commit

Permalink
Wait for the pod to be ready before exec-ing into it
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgianaElena committed Dec 18, 2024
1 parent f7cf459 commit be9dc92
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion deployer/commands/exec/infra_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,25 @@ def root_homes(
#
# Ask api-server to create a pod
subprocess.check_call(["kubectl", "create", "-f", tmpf.name])
# Exec into pod

# Wait for the pod to be ready but don't wait forever in case
# there was an error
tries, status = 0, None
while status != "Running" and tries < 30:
status = subprocess.check_output(
[
"kubectl",
"-n",
hub_name,
"get",
"pod",
pod_name,
"-o",
"jsonpath={.status.phase}",
]
).decode()
tries += 1
# Exec into pod now that is ready
subprocess.check_call(exec_cmd)
finally:
if not persist:
Expand Down

0 comments on commit be9dc92

Please sign in to comment.