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)) &&