5454 kubectl_cmd_base=" kubectl exec \" $resource_type /$resource_name \" -n \" $namespace \" --context=\" $context \" --"
5555fi
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.
5959wait_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}
8879wait_for_rsync
8980
0 commit comments