Skip to content

chore: fix rsync helper #5196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions sky/utils/kubernetes/rsync_helper.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
# When using pod@namespace+context, rsync passes args as: {us} -l pod namespace+context
# We need to split the pod@namespace+context into pod, namespace and context
# We need to determine the pod, namespace and context from the args
# For backward compatibility, we use + as the separator between namespace and context and add handling when context is not provided
shift
pod=$1
shift
echo "pod: $pod" >&2
encoded_namespace_context=$1
# Revert the encoded namespace+context to the original string.
namespace_context=$(echo "$encoded_namespace_context" | sed 's|%40|@|g' | sed 's|%3A|:|g' | sed 's|%2B|+|g' | sed 's|%2F|/|g')
echo "namespace_context: $namespace_context" >&2
if [ "$1" = "-l" ]; then
# -l pod namespace+context ...
# used by normal rsync
shift
pod=$1
shift
encoded_namespace_context=$1
shift
echo "pod: $pod" >&2
# Revert the encoded namespace+context to the original string.
namespace_context=$(echo "$encoded_namespace_context" | sed 's|%40|@|g' | sed 's|%3A|:|g' | sed 's|%2B|+|g' | sed 's|%2F|/|g')
echo "namespace_context: $namespace_context" >&2
else
# pod@namespace+context ...
# used by openrsync
encoded_pod_namespace_context=$1
shift
pod_namespace_context=$(echo "$encoded_pod_namespace_context" | sed 's|%40|@|g' | sed 's|%3A|:|g' | sed 's|%2B|+|g' | sed 's|%2F|/|g')
echo "pod_namespace_context: $pod_namespace_context" >&2
pod=$(echo $pod_namespace_context | cut -d@ -f1)
echo "pod: $pod" >&2
namespace_context=$(echo $pod_namespace_context | cut -d@ -f2-)
echo "namespace_context: $namespace_context" >&2
fi
namespace=$(echo $namespace_context | cut -d+ -f1)
echo "namespace: $namespace" >&2
context=$(echo $namespace_context | grep '+' >/dev/null && echo $namespace_context | cut -d+ -f2- || echo "")
echo "context: $context" >&2
context_lower=$(echo "$context" | tr '[:upper:]' '[:lower:]')
shift

if [ -z "$context" ] || [ "$context_lower" = "none" ]; then
# If context is none, it means we are using incluster auth. In this case,
# use need to set KUBECONFIG to /dev/null to avoid using kubeconfig file.
Expand Down