Skip to content

Commit e8ee5c7

Browse files
committed
Clean up.
1 parent 192a980 commit e8ee5c7

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

sky/utils/kubernetes/rsync_helper.sh

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,13 @@ else
5454
kubectl_cmd_base="kubectl exec \"$resource_type/$resource_name\" -n \"$namespace\" --context=\"$context\" --"
5555
fi
5656

57-
# Wait for rsync to be available. Rsync installation happens asynchronously
58-
# during pod startup, so we need to wait for it to be available.
57+
# Check if rsync is available, if not wait. Rsync installation happens
58+
# asynchronously during pod startup, so we need to wait for it to be available.
5959
wait_for_rsync() {
60-
# Check if rsync is available once
61-
# Build kubectl command array with proper context handling and timeout
62-
kubectl_cmd=(kubectl exec "$resource_type/$resource_name" -n "$namespace" --pod-running-timeout=5s)
63-
if [ -z "$context" ] || [ "$context_lower" = "none" ]; then
64-
kubectl_cmd+=(--kubeconfig=/dev/null)
65-
else
66-
kubectl_cmd+=(--context="$context")
67-
fi
68-
kubectl_cmd+=(--)
69-
70-
if timeout 5s "${kubectl_cmd[@]}" which rsync >/dev/null 2>&1 </dev/null; then
60+
# Check if rsync is available.
61+
if timeout 5s bash -c "eval \"$kubectl_cmd_base\" which rsync" >/dev/null 2>&1 </dev/null; then
7162
echo "Worked on first check" >&2
72-
exit 1
63+
return 0
7364
fi
7465

7566
# If not available, wait 60 seconds for installation to complete
@@ -79,11 +70,11 @@ wait_for_rsync() {
7970
# Check again after waiting
8071
if timeout 5s bash -c "eval \"$kubectl_cmd_base\" which rsync >/dev/null 2>&1 </dev/null"; then
8172
echo "Worked on second check" >&2
82-
exit 1
73+
return 0
8374
fi
8475

85-
echo "Error: rsync not available after waiting 60s, package installation may have failed." >&2
86-
exit 1
76+
echo "Error: rsync not available after waiting 60s, package installation is either slow or failed.." >&2
77+
return 1
8778
}
8879
wait_for_rsync
8980

0 commit comments

Comments
 (0)