Skip to content

Commit

Permalink
Fix silly stargate env variable usage
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski committed Dec 1, 2023
1 parent eb0ac0e commit 9cf7104
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
12 changes: 5 additions & 7 deletions pkg/stargate/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand All @@ -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]

Expand Down
1 change: 0 additions & 1 deletion pkg/stargate/deployments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 9cf7104

Please sign in to comment.