From e634fd75ed249bd3afb00b7d3c008e0303086328 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Mon, 16 Nov 2026 14:03:54 +0300 Subject: [PATCH] fix(capi-providers-core): repair a bridge selector with extra expressions The repair check compared only matchLabels, so a bridge selector with the right label plus matchExpressions was left alone, although the bridge ConfigMaps carry nothing those expressions could match and the selector then finds no repository. The check now compares the whole selector, the same shape the repair patch writes. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- hack/capi-upgrade_test.bats | 7 +++++++ .../system/capi-providers-core/files/upgrade-providers.sh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hack/capi-upgrade_test.bats b/hack/capi-upgrade_test.bats index bb95aae35..9172f904a 100644 --- a/hack/capi-upgrade_test.bats +++ b/hack/capi-upgrade_test.bats @@ -283,6 +283,13 @@ accepted_patches() { jq --exit-status 'all(.providers[]; .spec.fetchConfig.selector.matchLabels == {"provider.cluster.x-k8s.io/version": .spec.version})' "$CAPI_TEST_STATE" } +@test "a bridge selector with extra expressions is narrowed to the version label" { + fixture '.providers |= with_entries(.value.spec.version = ("v1.13.8-" + (if .key == "cluster-api" then "core" else "bootstrap" end)) | .value.status.installedVersion = .value.spec.version | .value.spec.fetchConfig.selector = {matchLabels: {"provider.cluster.x-k8s.io/version": .value.spec.version}, matchExpressions: [{key: "core-components", operator: "Exists"}]})' + run bash "$UPGRADE_SCRIPT" + [ "$status" -eq 0 ] + jq --exit-status 'all(.providers[]; .spec.fetchConfig.selector == {matchLabels: {"provider.cluster.x-k8s.io/version": .spec.version}})' "$CAPI_TEST_STATE" +} + @test "already selected bridges repair missing fetchConfig without changing other spec fields" { fixture '.providers |= with_entries(.value.spec.version = ("v1.13.8-" + (if .key == "cluster-api" then "core" else "bootstrap" end)) | .value.status.installedVersion = .value.spec.version | .value.spec.deployment = {replicas: 2} | del(.value.spec.fetchConfig))' run bash "$UPGRADE_SCRIPT" diff --git a/packages/system/capi-providers-core/files/upgrade-providers.sh b/packages/system/capi-providers-core/files/upgrade-providers.sh index a93a649fa..b4464e92d 100644 --- a/packages/system/capi-providers-core/files/upgrade-providers.sh +++ b/packages/system/capi-providers-core/files/upgrade-providers.sh @@ -83,7 +83,7 @@ fi bridge_selector_needs_repair() { jq --exit-status --arg version "$BRIDGE_VERSION-$2" ' .spec.version == $version and - .spec.fetchConfig.selector.matchLabels != {"provider.cluster.x-k8s.io/version": $version}' <<< "$1" >/dev/null + .spec.fetchConfig.selector != {matchLabels: {"provider.cluster.x-k8s.io/version": $version}}' <<< "$1" >/dev/null } if ((target_minor - core_minor <= 3 && target_minor - bootstrap_minor <= 3)) &&