diff --git a/.claude/skills/kerberator-register-principal/SKILL.md b/.claude/skills/kerberator-register-principal/SKILL.md index d2baaed..cab354b 100644 --- a/.claude/skills/kerberator-register-principal/SKILL.md +++ b/.claude/skills/kerberator-register-principal/SKILL.md @@ -64,7 +64,7 @@ Wait for a clear affirmative response to **this specific creation**. Do not take Use the approved exact values: ```bash -kubectl --context krb -n add-principal \ +kubectl krb -n add-principal \ --keytab-file \ --principal ``` @@ -105,7 +105,7 @@ kubectl --context krb -n describe principal kubectl --context krb -n list ``` -Verify UID, identity, Tenant reference, Secret name/key, and any selectors against the approved inputs. For the local-file path, verify that the expected Secret exists **without reading its contents**. Check `Ready` and the per-node reasons. If reconciliation is still progressing, allow one bounded follow-up status check (roughly 30 seconds later). Do not loop indefinitely or change resources to force readiness. +Verify UID, identity, Tenant reference, Secret name/key, and any selectors against the approved inputs. For the local-file path, verify that the expected Secret exists **without reading its contents**. Check `Ready` and the per-node reasons.If reconciliation is still progressing, allow up to 180 seconds for verification, checking every 15 seconds. Stop early if Ready=True, all expected nodes report Minted, and Tenant coverage is complete. If the timeout expires, report REGISTERED, NOT YET VERIFIED HEALTHY with the latest observed status. Do not loop indefinitely or change resources to force readiness. `READY=True`, expected node coverage, and `Minted` on each applicable node support a healthy result. Otherwise report `REGISTERED, NOT YET VERIFIED HEALTHY` or `FAILED`, citing actual status and events. Do not promise that all workloads already have valid tickets just because the CR exists. diff --git a/.claude/skills/kerberator-register-principal/scripts/verify.sh b/.claude/skills/kerberator-register-principal/scripts/verify.sh index a57be4b..75a0d85 100644 --- a/.claude/skills/kerberator-register-principal/scripts/verify.sh +++ b/.claude/skills/kerberator-register-principal/scripts/verify.sh @@ -3,13 +3,18 @@ set -o pipefail source "$(dirname "$0")/_common.sh" parse_args "$@"; env_check -printf '== OP-03 verification (%s) ==\n' "$(now_utc)" -raw=$(kc get principal "$NAME" -o json 2>/dev/null) -if [[ $? -ne 0 ]]; then fail "Principal $NAME not found/readable"; echo 'RESULT: NOT VERIFIED'; exit 1; fi -# Verify exact spec and health from Principal JSON only; no Secret values. -export OP03_UID="$TARGET_UID" OP03_PRINCIPAL="$PRINCIPAL" OP03_TENANT="$TENANT" OP03_SECRET="$SECRET" OP03_KEY="$SECRET_KEY" -export OP03_SELECTORS="$(printf '%s\n' "${SELECTORS[@]}")" -if ! printf '%s' "$raw" | python3 -c ' +verify_once() { + fail_count=0 + printf '== OP-03 verification (%s) ==\n' "$(now_utc)" + local raw + if ! raw=$(kc get principal "$NAME" -o json 2>/dev/null); then + fail "Principal $NAME not found/readable" + return 1 + fi + # Verify exact spec and health from Principal JSON only; no Secret values. + export OP03_UID="$TARGET_UID" OP03_PRINCIPAL="$PRINCIPAL" OP03_TENANT="$TENANT" OP03_SECRET="$SECRET" OP03_KEY="$SECRET_KEY" + export OP03_SELECTORS="$(printf '%s\n' "${SELECTORS[@]}")" + if ! printf '%s' "$raw" | python3 -c ' import json,os,sys try: d=json.load(sys.stdin) except Exception as e: print(" FAIL Principal JSON unreadable:",e);sys.exit(1) @@ -36,6 +41,24 @@ if isinstance(desired,int) and desired>0 and observed==desired and len(nodes)>=d else:print(" FAIL Tenant/node coverage not confirmed",observed,"/",desired);bad=True sys.exit(1 if bad else 0) '; then fail 'Principal spec or health checks not verified'; fi -if can get secrets && kc get secret "$SECRET" -o name >/dev/null 2>&1; then ok 'referenced Secret exists (contents not read)'; else fail 'referenced Secret is absent or unreadable'; fi -if ((fail_count)); then echo 'RESULT: NOT VERIFIED'; exit 1; fi -echo 'RESULT: VERIFIED' + if can get secrets && kc get secret "$SECRET" -o name >/dev/null 2>&1; then + ok 'referenced Secret exists (contents not read)' + else + fail 'referenced Secret is absent or unreadable' + fi + ((fail_count == 0)) +} + +deadline=$((SECONDS + 180)) +while :; do + verify_once + if ((fail_count == 0)); then echo 'RESULT: VERIFIED'; exit 0; fi + + remaining=$((deadline - SECONDS)) + if ((remaining <= 0)); then echo 'RESULT: NOT VERIFIED'; exit 1; fi + info 'Verification incomplete; retrying in 15 seconds' + sleep_for=15 + ((remaining < sleep_for)) && sleep_for=$remaining + sleep "$sleep_for" + if ((SECONDS >= deadline)); then echo 'RESULT: NOT VERIFIED'; exit 1; fi +done