Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run only DSE read_only_fs tests #707

Merged
merged 8 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions pkg/reconciliation/construct_podtemplatespec.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,29 @@ func buildInitContainers(dc *api.CassandraDatacenter, rackName string, baseTempl
}

configContainer.VolumeMounts = []corev1.VolumeMount{configBaseMount}
} else if !dc.UseClientImage() && dc.ReadOnlyFs() && dc.Spec.ServerType == "dse" {
// Similar to k8ssandra 1.x, use config-container if we use k8ssandra-client to build configs
if configContainerIndex < 0 {
configContainer = &corev1.Container{
Name: ServerBaseConfigContainerName,
}
}

if configContainer.Image == "" {
serverImage, err := makeImage(dc)
if err != nil {
return err
}

configContainer.Image = serverImage
if images.GetImageConfig() != nil && images.GetImageConfig().ImagePullPolicy != "" {
configContainer.ImagePullPolicy = images.GetImageConfig().ImagePullPolicy
}

configContainer.Command = []string{"/bin/sh"}
configContainer.Args = []string{"-c", "cp -rf /opt/dse/resources/cassandra/conf/* /config/"}
}
configContainer.VolumeMounts = combineVolumeMountSlices(configMounts, configContainer.VolumeMounts)
}

serverCfg.VolumeMounts = combineVolumeMountSlices(configMounts, serverCfg.VolumeMounts)
Expand Down Expand Up @@ -555,6 +578,9 @@ func buildInitContainers(dc *api.CassandraDatacenter, rackName string, baseTempl
} else {
baseTemplate.Spec.InitContainers = append(baseTemplate.Spec.InitContainers, *configContainer)
}
} else if !dc.UseClientImage() && configContainerIndex < 0 && dc.ReadOnlyFs() && dc.Spec.ServerType == "dse" {
// Workaround for cass-config-builder, copy missing files before cass-config-builder processes anything
baseTemplate.Spec.InitContainers = append([]corev1.Container{*configContainer}, baseTemplate.Spec.InitContainers...)
}

if serverContainerIndex < 0 {
Expand Down
13 changes: 11 additions & 2 deletions pkg/reconciliation/construct_podtemplatespec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2145,8 +2145,9 @@ func TestReadOnlyRootFilesystemVolumeChangesDSE(t *testing.T) {
assert.NotNil(initContainers, "No init containers were found")
assert.NoError(err, "Unexpected error encountered")

assert.Len(initContainers, 1, "Unexpected number of init containers returned")
assert.Equal(ServerConfigContainerName, initContainers[0].Name)
assert.Len(initContainers, 2, "Unexpected number of init containers returned")
assert.Equal(ServerBaseConfigContainerName, initContainers[0].Name)
assert.Equal(ServerConfigContainerName, initContainers[1].Name)

assert.True(reflect.DeepEqual(initContainers[0].VolumeMounts,
[]corev1.VolumeMount{
Expand All @@ -2156,6 +2157,14 @@ func TestReadOnlyRootFilesystemVolumeChangesDSE(t *testing.T) {
},
}), fmt.Sprintf("Unexpected volume mounts for the base config container: %v", initContainers[0].VolumeMounts))

assert.True(reflect.DeepEqual(initContainers[1].VolumeMounts,
[]corev1.VolumeMount{
{
Name: "server-config",
MountPath: "/config",
},
}), fmt.Sprintf("Unexpected volume mounts for the base config container: %v", initContainers[0].VolumeMounts))

containers := podTemplateSpec.Spec.Containers
assert.NotNil(containers, "No containers were found")
assert.NoError(err, "Unexpected error encountered")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ var _ = Describe(testName, func() {
ns.WaitForOutputAndLog(step, k, "true", 360)

step = "creating a datacenter resource with 1 rack/1 node"
k = kubectl.ApplyFiles(dcYaml)

testFile, err := ginkgo_util.CreateTestFile(dcYaml)
Expect(err).ToNot(HaveOccurred())
k = kubectl.ApplyFiles(testFile)
ns.ExecAndLog(step, k)

ns.WaitForDatacenterReady(dcName)
ns.WaitForDatacenterReadyWithTimeouts(dcName, 360, 360)
ns.ExpectDoneReconciling(dcName)

step = "deleting the dc"
Expand Down
Loading