tests: k8s-credentials-secrets: retry on exec error

Retry after "kubectl exec" failure, instead of aborting the test
immediately.

Example of recent error:

https://github.com/kata-containers/kata-containers/actions/runs/17828061309/job/50693999052?pr=11822

not ok 1 Credentials using secrets
 (in test file k8s-credentials-secrets.bats, line 59)
  `kubectl exec $pod_name -- "${pod_exec_command[@]}" | grep -w "username"' failed

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
Dan Mihai
2025-09-18 21:52:51 +00:00
parent 01c7949bfd
commit 524bf66cbc

View File

@@ -55,8 +55,8 @@ setup() {
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
# List the files
kubectl exec $pod_name -- "${pod_exec_command[@]}" | grep -w "password"
kubectl exec $pod_name -- "${pod_exec_command[@]}" | grep -w "username"
pod_exec_with_retries "${pod_name}" "${pod_exec_command[@]}" | grep -w "password"
pod_exec_with_retries "${pod_name}" "${pod_exec_command[@]}" | grep -w "username"
# Create a pod that has access to the secret data through environment variables
kubectl create -f "${pod_env_yaml_file}"
@@ -65,8 +65,8 @@ setup() {
kubectl wait --for=condition=Ready --timeout=$timeout pod "$second_pod_name"
# Display environment variables
kubectl exec $second_pod_name -- "${pod_env_exec_command[@]}" | grep -w "SECRET_USERNAME"
kubectl exec $second_pod_name -- "${pod_env_exec_command[@]}" | grep -w "SECRET_PASSWORD"
pod_exec_with_retries "${second_pod_name}" "${pod_env_exec_command[@]}" | grep -w "SECRET_USERNAME"
pod_exec_with_retries "${second_pod_name}" "${pod_env_exec_command[@]}" | grep -w "SECRET_PASSWORD"
}
teardown() {