Skip to content

Commit adca1e1

Browse files
committed
test(renewal): suspend the renewer's CronJob while the test runs its Jobs
The role schedules the renewer every quarter hour, so a test run that crossed a scheduled time got a Job of the CronJob's own that minted a token between the test's steps, and the refused-mint step then found the pull Secret changed. The test now suspends the CronJob when it points it at the stand-in, and deletes any Job the schedule started before that.
1 parent d6d4f19 commit adca1e1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • tests/pull_secret_renewal

‎tests/pull_secret_renewal/run.sh‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ ANSIBLE_COLLECTIONS_PATH="$repo_root/playbooks/collections${ANSIBLE_COLLECTIONS_
9393
-e renewal_namespace="$namespace" -e github_runner_arc_image_pull_secret_renewer_image="$image" -e renewal_org_image=registry.example.com/example-org/runner:1.0 \
9494
-e renewal_output="$work/renewal.yaml" >/dev/null
9595
kubectl apply -f "$work/renewal.yaml" >/dev/null
96-
# The test points the Job at the stand-in; everything else is as the role renders it.
97-
kubectl -n "$namespace" patch cronjob "$renewer" --type=json -p "[{\"op\": \"add\", \"path\": \"/spec/jobTemplate/spec/template/spec/containers/0/env/-\", \"value\": {\"name\": \"GITHUB_API_URL\", \"value\": \"http://stub-github.${namespace}.svc:8080\"}}]" >/dev/null
96+
# The test points the Job at the stand-in and suspends the CronJob, so that only the Jobs it creates from it run: the role's schedule would otherwise start one of its own whenever the test crosses a scheduled time, minting a token between the test's own steps. Everything else is as the role renders it.
97+
kubectl -n "$namespace" patch cronjob "$renewer" --type=json -p "[{\"op\": \"add\", \"path\": \"/spec/jobTemplate/spec/template/spec/containers/0/env/-\", \"value\": {\"name\": \"GITHUB_API_URL\", \"value\": \"http://stub-github.${namespace}.svc:8080\"}}, {\"op\": \"add\", \"path\": \"/spec/suspend\", \"value\": true}]" >/dev/null
98+
# A Job the schedule started between the apply and the patch would still run with the unpatched template.
99+
kubectl -n "$namespace" delete jobs --all --wait=true >/dev/null
98100

99101
log "Checking the ServiceAccount's permissions"
100102
as="system:serviceaccount:${namespace}:${renewer}"

0 commit comments

Comments
 (0)