Skip to content

Commit 958b91a

Browse files
authored
[K8s] Fix rsync Not Found (#7844)
* Suppress future warning for launch output. * fix syntax. * Remove future warning using grep. * Sleep if not present. * Clean up. * Wait for rsync on remote.
1 parent db63f7d commit 958b91a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

sky/utils/kubernetes/rsync_helper.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ fi
4848

4949
if [ -z "$context" ] || [ "$context_lower" = "none" ]; then
5050
# If context is none, it means we are using incluster auth. In this case,
51-
# use need to set KUBECONFIG to /dev/null to avoid using kubeconfig file.
52-
kubectl exec -i "$resource_type/$resource_name" -n "$namespace" --kubeconfig=/dev/null -- "$@"
51+
# we need to set KUBECONFIG to /dev/null to avoid using kubeconfig file.
52+
kubectl_cmd_base="kubectl exec \"$resource_type/$resource_name\" -n \"$namespace\" --kubeconfig=/dev/null --"
5353
else
54-
kubectl exec -i "$resource_type/$resource_name" -n "$namespace" --context="$context" -- "$@"
54+
kubectl_cmd_base="kubectl exec \"$resource_type/$resource_name\" -n \"$namespace\" --context=\"$context\" --"
5555
fi
56+
57+
# Execute command on remote pod, waiting for rsync to be available first.
58+
# The waiting happens on the remote pod, not locally, which is more efficient
59+
# and reliable than polling from the local machine.
60+
# We wrap the command in a bash script that waits for rsync, then execs the original command.
61+
eval "${kubectl_cmd_base% --} -i -- bash -c 'until which rsync >/dev/null 2>&1; do sleep 0.5; done; exec \"\$@\"' -- \"\$@\""

0 commit comments

Comments
 (0)