From 006c05ac777b817619f8db7312adff24402fbe07 Mon Sep 17 00:00:00 2001 From: Flea Flicker Date: Sun, 5 Apr 2026 15:44:29 +0000 Subject: [PATCH] fix(ci): delete completed Jobs before Flux reconciles (GRO-481) Both promote-to-uat and promote-prod workflows now delete any existing completed Jobs with the same short SHA suffix before Flux reconciles. This prevents the immutable-podTemplate error that was blocking UAT at image tag a67e541: Job.batch "migrate-schema-xxx" is invalid: spec.template: field is immutable Also added missing failure notification step to promote-prod workflow. Co-Authored-By: Paperclip --- .github/workflows/promote-prod.yml | 24 +++++++++++++++++++++++- .github/workflows/promote-to-uat.yml | 10 ++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/promote-prod.yml b/.github/workflows/promote-prod.yml index e890112..da8c9b0 100644 --- a/.github/workflows/promote-prod.yml +++ b/.github/workflows/promote-prod.yml @@ -82,4 +82,26 @@ jobs: --base main \ --head "release/promote-prod-${TAG}" \ --title "release: promote ${TAG} to production" \ - --body "Promote image tag ${TAG} to production after UAT sign-off. cc @cpfarhood" \ No newline at end of file + --body "Promote image tag ${TAG} to production after UAT sign-off. cc @cpfarhood" + + - name: Delete existing completed Jobs before Flux reconciles + env: + TAG: ${{ inputs.tag }} + run: | + SHORT_SHA="${TAG##*-}" + echo "Deleting completed Jobs with name suffix: $SHORT_SHA" + kubectl delete job "migrate-schema-${SHORT_SHA}" -n groombook --ignore-not-found + kubectl delete job "seed-test-data-${SHORT_SHA}" -n groombook --ignore-not-found + echo "Jobs deleted, Flux will reconcile with fresh objects" + + - name: Notify on failure + if: failure() + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: '## Production Promotion Failed\n\nThe `promote-prod` workflow failed. Check the workflow run logs for details.' + }); diff --git a/.github/workflows/promote-to-uat.yml b/.github/workflows/promote-to-uat.yml index c0ccff9..8fe3a37 100644 --- a/.github/workflows/promote-to-uat.yml +++ b/.github/workflows/promote-to-uat.yml @@ -95,6 +95,16 @@ jobs: --body "[GRO-429](/GRO/issues/GRO-429) — UAT promotion triggered by CTO") gh pr merge "$PR_URL" --merge + - name: Delete existing completed Jobs before Flux reconciles + env: + TAG: ${{ inputs.image_tag }} + run: | + SHORT_SHA="${TAG##*-}" + echo "Deleting completed Jobs with name suffix: $SHORT_SHA" + kubectl delete job "migrate-schema-${SHORT_SHA}" -n groombook-uat --ignore-not-found + kubectl delete job "seed-test-data-${SHORT_SHA}" -n groombook-uat --ignore-not-found + echo "Jobs deleted, Flux will reconcile with fresh objects" + - name: Notify on failure if: failure() uses: actions/github-script@v7