Skip to content

Commit 34ddd9e

Browse files
authored
Merge pull request #5797 from twz123/fix-ostests-konnectivity-check
Fix konnectivity health check in OS tests
2 parents c0f0042 + 54f1dd8 commit 34ddd9e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

hack/ostests/modules/k0sctl/pre-flight-checks.sh

+17-17
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,26 @@ kubectl() {
2828
"$@"
2929
}
3030

31-
countSeenControllers() {
32-
kubectl -n kube-system logs "$1" \
33-
| grep -F '"Start serving"' \
34-
| sed -E 's/.+serverID="([0-9a-f]+)".+/\1/g' \
35-
| sort -u \
36-
| wc -l
37-
}
38-
3931
testKonnectivityPods() {
40-
pods="$(kubectl -n kube-system get po -l k8s-app=konnectivity-agent --field-selector=status.phase=Running -oname)"
41-
42-
seenPods=0
43-
for pod in $pods; do
44-
seenControllers="$(countSeenControllers "$pod")"
45-
echo Pod: "$pod", seen controllers: "$seenControllers" >&2
46-
[ "$seenControllers" -ne "$expectedControllers" ] || seenPods=$((seenPods + 1))
32+
nodeIPs=$(kubectl get nodes -o jsonpath='{range .items[*]}{.status.addresses[?(@.type=="InternalIP")].address}{"\n"}{end}')
33+
34+
goodNodes=0
35+
for ip in $nodeIPs; do
36+
openServerConnections=$(curl -sSf "http://$ip:8093/metrics" | {
37+
while read -r metric value; do
38+
if [ "$metric" = konnectivity_network_proxy_agent_open_server_connections ]; then
39+
echo "$value"
40+
break
41+
fi
42+
done
43+
})
44+
45+
echo Node IP: "$ip", open konnectivity server connections: "$openServerConnections" >&2
46+
[ "$openServerConnections" -ne "$expectedControllers" ] || goodNodes=$((goodNodes + 1))
4747
done
4848

49-
echo Seen pods with expected amount of controller connections: $seenPods >&2
50-
[ $seenPods -eq "$expectedWorkers" ]
49+
echo Nodes with expected number of open konnectivity server connections: $goodNodes >&2
50+
[ $goodNodes -eq "$expectedWorkers" ]
5151
}
5252

5353
testCoreDnsDeployment() {

0 commit comments

Comments
 (0)