Skip to content

Commit 75f78e8

Browse files
authored
Merge pull request #12067 from sbueringer/pr-clusterctl-add-ssa-retries
🌱 Add retry for SSA requests against Kubernetes < v1.29 in clusterctl upgrade tests
2 parents b9ac53a + 7a2c877 commit 75f78e8

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

test/e2e/clusterctl_upgrade.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"strings"
2929
"time"
3030

31+
"github.com/blang/semver/v4"
3132
. "github.com/onsi/ginkgo/v2"
3233
. "github.com/onsi/gomega"
3334
coordinationv1 "k8s.io/api/coordination/v1"
@@ -726,15 +727,28 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
726727
verifyV1Beta2ConditionsTrueV1Beta1(ctx, managementClusterProxy.GetClient(), workloadCluster.Name, workloadCluster.Namespace,
727728
[]string{clusterv1.AvailableV1Beta2Condition, clusterv1.ReadyV1Beta2Condition})
728729

729-
Byf("[%d] Verify client-side SSA still works", i)
730-
clusterUpdate := &unstructured.Unstructured{}
731-
clusterUpdate.SetGroupVersionKind(clusterv1beta1.GroupVersion.WithKind("Cluster"))
732-
clusterUpdate.SetNamespace(workloadCluster.Namespace)
733-
clusterUpdate.SetName(workloadCluster.Name)
734-
clusterUpdate.SetLabels(map[string]string{
735-
fmt.Sprintf("test-label-upgrade-%d", i): "test-label-value",
736-
})
737-
err = managementClusterProxy.GetClient().Patch(ctx, clusterUpdate, client.Apply, client.FieldOwner("e2e-test-client"))
730+
// Note: It is a known issue on Kubernetes < v1.29 that SSA sometimes fail:
731+
// https://github.com/kubernetes/kubernetes/issues/117356
732+
tries := 1
733+
initKubernetesVersionParsed, err := semver.ParseTolerant(initKubernetesVersion)
734+
Expect(err).ToNot(HaveOccurred())
735+
if initKubernetesVersionParsed.LT(semver.MustParse("1.29.0")) {
736+
tries = 10
737+
}
738+
for range tries {
739+
Byf("[%d] Verify client-side SSA still works", i)
740+
clusterUpdate := &unstructured.Unstructured{}
741+
clusterUpdate.SetGroupVersionKind(clusterv1beta1.GroupVersion.WithKind("Cluster"))
742+
clusterUpdate.SetNamespace(workloadCluster.Namespace)
743+
clusterUpdate.SetName(workloadCluster.Name)
744+
clusterUpdate.SetLabels(map[string]string{
745+
fmt.Sprintf("test-label-upgrade-%d", i): "test-label-value",
746+
})
747+
err = managementClusterProxy.GetClient().Patch(ctx, clusterUpdate, client.Apply, client.FieldOwner("e2e-test-client"))
748+
if err == nil {
749+
break
750+
}
751+
}
738752
Expect(err).ToNot(HaveOccurred())
739753

740754
Byf("[%d] THE UPGRADED MANAGEMENT CLUSTER WORKS!", i)

0 commit comments

Comments
 (0)