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 <f@lex.la>
This commit is contained in:
Aleksei Sviridkin committed 2026-11-16 14:03:54 +03:00
1 parent a52e8dac30
commit e634fd75ed
2 files changed
+8 -1

No files matched your search

+7
View File
@@ -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"
@@ -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)) &&