fix(capi-providers-core): stage unfinished kubeadm installations

A kubeadm installation can finish at its old requested version while
core moves to the intermediate release. Ignoring its initial empty
installedVersion leaves the final bootstrap chart outside its supported
upgrade window.

Fixes: 4d251f4122 ("fix(capi-providers-core): let a never-installed provider take the fresh path")
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
Aleksei Sviridkin committed 2026-11-18 15:01:21 +03:00
1 parent 2d1d98364d
commit 191e2f45fa
3 files changed
+82 -14

No files matched your search

+58 -2
View File
@@ -200,12 +200,68 @@ accepted_patches() {
[ "$(accepted_patches)" = '[]' ]
}
@test "a kubeadm provider that never finished installing is left to the final manifests" {
@test "a kubeadm installation completing during the core upgrade is staged to the bridge" {
fixture '.bootstrapAfterCore = .providers.kubeadm | del(.providers.kubeadm.status.installedVersion)'
run bash "$UPGRADE_SCRIPT"
[ "$status" -eq 0 ]
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"},{"name":"kubeadm","version":"v1.13.8-bootstrap"}]' ]
[ "$(jq --raw-output '.providers.kubeadm.status.installedVersion' "$CAPI_TEST_STATE")" = v1.13.8-bootstrap ]
}
@test "an unfinished kubeadm installation at an old requested version is staged to the bridge" {
fixture 'del(.providers.kubeadm.status.installedVersion)'
run bash "$UPGRADE_SCRIPT"
[ "$status" -eq 0 ]
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"},{"name":"kubeadm","version":"v1.13.8-bootstrap"}]' ]
[ "$(jq --raw-output '.providers.kubeadm.status.installedVersion' "$CAPI_TEST_STATE")" = v1.13.8-bootstrap ]
}
@test "an unfinished kubeadm target request does not wait for the final bootstrap chart" {
fixture 'del(.providers.kubeadm.status.installedVersion) | .providers.kubeadm.spec.version = "v1.14.4-bootstrap" | .providers.kubeadm.spec.fetchConfig.selector.matchLabels = {"provider.cluster.x-k8s.io/version": "v1.14.4-bootstrap"}'
run bash "$UPGRADE_SCRIPT"
[ "$status" -eq 0 ]
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
jq --exit-status '.providers.kubeadm | .spec.version == "v1.14.4-bootstrap" and (.status | has("installedVersion") | not)' "$CAPI_TEST_STATE"
}
@test "an unfinished kubeadm request within the upgrade window is left to the final manifests" {
fixture 'del(.providers.kubeadm.status.installedVersion) | .providers.kubeadm.spec.version = "v1.13.7-bootstrap"'
run bash "$UPGRADE_SCRIPT"
[ "$status" -eq 0 ]
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
jq --exit-status '.providers.kubeadm | .spec.version == "v1.13.7-bootstrap" and (.status | has("installedVersion") | not)' "$CAPI_TEST_STATE"
}
@test "an unfinished kubeadm installation with a malformed request is rejected" {
fixture 'del(.providers.kubeadm.status.installedVersion) | .providers.kubeadm.spec.version = "invalid"'
run bash "$UPGRADE_SCRIPT"
[ "$status" -ne 0 ]
[[ "$output" == *"invalid requested version: invalid"* ]]
[ "$(accepted_patches)" = '[]' ]
}
@test "an unfinished kubeadm installation with no requested version is rejected" {
fixture 'del(.providers.kubeadm.status.installedVersion, .providers.kubeadm.spec.version)'
run bash "$UPGRADE_SCRIPT"
[ "$status" -ne 0 ]
[[ "$output" == *"invalid requested version:"* ]]
[ "$(accepted_patches)" = '[]' ]
}
@test "a kubeadm replacement during the core upgrade is not adopted" {
fixture '.bootstrapAfterCore = (.providers.kubeadm | .metadata.uid = "replacement") | del(.providers.kubeadm.status.installedVersion)'
run bash "$UPGRADE_SCRIPT"
[ "$status" -ne 0 ]
[[ "$output" == *"kubeadm was replaced during the upgrade"* ]]
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
}
@test "a kubeadm version installed during the core upgrade is revalidated" {
fixture '.bootstrapAfterCore = (.providers.kubeadm | .status.installedVersion = "v1.14.5-bootstrap") | del(.providers.kubeadm.status.installedVersion)'
run bash "$UPGRADE_SCRIPT"
[ "$status" -ne 0 ]
[[ "$output" == *"bootstrap provider downgrades are not supported"* ]]
[ "$(accepted_patches)" = '[{"name":"cluster-api","version":"v1.13.8-core"}]' ]
[ "$(jq --raw-output '.providers.kubeadm.spec.version' "$CAPI_TEST_STATE")" = v1.10.1-bootstrap ]
}
@test "an installed kubeadm without an installed core provider is refused" {
+2
View File
@@ -92,6 +92,8 @@ if verb == "get":
obj["status"]["readyReplicas"] = 1
obj["status"]["availableReplicas"] = 1
del state["rolloutReads"][name]
if name == "capi-controller-manager" and "bootstrapAfterCore" in state and obj["status"]["readyReplicas"] == 1:
state["providers"]["kubeadm"] = state.pop("bootstrapAfterCore")
save()
print(json.dumps(obj))
elif verb == "patch":