diff --git a/controllers/medusa/medusarestorejob_controller.go b/controllers/medusa/medusarestorejob_controller.go index 5d36c32c9..0c85551e1 100644 --- a/controllers/medusa/medusarestorejob_controller.go +++ b/controllers/medusa/medusarestorejob_controller.go @@ -377,6 +377,7 @@ func updateMedusaRestoreInitContainer(req *medusa.RestoreRequest) error { if err := setRestoreMappingInRestoreContainer(req.RestoreJob.Status.RestoreMapping, req.Datacenter); err != nil { return err } + return setRestoreKeyInRestoreContainer(req.RestoreJob.Status.RestoreKey, req.Datacenter) } diff --git a/pkg/cassandra/datacenter.go b/pkg/cassandra/datacenter.go index 22e985abc..1162a96e3 100644 --- a/pkg/cassandra/datacenter.go +++ b/pkg/cassandra/datacenter.go @@ -156,9 +156,11 @@ func NewDatacenter(klusterKey types.NamespacedName, template *DatacenterConfig) dc := &cassdcapi.CassandraDatacenter{ ObjectMeta: metav1.ObjectMeta{ - Namespace: namespace, - Name: template.Meta.Name, - Annotations: map[string]string{}, + Namespace: namespace, + Name: template.Meta.Name, + Annotations: map[string]string{ + cassdcapi.UpdateAllowedAnnotation: string(cassdcapi.AllowUpdateAlways), + }, Labels: utils.MergeMap(map[string]string{ api.NameLabel: api.NameLabelValue, api.PartOfLabel: api.PartOfLabelValue, diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index 0a240eca7..bb4686113 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -604,7 +604,7 @@ func beforeTest(t *testing.T, f *framework.E2eFramework, opts *e2eTestOpts) erro return nil } -func upgradeToLatest(t *testing.T, ctx context.Context, f *framework.E2eFramework, namespace string) error { +func upgradeToLatest(t *testing.T, ctx context.Context, f *framework.E2eFramework, namespace, dcPrefix string) error { deploymentConfig := framework.OperatorDeploymentConfig{ Namespace: namespace, ClusterScoped: false, @@ -716,7 +716,7 @@ func applyPollingDefaults() { polling.medusaBackupDone.timeout = 10 * time.Minute polling.medusaBackupDone.interval = 15 * time.Second - polling.medusaRestoreDone.timeout = 10 * time.Minute + polling.medusaRestoreDone.timeout = 15 * time.Minute polling.medusaRestoreDone.interval = 15 * time.Second polling.datacenterUpdating.timeout = 1 * time.Minute @@ -955,51 +955,9 @@ func createSingleDatacenterClusterWithUpgrade(t *testing.T, ctx context.Context, assertCassandraDatacenterK8cStatusReady(ctx, t, f, kcKey, dcKey.Name) dcPrefix := DcPrefix(t, f, dcKey) - stargateKey := framework.ClusterKey{K8sContext: f.DataPlaneContexts[0], NamespacedName: types.NamespacedName{Namespace: namespace, Name: dcPrefix + "-stargate"}} - checkStargateReady(t, f, ctx, stargateKey) - checkStargateK8cStatusReady(t, f, ctx, kcKey, dcKey) - - // Save the Stargate deployment resource hash to verify if it was modified by the upgrade. - // It'll allow to wait for the pod to be successfully upgraded before performing the Stargate API tests. - stargateDeploymentKey := framework.ClusterKey{K8sContext: f.DataPlaneContexts[0], NamespacedName: types.NamespacedName{Namespace: namespace, Name: dcPrefix + "-default-stargate-deployment"}} - initialStargateResourceHash := GetStargateResourceHash(t, f, ctx, stargateDeploymentKey) - initialStargatePodNames := GetStargatePodNames(t, f, ctx, stargateDeploymentKey) - require.Len(initialStargatePodNames, 1, "expected 1 Stargate pod in namespace %s", namespace) - - t.Log("retrieve database credentials") - username, password, err := f.RetrieveDatabaseCredentials(ctx, f.DataPlaneContexts[0], namespace, k8ssandra.SanitizedName()) - require.NoError(err, "failed to retrieve database credentials") - - t.Log("deploying Stargate ingress routes in context", f.DataPlaneContexts[0]) - stargateRestHostAndPort := ingressConfigs[f.DataPlaneContexts[0]].StargateRest - stargateGrpcHostAndPort := ingressConfigs[f.DataPlaneContexts[0]].StargateGrpc - stargateCqlHostAndPort := ingressConfigs[f.DataPlaneContexts[0]].StargateCql - f.DeployStargateIngresses(t, f.DataPlaneContexts[0], namespace, dcPrefix+"-stargate-service", stargateRestHostAndPort, stargateGrpcHostAndPort) - defer f.UndeployAllIngresses(t, f.DataPlaneContexts[0], namespace) - // Perform the upgrade - err = upgradeToLatest(t, ctx, f, namespace) + err = upgradeToLatest(t, ctx, f, namespace, dcPrefix) require.NoError(err, "failed to upgrade to latest version") - - // Wait for the Stargate deployment resource hash to change. - // It'll allow to wait for the pod to be successfully upgraded before performing the Stargate API tests. - // It's possible that this assertion will fail if the Stargate deployment resource hash is not changed. - newStargateResourceHash := waitForStargateUpgrade(t, f, ctx, stargateDeploymentKey, initialStargateResourceHash) - - t.Logf("Stargate initial deployment resource hash: %s / Current hash: %s", initialStargateResourceHash, newStargateResourceHash) - if initialStargateResourceHash != newStargateResourceHash { - // Stargate deployment was modified after the upgrade, we need to wait for the new pod to be ready - t.Log("Stargate deployment updated, waiting for new pod to be ready") - require.Eventually(func() bool { - newStargatePodNames := GetStargatePodNames(t, f, ctx, stargateDeploymentKey) - return !utils.SliceContains(newStargatePodNames, initialStargatePodNames[0]) - }, polling.stargateReady.timeout, polling.stargateReady.interval) - } - - checkStargateApisReachable(t, ctx, f.DataPlaneContexts[0], namespace, dcPrefix, stargateRestHostAndPort, stargateGrpcHostAndPort, stargateCqlHostAndPort, username, password, false, f) - - replication := map[string]int{DcName(t, f, dcKey): 1} - testStargateApis(t, f, ctx, f.DataPlaneContexts[0], namespace, dcPrefix, username, password, false, replication) } // createSingleDatacenterCluster creates a K8ssandraCluster with one CassandraDatacenter @@ -2108,32 +2066,6 @@ func DcName( return cassdc.DatacenterName() } -func waitForStargateUpgrade(t *testing.T, f *framework.E2eFramework, ctx context.Context, stargateDeploymentKey framework.ClusterKey, initialStargateResourceHash string) string { - stargateChan := make(chan string) - go func() { - for { - stargateDeploymentResourceHash := GetStargateResourceHash(t, f, ctx, stargateDeploymentKey) - if stargateDeploymentResourceHash != initialStargateResourceHash { - stargateChan <- stargateDeploymentResourceHash - return - } - time.Sleep(time.Second) - } - }() - - stargateUpgradeTimeout := time.After(5 * time.Minute) - for { - select { - case newStargateResourceHash := <-stargateChan: - t.Logf("Stargate deployment resource hash changed to %s", newStargateResourceHash) - return newStargateResourceHash - case <-stargateUpgradeTimeout: - t.Log("Stargate deployment resource hash did not change") - return initialStargateResourceHash - } - } -} - func checkMetricsFiltersAbsence(t *testing.T, ctx context.Context, f *framework.E2eFramework, dcKey framework.ClusterKey) error { t.Logf("check that metric filters are absent on dc %s in cluster %s", dcKey.Name, dcKey.K8sContext) cassdc := &cassdcapi.CassandraDatacenter{} diff --git a/test/testdata/fixtures/gc/4.0-jdk11-CMS/k8ssandra.yaml b/test/testdata/fixtures/gc/4.0-jdk11-CMS/k8ssandra.yaml index 9d9015847..9a924fb3b 100644 --- a/test/testdata/fixtures/gc/4.0-jdk11-CMS/k8ssandra.yaml +++ b/test/testdata/fixtures/gc/4.0-jdk11-CMS/k8ssandra.yaml @@ -4,7 +4,7 @@ metadata: name: test spec: cassandra: - serverVersion: 4.0.3 + serverVersion: 4.0.13 datacenters: - metadata: name: dc1 diff --git a/test/testdata/fixtures/gc/4.0-jdk11-G1/k8ssandra.yaml b/test/testdata/fixtures/gc/4.0-jdk11-G1/k8ssandra.yaml index 1db20c4bd..b1d3f3753 100644 --- a/test/testdata/fixtures/gc/4.0-jdk11-G1/k8ssandra.yaml +++ b/test/testdata/fixtures/gc/4.0-jdk11-G1/k8ssandra.yaml @@ -4,7 +4,7 @@ metadata: name: test spec: cassandra: - serverVersion: 4.0.3 + serverVersion: 4.0.13 datacenters: - metadata: name: dc1 diff --git a/test/testdata/fixtures/gc/4.0-jdk11-ZGC/k8ssandra.yaml b/test/testdata/fixtures/gc/4.0-jdk11-ZGC/k8ssandra.yaml index ec85ff265..fb0116b90 100644 --- a/test/testdata/fixtures/gc/4.0-jdk11-ZGC/k8ssandra.yaml +++ b/test/testdata/fixtures/gc/4.0-jdk11-ZGC/k8ssandra.yaml @@ -4,7 +4,7 @@ metadata: name: test spec: cassandra: - serverVersion: 4.0.3 + serverVersion: 4.0.13 datacenters: - metadata: name: dc1 diff --git a/test/testdata/fixtures/multi-dc-medusa/k8ssandra.yaml b/test/testdata/fixtures/multi-dc-medusa/k8ssandra.yaml index 693698a5e..8768ea427 100644 --- a/test/testdata/fixtures/multi-dc-medusa/k8ssandra.yaml +++ b/test/testdata/fixtures/multi-dc-medusa/k8ssandra.yaml @@ -5,8 +5,8 @@ metadata: spec: cassandra: clusterName: "E2E Test Cluster" - serverVersion: "4.0.0" - serverImage: k8ssandra/cass-management-api:4.0.0 + serverVersion: "4.0.13" + serverImage: k8ssandra/cass-management-api:4.0.13 storageConfig: cassandraDataVolumeClaimSpec: storageClassName: standard diff --git a/test/testdata/fixtures/multi-dc-mixed/k8ssandra.yaml b/test/testdata/fixtures/multi-dc-mixed/k8ssandra.yaml index c0dcd5a76..145b355ed 100644 --- a/test/testdata/fixtures/multi-dc-mixed/k8ssandra.yaml +++ b/test/testdata/fixtures/multi-dc-mixed/k8ssandra.yaml @@ -5,7 +5,7 @@ metadata: spec: cassandra: clusterName: "E2E Test Cluster" - serverVersion: "4.0.3" + serverVersion: "4.0.13" storageConfig: cassandraDataVolumeClaimSpec: storageClassName: standard diff --git a/test/testdata/fixtures/multi-dc-reaper/k8ssandra.yaml b/test/testdata/fixtures/multi-dc-reaper/k8ssandra.yaml index 560095496..e6ddb9424 100644 --- a/test/testdata/fixtures/multi-dc-reaper/k8ssandra.yaml +++ b/test/testdata/fixtures/multi-dc-reaper/k8ssandra.yaml @@ -34,7 +34,7 @@ spec: heapSize: 256Mi cassandra: clusterName: "E2E Test Cluster" - serverVersion: "4.0.1" + serverVersion: "4.0.13" datacenters: - metadata: name: dc1 diff --git a/test/testdata/fixtures/remove-dc/k8ssandra.yaml b/test/testdata/fixtures/remove-dc/k8ssandra.yaml index 1a49232d6..ba9510529 100644 --- a/test/testdata/fixtures/remove-dc/k8ssandra.yaml +++ b/test/testdata/fixtures/remove-dc/k8ssandra.yaml @@ -4,7 +4,7 @@ metadata: name: test spec: cassandra: - serverVersion: "4.0.1" + serverVersion: "4.0.13" storageConfig: cassandraDataVolumeClaimSpec: storageClassName: standard diff --git a/test/testdata/fixtures/remove-local-dc/k8ssandra.yaml b/test/testdata/fixtures/remove-local-dc/k8ssandra.yaml index 6fe407f55..d0ab1bed8 100644 --- a/test/testdata/fixtures/remove-local-dc/k8ssandra.yaml +++ b/test/testdata/fixtures/remove-local-dc/k8ssandra.yaml @@ -4,7 +4,7 @@ metadata: name: test spec: cassandra: - serverVersion: "4.0.1" + serverVersion: "4.0.13" storageConfig: cassandraDataVolumeClaimSpec: storageClassName: standard diff --git a/test/testdata/fixtures/single-dc-dse-medusa/k8ssandra.yaml b/test/testdata/fixtures/single-dc-dse-medusa/k8ssandra.yaml index d2c485680..ba57b1740 100644 --- a/test/testdata/fixtures/single-dc-dse-medusa/k8ssandra.yaml +++ b/test/testdata/fixtures/single-dc-dse-medusa/k8ssandra.yaml @@ -15,7 +15,7 @@ spec: secure: false cassandra: clusterName: "First Cluster" - serverVersion: 6.8.36 + serverVersion: 6.8.43 serverType: dse datacenters: - metadata: diff --git a/test/testdata/fixtures/single-dc-multi-cluster-medusa/k8ssandra.yaml b/test/testdata/fixtures/single-dc-multi-cluster-medusa/k8ssandra.yaml index 6d80d2f5d..ade01f1a8 100644 --- a/test/testdata/fixtures/single-dc-multi-cluster-medusa/k8ssandra.yaml +++ b/test/testdata/fixtures/single-dc-multi-cluster-medusa/k8ssandra.yaml @@ -22,7 +22,7 @@ metadata: name: cluster1 spec: cassandra: - serverVersion: 4.0.11 + serverVersion: 4.0.13 datacenters: - metadata: name: cluster1-dc1 @@ -47,7 +47,7 @@ metadata: name: cluster2 spec: cassandra: - serverVersion: 4.0.11 + serverVersion: 4.0.13 superuserSecretRef: name: cluster2-superuser datacenters: diff --git a/test/testdata/fixtures/single-dc-upgrade/k8ssandra.yaml b/test/testdata/fixtures/single-dc-upgrade/k8ssandra.yaml index 080bc7283..baa28ff8c 100644 --- a/test/testdata/fixtures/single-dc-upgrade/k8ssandra.yaml +++ b/test/testdata/fixtures/single-dc-upgrade/k8ssandra.yaml @@ -10,6 +10,15 @@ spec: name: dc1 k8sContext: kind-k8ssandra-0 size: 2 + initContainers: + - name: "server-config-init" + resources: + requests: + memory: 256Mi + cpu: 1 + limits: + memory: 512Mi + cpu: 1 storageConfig: cassandraDataVolumeClaimSpec: storageClassName: standard @@ -18,21 +27,4 @@ spec: resources: requests: storage: 5Gi - stargate: - size: 1 - heapSize: 384Mi - livenessProbe: - initialDelaySeconds: 100 - periodSeconds: 10 - failureThreshold: 20 - successThreshold: 1 - timeoutSeconds: 20 - readinessProbe: - initialDelaySeconds: 100 - periodSeconds: 10 - failureThreshold: 20 - successThreshold: 1 - timeoutSeconds: 20 - cassandraConfigMapRef: - name: cassandra-config mgmtAPIHeap: 64Mi diff --git a/test/testdata/fixtures/single-dc/k8ssandra.yaml b/test/testdata/fixtures/single-dc/k8ssandra.yaml index 18f7da717..a33f05303 100644 --- a/test/testdata/fixtures/single-dc/k8ssandra.yaml +++ b/test/testdata/fixtures/single-dc/k8ssandra.yaml @@ -38,7 +38,7 @@ spec: anAnnotationKeyDcLevel: anAnnotationValueDCLevel k8sContext: kind-k8ssandra-0 size: 3 - serverVersion: 4.0.6 + serverVersion: 4.0.13 storageConfig: cassandraDataVolumeClaimSpec: storageClassName: standard diff --git a/test/testdata/fixtures/stop-dc/k8ssandra.yaml b/test/testdata/fixtures/stop-dc/k8ssandra.yaml index 14110f76e..576ecb2d4 100644 --- a/test/testdata/fixtures/stop-dc/k8ssandra.yaml +++ b/test/testdata/fixtures/stop-dc/k8ssandra.yaml @@ -4,7 +4,7 @@ metadata: name: cluster1 spec: cassandra: - serverVersion: "4.0.1" + serverVersion: "4.0.13" storageConfig: cassandraDataVolumeClaimSpec: storageClassName: standard