From c0a89926a17ecbeff84e3f51d52c2755edba0034 Mon Sep 17 00:00:00 2001 From: Miles Garnsey Date: Fri, 5 Apr 2024 17:45:18 +1100 Subject: [PATCH] Put an eventually in place since this update is failing on some optimistic locking issue. --- controllers/k8ssandra/add_dc_test.go | 49 ++++++++++++++++------------ 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/controllers/k8ssandra/add_dc_test.go b/controllers/k8ssandra/add_dc_test.go index 77cedad40..71daec2b0 100644 --- a/controllers/k8ssandra/add_dc_test.go +++ b/controllers/k8ssandra/add_dc_test.go @@ -744,32 +744,39 @@ func addStargateAndReaperToCluster(ctx context.Context, t *testing.T, f *framewo } func addDcToCluster(ctx context.Context, t *testing.T, f *framework.Framework, kc *api.K8ssandraCluster, dcKey framework.ClusterKey) { - t.Logf("add %s to cluster", dcKey.Name) + require.Eventually(t, func() bool { + t.Logf("add %s to cluster", dcKey.Name) - key := utils.GetKey(kc) - err := f.Client.Get(ctx, key, kc) - require.NoError(t, err, "failed to get K8ssandraCluster") + key := utils.GetKey(kc) + err := f.Client.Get(ctx, key, kc) + require.NoError(t, err, "failed to get K8ssandraCluster") - kc.Spec.Cassandra.Datacenters = append(kc.Spec.Cassandra.Datacenters, api.CassandraDatacenterTemplate{ - Meta: api.EmbeddedObjectMeta{ - Name: dcKey.Name, - Namespace: dcKey.Namespace, - }, - K8sContext: dcKey.K8sContext, - Size: 3, - DatacenterOptions: api.DatacenterOptions{ - ServerVersion: "4.0.1", - StorageConfig: &cassdcapi.StorageConfig{ - CassandraDataVolumeClaimSpec: &corev1.PersistentVolumeClaimSpec{ - StorageClassName: &defaultStorageClass, + kc.Spec.Cassandra.Datacenters = append(kc.Spec.Cassandra.Datacenters, api.CassandraDatacenterTemplate{ + Meta: api.EmbeddedObjectMeta{ + Name: dcKey.Name, + Namespace: dcKey.Namespace, + }, + K8sContext: dcKey.K8sContext, + Size: 3, + DatacenterOptions: api.DatacenterOptions{ + ServerVersion: "4.0.1", + StorageConfig: &cassdcapi.StorageConfig{ + CassandraDataVolumeClaimSpec: &corev1.PersistentVolumeClaimSpec{ + StorageClassName: &defaultStorageClass, + }, }, }, - }, - }) - annotations.AddAnnotation(kc, api.DcReplicationAnnotation, fmt.Sprintf(`{"%s": {"ks1": 3, "ks2": 3}}`, dcKey.Name)) + }) + annotations.AddAnnotation(kc, api.DcReplicationAnnotation, fmt.Sprintf(`{"%s": {"ks1": 3, "ks2": 3}}`, dcKey.Name)) + + err = f.Client.Update(ctx, kc) + if err != nil { + t.Logf("failed to add %s to cluster: %v", dcKey.Name, err) + return false + } + return err == nil + }, timeout, interval) - err = f.Client.Update(ctx, kc) - require.NoError(t, err, "failed to add dc to K8ssandraCluster") } func verifyReplicationOfSystemKeyspacesUpdated(t *testing.T, mockMgmtApi *testutils.FakeManagementApiFacade, replication, updatedReplication map[string]int) {