mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Use rsync to probe for rsync ready
We were using netcat to try and figure out when the rsync container is ready. Now we instead use rsync itself. I suspect that there was a race condition with some versions of Docker where it would accept connections and then close them during container start. This fixes #34214 (I think)
This commit is contained in:
parent
8dd9462dd1
commit
add137c4d5
@ -582,26 +582,13 @@ function kube::build::run_build_command_ex() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function kube::build::probe_address {
|
function kube::build::rsync_probe {
|
||||||
# Apple has an ancient version of netcat with custom timeout flags. This is
|
|
||||||
# the best way I (jbeda) could find to test for that.
|
|
||||||
local netcat
|
|
||||||
if nc 2>&1 | grep -e 'apple' >/dev/null ; then
|
|
||||||
netcat="nc -G 1"
|
|
||||||
else
|
|
||||||
netcat="nc -w 1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Wait unil rsync is up and running.
|
# Wait unil rsync is up and running.
|
||||||
if ! which nc >/dev/null ; then
|
local tries=20
|
||||||
V=6 kube::log::info "netcat not installed, waiting for 1s"
|
|
||||||
sleep 1
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local tries=10
|
|
||||||
while (( ${tries} > 0 )) ; do
|
while (( ${tries} > 0 )) ; do
|
||||||
if ${netcat} -z "$1" "$2" 2> /dev/null ; then
|
if rsync "rsync://k8s@${1}:${2}/" \
|
||||||
|
--password-file="${LOCAL_OUTPUT_BUILD_CONTEXT}/rsyncd.password" \
|
||||||
|
&> /dev/null ; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
tries=$(( ${tries} - 1))
|
tries=$(( ${tries} - 1))
|
||||||
@ -637,13 +624,11 @@ function kube::build::start_rsyncd_container() {
|
|||||||
# machines) we have to talk directly to the container IP. There is no one
|
# machines) we have to talk directly to the container IP. There is no one
|
||||||
# strategy that works in all cases so we test to figure out which situation we
|
# strategy that works in all cases so we test to figure out which situation we
|
||||||
# are in.
|
# are in.
|
||||||
if kube::build::probe_address 127.0.0.1 ${mapped_port}; then
|
if kube::build::rsync_probe 127.0.0.1 ${mapped_port}; then
|
||||||
KUBE_RSYNC_ADDR="127.0.0.1:${mapped_port}"
|
KUBE_RSYNC_ADDR="127.0.0.1:${mapped_port}"
|
||||||
sleep 0.5
|
|
||||||
return 0
|
return 0
|
||||||
elif kube::build::probe_address "${container_ip}" ${KUBE_CONTAINER_RSYNC_PORT}; then
|
elif kube::build::rsync_probe "${container_ip}" ${KUBE_CONTAINER_RSYNC_PORT}; then
|
||||||
KUBE_RSYNC_ADDR="${container_ip}:${KUBE_CONTAINER_RSYNC_PORT}"
|
KUBE_RSYNC_ADDR="${container_ip}:${KUBE_CONTAINER_RSYNC_PORT}"
|
||||||
sleep 0.5
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user