Skip to content

Commit

Permalink
tests: retry connection to pod SSH server
Browse files Browse the repository at this point in the history
To become more resilient against these kinds of errors:

deployment.apps/confidential-unencrypted created
pod/confidential-unencrypted-c5fdd6964-rrb6q condition met
ssh: connect to host 10.42.0.109 port 22: Connection refused

Fixes: #8687

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
  • Loading branch information
danmihai1 committed Dec 19, 2023
1 parent 6cea8a5 commit 2107189
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions tests/integration/kubernetes/k8s-confidential.bats
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ setup() {
# Check pod creation
kubectl wait --for=condition=Ready --timeout=$timeout pod "${pod_name}"

pod_ip=$(kubectl get pod -o wide | grep "confidential-unencrypted" | awk '{print $6;}')

# Run the remote command
coco_enabled=$(ssh -i ${SSH_KEY_FILE} -o "StrictHostKeyChecking no" -o "PasswordAuthentication=no" root@${pod_ip} /bin/sh -c "$(get_remote_command_per_hypervisor)" || true)

if [ -z "$coco_enabled" ]; then
>&2 echo -e "Confidential compute is expected but not enabled."
return 1
fi
coco_enabled=""
for i in {1..6}; do
if ! pod_ip=$(kubectl get pod -o wide | grep "confidential-unencrypted" | awk '{print $6;}'); then
warn "Failed to get pod IP address."
else
info "Pod IP address: ${pod_ip}"
coco_enabled=$(ssh -i ${SSH_KEY_FILE} -o "StrictHostKeyChecking no" -o "PasswordAuthentication=no" root@${pod_ip} /bin/sh -c "$(get_remote_command_per_hypervisor)") && break
warn "Failed to connect to pod."
fi
sleep 5
done
[ -z "$coco_enabled" ] && die "Confidential compute is expected but not enabled."
info "ssh client output: ${coco_enabled}"
}

teardown() {
Expand Down

0 comments on commit 2107189

Please sign in to comment.