Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ff1b89

Browse files
author
Ritesh H Shukla
committed
Wait for cbr0 configuration to complete before setting up routes.
- fixes #34248, #31310 - Remove optimizations for salt status check till flakyness of install is addressed - fix indentation
1 parent 35943d6 commit 4ff1b89

1 file changed

Lines changed: 45 additions & 16 deletions

File tree

cluster/vsphere/util.sh

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -325,23 +325,52 @@ function setup-pod-routes {
325325
# identify the subnet assigned to the node by the kubernetes controller manager.
326326
KUBE_NODE_BRIDGE_NETWORK=()
327327
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
328-
printf " finding network of cbr0 bridge on node ${NODE_NAMES[$i]}\n"
329-
network=$(kube-ssh ${KUBE_NODE_IP_ADDRESSES[$i]} 'sudo ip route show | grep -E "dev cbr0" | cut -d " " -f1')
330-
KUBE_NODE_BRIDGE_NETWORK+=("${network}")
331-
done
328+
printf " finding network of cbr0 bridge on node ${NODE_NAMES[$i]}\n"
329+
330+
network=""
331+
top2_octets_final=$(echo $NODE_IP_RANGES | awk -F "." '{ print $1 "." $2 }') # Assume that a 24 bit mask per node
332+
333+
attempt=0
334+
max_attempt=60
335+
while true ; do
336+
attempt=$(($attempt+1))
337+
338+
network=$(kube-ssh ${KUBE_NODE_IP_ADDRESSES[$i]} 'sudo ip route show | grep -E "dev cbr0" | cut -d " " -f1')
339+
top2_octets_read=$(echo $network | awk -F "." '{ print $1 "." $2 }')
340+
341+
if [[ "$top2_octets_read" == "$top2_octets_final" ]]; then
342+
break
343+
fi
344+
345+
if (( $attempt == $max_attempt )); then
346+
echo
347+
echo "(Failed) Waiting for cbr0 bridge to come up @ ${NODE_NAMES[$i]}"
348+
echo
349+
exit 1
350+
fi
351+
352+
printf "."
353+
sleep 5
354+
done
332355

356+
printf "\n"
357+
KUBE_NODE_BRIDGE_NETWORK+=("${network}")
358+
done
333359

334360
# Make the pods visible to each other and to the master.
335361
# The master needs have routes to the pods for the UI to work.
336362
local j
337363
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
338-
printf "setting up routes for ${NODE_NAMES[$i]}"
339-
kube-ssh "${KUBE_MASTER_IP}" "sudo route add -net ${KUBE_NODE_BRIDGE_NETWORK[${i}]} gw ${KUBE_NODE_IP_ADDRESSES[${i}]}"
340-
for (( j=0; j<${#NODE_NAMES[@]}; j++)); do
341-
if [[ $i != $j ]]; then
342-
kube-ssh ${KUBE_NODE_IP_ADDRESSES[$i]} "sudo route add -net ${KUBE_NODE_BRIDGE_NETWORK[$j]} gw ${KUBE_NODE_IP_ADDRESSES[$j]}"
343-
fi
344-
done
364+
printf "setting up routes for ${NODE_NAMES[$i]}\n"
365+
printf " adding route to ${MASTER_NAME} for network ${KUBE_NODE_BRIDGE_NETWORK[${i}]} via ${KUBE_NODE_IP_ADDRESSES[${i}]}\n"
366+
kube-ssh "${KUBE_MASTER_IP}" "sudo route add -net ${KUBE_NODE_BRIDGE_NETWORK[${i}]} gw ${KUBE_NODE_IP_ADDRESSES[${i}]}"
367+
for (( j=0; j<${#NODE_NAMES[@]}; j++)); do
368+
if [[ $i != $j ]]; then
369+
printf " adding route to ${NODE_NAMES[$j]} for network ${KUBE_NODE_BRIDGE_NETWORK[${i}]} via ${KUBE_NODE_IP_ADDRESSES[${i}]}\n"
370+
kube-ssh ${KUBE_NODE_IP_ADDRESSES[$i]} "sudo route add -net ${KUBE_NODE_BRIDGE_NETWORK[$j]} gw ${KUBE_NODE_IP_ADDRESSES[$j]}"
371+
fi
372+
done
373+
printf "\n"
345374
done
346375
}
347376

@@ -465,18 +494,18 @@ function kube-up {
465494
printf "Waiting for salt-master to be up on ${KUBE_MASTER} ...\n"
466495
remote-pgrep ${KUBE_MASTER_IP} "salt-master"
467496

497+
printf "Waiting for all packages to be installed on ${KUBE_MASTER} ...\n"
498+
kube-check ${KUBE_MASTER_IP} 'sudo salt "kubernetes-master" state.highstate -t 30 | grep -E "Failed:[[:space:]]+0"'
499+
468500
local i
469501
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
470502
printf "Waiting for salt-minion to be up on ${NODE_NAMES[$i]} ....\n"
471503
remote-pgrep ${KUBE_NODE_IP_ADDRESSES[$i]} "salt-minion"
504+
printf "Waiting for all salt packages to be installed on ${NODE_NAMES[$i]} .... \n"
505+
kube-check ${KUBE_MASTER_IP} 'sudo salt '"${NODE_NAMES[$i]}"' state.highstate -t 30 | grep -E "Failed:[[:space:]]+0"'
472506
printf " OK\n"
473507
done
474508

475-
printf "Waiting for init highstate to be done on all nodes (this can take a few minutes) ...\n"
476-
kube-check ${KUBE_MASTER_IP} 'sudo salt '\''*'\'' state.show_highstate -t 50'
477-
printf "Waiting for all packages to be installed on all nodes (this can take a few minutes) ...\n"
478-
kube-check ${KUBE_MASTER_IP} 'sudo salt '\''*'\'' state.highstate -t 50 | grep -E "Failed:[[:space:]]+0"'
479-
480509
echo
481510

482511
echo "Waiting for master and node initialization."

0 commit comments

Comments
 (0)