From 9cf7104b3427e556ee553905ac4ebee9390698f1 Mon Sep 17 00:00:00 2001 From: Alexander Dejanovski Date: Fri, 1 Dec 2023 15:19:53 +0100 Subject: [PATCH] Fix silly stargate env variable usage --- pkg/stargate/deployments.go | 12 +++++------- pkg/stargate/deployments_test.go | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/stargate/deployments.go b/pkg/stargate/deployments.go index adb4311e9..cf7464e40 100644 --- a/pkg/stargate/deployments.go +++ b/pkg/stargate/deployments.go @@ -107,12 +107,6 @@ func NewDeployments(stargate *api.Stargate, dc *cassdcapi.CassandraDatacenter, l podMeta := createPodMeta(stargate, deploymentName) - isDse := "0" - if coreapi.ServerDistribution(dc.Spec.ServerType) == coreapi.ServerDistributionDse { - // Stargate requires a DSE env variable set to "1" to use the right backend. - isDse = "1" - } - deployment := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: deploymentName, @@ -179,7 +173,6 @@ func NewDeployments(stargate *api.Stargate, dc *cassdcapi.CassandraDatacenter, l {Name: "JAVA_OPTS", Value: jvmOptions}, {Name: "CLUSTER_NAME", Value: dc.Spec.ClusterName}, {Name: "CLUSTER_VERSION", Value: string(clusterVersion)}, - {Name: "DSE", Value: isDse}, {Name: "SEED", Value: seedService}, {Name: "DATACENTER_NAME", Value: dc.DatacenterName()}, {Name: "RACK_NAME", Value: rack.Name}, @@ -204,6 +197,11 @@ func NewDeployments(stargate *api.Stargate, dc *cassdcapi.CassandraDatacenter, l }, } + if coreapi.ServerDistribution(dc.Spec.ServerType) == coreapi.ServerDistributionDse { + // Stargate requires a DSE env variable set to "1" to use the right backend. + deployment.Spec.Template.Spec.Containers[0].Env = append(deployment.Spec.Template.Spec.Containers[0].Env, corev1.EnvVar{Name: "DSE", Value: "1"}) + } + klusterName, nameFound := stargate.Labels[coreapi.K8ssandraClusterNameLabel] klusterNamespace, namespaceFound := stargate.Labels[coreapi.K8ssandraClusterNamespaceLabel] diff --git a/pkg/stargate/deployments_test.go b/pkg/stargate/deployments_test.go index b76b13826..d1348e566 100644 --- a/pkg/stargate/deployments_test.go +++ b/pkg/stargate/deployments_test.go @@ -826,7 +826,6 @@ func testImages(t *testing.T) { assert.Equal(t, corev1.PullAlways, deployment.Spec.Template.Spec.Containers[0].ImagePullPolicy) assert.Contains(t, deployment.Spec.Template.Spec.ImagePullSecrets, corev1.LocalObjectReference{Name: "my-secret"}) assert.Len(t, deployment.Spec.Template.Spec.ImagePullSecrets, 1) - assert.Equal(t, "0", utils.FindEnvVarInContainer(&deployment.Spec.Template.Spec.Containers[0], "DSE").Value) }) t.Run("default image DSE 6.8", func(t *testing.T) { stargate := stargate.DeepCopy()