Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d9d2bf6

Browse files
committedMar 31, 2025··
NO-JIRA: Fixing flake EnsureKubeAPIDNSName E2E test
This PR get the latest revision of the HC object before updating it, with that we make sure we updating the latest version of the object avoiding the error 409 Signed-off-by: Juan Manuel Parrilla Madrid <[email protected]>
1 parent 3539a24 commit d9d2bf6

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed
 

‎test/e2e/util/util.go

+16-9
Original file line numberDiff line numberDiff line change
@@ -1435,13 +1435,6 @@ func EnsureGuestWebhooksValidated(t *testing.T, ctx context.Context, guestClient
14351435
}
14361436

14371437
func EnsureKubeAPIDNSName(t *testing.T, ctx context.Context, mgmtClient crclient.Client, entryHostedCluster *hyperv1.HostedCluster) {
1438-
// Skipping KubeAPIDNSName test until we investigate why it's flaking in CI
1439-
// https://testgrid-citests.apps.cewong-dev.cewong.hypershift.devcluster.openshift.com/?job=1906642686312452096&test=TestCreateClusterCustomConfig/Main
1440-
// Message: "Operation cannot be fulfilled on hostedclusters.hypershift.openshift.io \"custom-config-2pwq4\": the object has been modified; please apply your changes to the latest version and try again",
1441-
// Reason: "Conflict"
1442-
// Code: 409
1443-
1444-
t.Skip("Skipping KubeAPIDNSName test")
14451438
AtLeast(t, Version419)
14461439
var (
14471440
hcKASCustomKubeconfigSecretName string
@@ -1470,7 +1463,14 @@ func EnsureKubeAPIDNSName(t *testing.T, ctx context.Context, mgmtClient crclient
14701463
hc.Spec.KubeAPIServerDNSName = customApiServerHost
14711464
t.Log("Updating hosted cluster with KubeAPIDNSName")
14721465
err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
1473-
return mgmtClient.Update(ctx, hc)
1466+
// Get the latest version of the object
1467+
latestHC := &hyperv1.HostedCluster{}
1468+
if err := mgmtClient.Get(ctx, client.ObjectKeyFromObject(hc), latestHC); err != nil {
1469+
return err
1470+
}
1471+
// Apply our changes to the latest version
1472+
latestHC.Spec.KubeAPIServerDNSName = customApiServerHost
1473+
return mgmtClient.Update(ctx, latestHC)
14741474
})
14751475
g.Expect(err).NotTo(HaveOccurred(), "failed to update hosted cluster")
14761476

@@ -1553,7 +1553,14 @@ func EnsureKubeAPIDNSName(t *testing.T, ctx context.Context, mgmtClient crclient
15531553
// removing KubeAPIDNSName from HC
15541554
hc.Spec.KubeAPIServerDNSName = ""
15551555
err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
1556-
return mgmtClient.Update(ctx, hc)
1556+
// Get the latest version of the object
1557+
latestHC := &hyperv1.HostedCluster{}
1558+
if err := mgmtClient.Get(ctx, client.ObjectKeyFromObject(hc), latestHC); err != nil {
1559+
return err
1560+
}
1561+
// Apply our changes to the latest version
1562+
latestHC.Spec.KubeAPIServerDNSName = ""
1563+
return mgmtClient.Update(ctx, latestHC)
15571564
})
15581565
g.Expect(err).NotTo(HaveOccurred(), "failed to update hosted control plane")
15591566

0 commit comments

Comments
 (0)
Please sign in to comment.