From 020a89ef0d0e7306ef33c468366d7a83f6061623 Mon Sep 17 00:00:00 2001 From: Marin Dzhigarov Date: Thu, 9 Apr 2026 09:53:13 +0300 Subject: [PATCH] Add version annotation to APIService to prevent race conditions during rolling upgrades During kapp-controller rolling upgrades via `kapp deploy`, a race condition can occur where kapp reports success even though the APIService webhook is not ready yet. This happens because kapp doesn't detect any changes in the APIService resource and considers the deployment complete before the new APIService is fully operational. This change adds a version annotation to the APIService that gets updated with each release, ensuring kapp detects changes and properly waits for the APIService to be ready during rolling upgrades. Changes: - Add kapp-controller.carvel.dev/version annotation to APIService metadata - Update build script to replace version placeholder with actual release version - Follow same pattern as existing Deployment resource versioning Fixes race condition during kapp-controller upgrades where APIService readiness is not properly validated. Signed-off-by: Marin Dzhigarov Made-with: Cursor --- config/config/agg-api.yml | 2 ++ hack/build-release.sh | 3 +++ 2 files changed, 5 insertions(+) diff --git a/config/config/agg-api.yml b/config/config/agg-api.yml index 181b9708c..d7f50d7f9 100644 --- a/config/config/agg-api.yml +++ b/config/config/agg-api.yml @@ -4,6 +4,8 @@ apiVersion: apiregistration.k8s.io/v1 kind: APIService metadata: name: v1alpha1.data.packaging.carvel.dev + annotations: + kapp-controller.carvel.dev/version: v0.0.0 spec: group: data.packaging.carvel.dev groupPriorityMinimum: 100 diff --git a/hack/build-release.sh b/hack/build-release.sh index 2b0a44c48..1b6ea092e 100755 --- a/hack/build-release.sh +++ b/hack/build-release.sh @@ -14,6 +14,9 @@ export version="$(get_kappctrl_ver)" sed 's/v0.0.0/'"$version"'/' config/config/deployment.yml > tmp/deployment.yml mv tmp/deployment.yml config/config/deployment.yml +sed 's/v0.0.0/'"$version"'/' config/config/agg-api.yml > tmp/agg-api.yml +mv tmp/agg-api.yml config/config/agg-api.yml + ytt -f config/config -f config/values-schema.yml -f config-release -v dev.version="$version" --data-values-env=KCTRL | kbld --imgpkg-lock-output .imgpkg/images.yml -f- > ./tmp/release.yml # Update image url in kapp-controller package overlays