From 72984ec0a6f5505424855d6f3fb3c33cac55dd5e Mon Sep 17 00:00:00 2001 From: mowangdk Date: Sat, 10 Jun 2023 20:41:25 +0800 Subject: [PATCH] chore: adopt kubernetes recommand label --- prow.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/prow.sh b/prow.sh index 6d68fd9f..53893568 100755 --- a/prow.sh +++ b/prow.sh @@ -872,10 +872,17 @@ install_snapshot_controller() { cnt=0 expected_running_pods=$(kubectl apply --dry-run=client -o "jsonpath={.spec.replicas}" -f "$SNAPSHOT_CONTROLLER_YAML") expected_namespace=$(kubectl apply --dry-run=client -o "jsonpath={.metadata.namespace}" -f "$SNAPSHOT_CONTROLLER_YAML") - while [ "$(kubectl get pods -n "$expected_namespace" -l app=snapshot-controller | grep 'Running' -c)" -lt "$expected_running_pods" ]; do + expect_key='app\.kubernetes\.io/name' + expected_label=$(kubectl apply --dry-run=client -o "jsonpath={.spec.template.metadata.labels['$expect_key']}" -f "$SNAPSHOT_CONTROLLER_YAML") + if [ -z "${expected_label}" ]; then + expect_key='app' + expected_label=$(kubectl apply --dry-run=client -o "jsonpath={.spec.template.metadata.labels['$expect_key']}" -f "$SNAPSHOT_CONTROLLER_YAML") + fi + expect_key=${expect_key//\\/} + while [ "$(kubectl get pods -n "$expected_namespace" -l "$expect_key"="$expected_label" | grep 'Running' -c)" -lt "$expected_running_pods" ]; do if [ $cnt -gt 30 ]; then echo "snapshot-controller pod status:" - kubectl describe pods -n "$expected_namespace" -l app=snapshot-controller + kubectl describe pods -n "$expected_namespace" -l "$expect_key"="$expected_label" echo >&2 "ERROR: snapshot controller not ready after over 5 min" exit 1 fi