diff --git a/CHANGELOG.md b/CHANGELOG.md index a80b6d97..afe7cc7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ Changelog for Cass Operator, new PRs should update the `main / unreleased` secti * [BUGFIX] ``` +## unreleased + +* [BUGFIX] [#703](https://github.com/k8ssandra/cass-operator/issues/703) Fix HCD config path from /etc/cassandra to /opt/hcd/resources/cassandra/conf + ## v1.22.1 * [BUGFIX] [#687](https://github.com/k8ssandra/cass-operator/issues/687) Prevent a crash when when StorageClassName was not set in the CassandraDataVolumeClaimSpec diff --git a/pkg/reconciliation/construct_podtemplatespec.go b/pkg/reconciliation/construct_podtemplatespec.go index 2dfc83e7..cbc4426c 100644 --- a/pkg/reconciliation/construct_podtemplatespec.go +++ b/pkg/reconciliation/construct_podtemplatespec.go @@ -742,10 +742,18 @@ func buildContainers(dc *api.CassandraDatacenter, baseTemplate *corev1.PodTempla Name: "tmp", MountPath: "/tmp", }) - cassContainer.VolumeMounts = append(cassContainer.VolumeMounts, corev1.VolumeMount{ - Name: "etc-cassandra", - MountPath: "/etc/cassandra", - }) + + if dc.Spec.ServerType == "hcd" { + cassContainer.VolumeMounts = append(cassContainer.VolumeMounts, corev1.VolumeMount{ + Name: "etc-cassandra", + MountPath: "/opt/hcd/resources/cassandra/conf", + }) + } else { + cassContainer.VolumeMounts = append(cassContainer.VolumeMounts, corev1.VolumeMount{ + Name: "etc-cassandra", + MountPath: "/etc/cassandra", + }) + } } volumeMounts = combineVolumeMountSlices(volumeMounts, cassContainer.VolumeMounts) diff --git a/pkg/reconciliation/construct_podtemplatespec_test.go b/pkg/reconciliation/construct_podtemplatespec_test.go index c116a73e..98db5f8a 100644 --- a/pkg/reconciliation/construct_podtemplatespec_test.go +++ b/pkg/reconciliation/construct_podtemplatespec_test.go @@ -2006,3 +2006,59 @@ func TestReadOnlyRootFilesystemVolumeChanges(t *testing.T) { mcacDisabled := corev1.EnvVar{Name: "MGMT_API_DISABLE_MCAC", Value: "true"} assert.True(envVarsContains(containers[0].Env, mcacDisabled)) } + +func TestReadOnlyRootFilesystemVolumeChangesHCD(t *testing.T) { + assert := assert.New(t) + dc := &api.CassandraDatacenter{ + Spec: api.CassandraDatacenterSpec{ + ClusterName: "bob", + ServerType: "hcd", + ServerVersion: "1.0.0", + ReadOnlyRootFilesystem: ptr.To[bool](true), + Racks: []api.Rack{ + { + Name: "r1", + }, + }, + }, + } + + podTemplateSpec, err := buildPodTemplateSpec(dc, dc.Spec.Racks[0], false) + assert.NoError(err, "failed to build PodTemplateSpec") + + containers := podTemplateSpec.Spec.Containers + assert.NotNil(containers, "Unexpected containers containers received") + assert.NoError(err, "Unexpected error encountered") + + assert.Len(containers, 2, "Unexpected number of containers containers returned") + assert.Equal("cassandra", containers[0].Name) + assert.Equal(ptr.To[bool](true), containers[0].SecurityContext.ReadOnlyRootFilesystem) + + assert.True(reflect.DeepEqual(containers[0].VolumeMounts, + []corev1.VolumeMount{ + { + Name: "tmp", + MountPath: "/tmp", + }, + { + Name: "etc-cassandra", + MountPath: "/opt/hcd/resources/cassandra/conf", + }, + { + Name: "server-logs", + MountPath: "/var/log/cassandra", + }, + { + Name: "server-data", + MountPath: "/var/lib/cassandra", + }, + { + Name: "server-config", + MountPath: "/config", + }, + }), fmt.Sprintf("Unexpected volume mounts for the cassandra container: %v", containers[0].VolumeMounts)) + + // TODO Verify MCAC is disabled since it will fail with ReadOnlyRootFilesystem + mcacDisabled := corev1.EnvVar{Name: "MGMT_API_DISABLE_MCAC", Value: "true"} + assert.True(envVarsContains(containers[0].Env, mcacDisabled)) +} diff --git a/tests/testdata/default-single-rack-single-node-dc-with-readonly-fs.yaml b/tests/testdata/default-single-rack-single-node-dc-with-readonly-fs.yaml index 8a734a74..6dae5e3d 100644 --- a/tests/testdata/default-single-rack-single-node-dc-with-readonly-fs.yaml +++ b/tests/testdata/default-single-rack-single-node-dc-with-readonly-fs.yaml @@ -5,8 +5,7 @@ metadata: spec: clusterName: cluster1 serverType: cassandra - serverVersion: "4.1.5" - serverImage: michaelburman290/cass-management-api:4.1.5-ubi8 + serverVersion: 4.1.6 managementApiAuth: insecure: {} readOnlyRootFilesystem: true