From 8d3491914bf759bde292a1ce6462759386edf61e Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Thu, 30 May 2024 11:08:10 +0300 Subject: [PATCH] Add support for DSE 6.9 and HCD (#662) * Add support for DSE 6.9, remove DSE 7.0 and add support for HCD serverType * CHANGELOG * Fix error string assert in the webhook_validation_test * Change config pulling directory to /opt/hcd/resources/cassandra/conf/ for HCD * Add HCD_AUTO_CONF_OFF = all to env variables * Test all env vars for Cassandra, HCD and DSE * Change regexp error string again.. --- CHANGELOG.md | 2 + .../v1beta1/cassandradatacenter_types.go | 15 +++- .../v1beta1/cassandradatacenter_types_test.go | 10 +++ .../v1beta1/cassandradatacenter_webhook.go | 6 ++ apis/cassandra/v1beta1/webhook_test.go | 38 ++++++-- apis/config/v1beta1/imageconfig_types.go | 2 + apis/config/v1beta1/zz_generated.deepcopy.go | 1 + ...dra.datastax.com_cassandradatacenters.yaml | 5 +- config/manager/image_config.yaml | 5 +- pkg/images/images.go | 32 +++++-- pkg/images/images_test.go | 17 ++-- .../construct_podtemplatespec.go | 25 ++++-- .../construct_podtemplatespec_test.go | 88 ++++++++++++++++++- ...efault-single-rack-single-node-hcd-dc.yaml | 26 ++++++ .../webhook_validation_suite_test.go | 2 +- 15 files changed, 236 insertions(+), 38 deletions(-) create mode 100644 tests/testdata/default-single-rack-single-node-hcd-dc.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index ab6d64f5..086ecab0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Changelog for Cass Operator, new PRs should update the `main / unreleased` secti ## unreleased +* [FEATURE] [#659](https://github.com/k8ssandra/cass-operator/issues/659) Add support for HCD serverType with versions 1.x.x. It will be deployed like Cassandra >= 4.1 for now. +* [FEATURE] [#660](https://github.com/k8ssandra/cass-operator/issues/660) Add support for DSE version 6.9.x and remove support for DSE 7.x.x. DSE 6.9 will be deployed like DSE 6.8. * [BUGFIX] [#652](https://github.com/k8ssandra/cass-operator/issues/652) Update nodeStatuses info when a pod is recreated ## v1.20.0 diff --git a/apis/cassandra/v1beta1/cassandradatacenter_types.go b/apis/cassandra/v1beta1/cassandradatacenter_types.go index a47265f3..fc4a76c4 100644 --- a/apis/cassandra/v1beta1/cassandradatacenter_types.go +++ b/apis/cassandra/v1beta1/cassandradatacenter_types.go @@ -101,7 +101,7 @@ type CassandraDatacenterSpec struct { // Version string for config builder, // used to generate Cassandra server configuration - // +kubebuilder:validation:Pattern=(6\.8\.\d+)|(3\.11\.\d+)|(4\.\d+\.\d+)|(5\.\d+\.\d+)|(7\.\d+\.\d+) + // +kubebuilder:validation:Pattern=(6\.[89]\.\d+)|(3\.11\.\d+)|(4\.\d+\.\d+)|(5\.\d+\.\d+)|(1\.\d+\.\d+) ServerVersion string `json:"serverVersion"` // Cassandra server image name. Use of ImageConfig to match ServerVersion is recommended instead of this value. @@ -109,8 +109,8 @@ type CassandraDatacenterSpec struct { // More info: https://kubernetes.io/docs/concepts/containers/images ServerImage string `json:"serverImage,omitempty"` - // Server type: "cassandra" or "dse" - // +kubebuilder:validation:Enum=cassandra;dse + // Server type: "cassandra", "dse" or "hcd" + // +kubebuilder:validation:Enum=cassandra;dse;hcd ServerType string `json:"serverType"` // DEPRECATED This setting does nothing and defaults to true. Use SecurityContext instead. @@ -970,7 +970,14 @@ func (dc *CassandraDatacenter) DatacenterName() string { } func (dc *CassandraDatacenter) UseClientImage() bool { - return dc.Spec.ServerType == "cassandra" && semver.Compare(fmt.Sprintf("v%s", dc.Spec.ServerVersion), "v4.1.0") >= 0 + if dc.Spec.ServerType == "hcd" { + return true + } + + if dc.Spec.ServerType == "cassandra" && semver.Compare(fmt.Sprintf("v%s", dc.Spec.ServerVersion), "v4.1.0") >= 0 { + return true + } + return false } func (dc *CassandraDatacenter) GenerationChanged() bool { diff --git a/apis/cassandra/v1beta1/cassandradatacenter_types_test.go b/apis/cassandra/v1beta1/cassandradatacenter_types_test.go index b471a839..266897c2 100644 --- a/apis/cassandra/v1beta1/cassandradatacenter_types_test.go +++ b/apis/cassandra/v1beta1/cassandradatacenter_types_test.go @@ -93,6 +93,16 @@ func TestUseClientImage(t *testing.T) { version: "6.8.39", should: false, }, + { + serverType: "dse", + version: "6.9.0", + should: false, + }, + { + serverType: "hcd", + version: "1.0.0", + should: true, + }, { serverType: "dse", version: "4.1.2", diff --git a/apis/cassandra/v1beta1/cassandradatacenter_webhook.go b/apis/cassandra/v1beta1/cassandradatacenter_webhook.go index bacf3379..10a619d9 100644 --- a/apis/cassandra/v1beta1/cassandradatacenter_webhook.go +++ b/apis/cassandra/v1beta1/cassandradatacenter_webhook.go @@ -87,6 +87,12 @@ func ValidateSingleDatacenter(dc CassandraDatacenter) error { } } + if dc.Spec.ServerType == "hcd" { + if !images.IsHCDVersionSupported(dc.Spec.ServerVersion) { + return attemptedTo("use unsupported HCD version '%s'", dc.Spec.ServerVersion) + } + } + if dc.Spec.ServerType == "cassandra" && dc.Spec.DseWorkloads != nil { if dc.Spec.DseWorkloads.AnalyticsEnabled || dc.Spec.DseWorkloads.GraphEnabled || dc.Spec.DseWorkloads.SearchEnabled { return attemptedTo("enable DSE workloads if server type is Cassandra") diff --git a/apis/cassandra/v1beta1/webhook_test.go b/apis/cassandra/v1beta1/webhook_test.go index c7210ce1..dda14ef5 100644 --- a/apis/cassandra/v1beta1/webhook_test.go +++ b/apis/cassandra/v1beta1/webhook_test.go @@ -22,7 +22,7 @@ func Test_ValidateSingleDatacenter(t *testing.T) { errString string }{ { - name: "Dse Valid", + name: "DSE Valid", dc: &CassandraDatacenter{ ObjectMeta: metav1.ObjectMeta{ Name: "exampleDC", @@ -35,7 +35,7 @@ func Test_ValidateSingleDatacenter(t *testing.T) { errString: "", }, { - name: "Dse 6.8.4 Valid", + name: "DSE 6.8.4 Valid", dc: &CassandraDatacenter{ ObjectMeta: metav1.ObjectMeta{ Name: "exampleDC", @@ -48,20 +48,46 @@ func Test_ValidateSingleDatacenter(t *testing.T) { errString: "", }, { - name: "Dse 7.0.0 Valid", + name: "DSE 6.9.1 Valid", dc: &CassandraDatacenter{ ObjectMeta: metav1.ObjectMeta{ Name: "exampleDC", }, Spec: CassandraDatacenterSpec{ ServerType: "dse", - ServerVersion: "7.0.0", + ServerVersion: "6.9.1", + }, + }, + errString: "", + }, + { + name: "HCD 1.0.0 Valid", + dc: &CassandraDatacenter{ + ObjectMeta: metav1.ObjectMeta{ + Name: "exampleDC", + }, + Spec: CassandraDatacenterSpec{ + ServerType: "hcd", + ServerVersion: "1.0.0", }, }, errString: "", }, { - name: "Dse Invalid", + name: "DSE 7.0.0 invalid", + dc: &CassandraDatacenter{ + ObjectMeta: metav1.ObjectMeta{ + Name: "exampleDC", + }, + Spec: CassandraDatacenterSpec{ + ServerType: "dse", + ServerVersion: "7.0.0", + }, + }, + errString: "use unsupported DSE version '7.0.0'", + }, + { + name: "DSE Invalid", dc: &CassandraDatacenter{ ObjectMeta: metav1.ObjectMeta{ Name: "exampleDC", @@ -74,7 +100,7 @@ func Test_ValidateSingleDatacenter(t *testing.T) { errString: "use unsupported DSE version '4.8.0'", }, { - name: "Dse 5 Invalid", + name: "DSE 5 Invalid", dc: &CassandraDatacenter{ ObjectMeta: metav1.ObjectMeta{ Name: "exampleDC", diff --git a/apis/config/v1beta1/imageconfig_types.go b/apis/config/v1beta1/imageconfig_types.go index 3eeaba7e..3cdf6e20 100644 --- a/apis/config/v1beta1/imageconfig_types.go +++ b/apis/config/v1beta1/imageconfig_types.go @@ -65,6 +65,8 @@ type DefaultImages struct { CassandraImageComponent ImageComponent `json:"cassandra,omitempty"` DSEImageComponent ImageComponent `json:"dse,omitempty"` + + HCDImageComponent ImageComponent `json:"hcd,omitempty"` } type ImageComponent struct { diff --git a/apis/config/v1beta1/zz_generated.deepcopy.go b/apis/config/v1beta1/zz_generated.deepcopy.go index 271dbf74..516c6371 100644 --- a/apis/config/v1beta1/zz_generated.deepcopy.go +++ b/apis/config/v1beta1/zz_generated.deepcopy.go @@ -30,6 +30,7 @@ func (in *DefaultImages) DeepCopyInto(out *DefaultImages) { out.TypeMeta = in.TypeMeta out.CassandraImageComponent = in.CassandraImageComponent out.DSEImageComponent = in.DSEImageComponent + out.HCDImageComponent = in.HCDImageComponent } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DefaultImages. diff --git a/config/crd/bases/cassandra.datastax.com_cassandradatacenters.yaml b/config/crd/bases/cassandra.datastax.com_cassandradatacenters.yaml index 6e48424e..65605344 100644 --- a/config/crd/bases/cassandra.datastax.com_cassandradatacenters.yaml +++ b/config/crd/bases/cassandra.datastax.com_cassandradatacenters.yaml @@ -8887,16 +8887,17 @@ spec: More info: https://kubernetes.io/docs/concepts/containers/images type: string serverType: - description: 'Server type: "cassandra" or "dse"' + description: 'Server type: "cassandra", "dse" or "hcd"' enum: - cassandra - dse + - hcd type: string serverVersion: description: |- Version string for config builder, used to generate Cassandra server configuration - pattern: (6\.8\.\d+)|(3\.11\.\d+)|(4\.\d+\.\d+)|(5\.\d+\.\d+)|(7\.\d+\.\d+) + pattern: (6\.[89]\.\d+)|(3\.11\.\d+)|(4\.\d+\.\d+)|(5\.\d+\.\d+)|(1\.\d+\.\d+) type: string serviceAccount: description: Deprecated DeprecatedServiceAccount Use ServiceAccountName diff --git a/config/manager/image_config.yaml b/config/manager/image_config.yaml index 4e545ddf..c1c4bfe8 100644 --- a/config/manager/image_config.yaml +++ b/config/manager/image_config.yaml @@ -18,7 +18,10 @@ defaults: # Note, postfix is ignored if repository is not set cassandra: repository: "k8ssandra/cass-management-api" - # suffix: "-ubi8" + suffix: "-ubi8" dse: repository: "datastax/dse-mgmtapi-6_8" suffix: "-ubi8" + hcd: + repository: "datastax/hcd" + suffix: "-ubi" diff --git a/pkg/images/images.go b/pkg/images/images.go index 7297738b..c6e7f1c7 100644 --- a/pkg/images/images.go +++ b/pkg/images/images.go @@ -24,10 +24,12 @@ var ( ) const ( - ValidDseVersionRegexp = "(6\\.8\\.\\d+)|(7\\.\\d+\\.\\d+)" + ValidDseVersionRegexp = "(6\\.[89]\\.\\d+)" + ValidHcdVersionRegexp = "(1\\.\\d+\\.\\d+)" ValidOssVersionRegexp = "(3\\.11\\.\\d+)|(4\\.\\d+\\.\\d+)|(5\\.\\d+\\.\\d+)" DefaultCassandraRepository = "k8ssandra/cass-management-api" - DefaultDSERepository = "datastax/dse-server" + DefaultDSERepository = "datastax/dse-mgmtapi-6_8" + DefaultHCDRepository = "datastax/hcd" ) func init() { @@ -71,6 +73,11 @@ func IsOssVersionSupported(version string) bool { return validVersions.MatchString(version) } +func IsHCDVersionSupported(version string) bool { + validVersions := regexp.MustCompile(ValidHcdVersionRegexp) + return validVersions.MatchString(version) +} + func stripRegistry(image string) string { comps := strings.Split(image, "/") @@ -133,10 +140,14 @@ func getImageComponents(serverType string) (string, string) { defaults := GetImageConfig().DefaultImages if defaults != nil { var component configv1beta1.ImageComponent - if serverType == "dse" { + switch serverType { + case "dse": component = defaults.DSEImageComponent - } - if serverType == "cassandra" { + case "cassandra": + component = defaults.CassandraImageComponent + case "hcd": + component = defaults.HCDImageComponent + default: component = defaults.CassandraImageComponent } @@ -153,14 +164,21 @@ func GetCassandraImage(serverType, version string) (string, error) { return ApplyRegistry(image), nil } - if serverType == "dse" { + switch serverType { + case "dse": if !IsDseVersionSupported(version) { return "", fmt.Errorf("server 'dse' and version '%s' do not work together", version) } - } else { + case "cassandra": if !IsOssVersionSupported(version) { return "", fmt.Errorf("server 'cassandra' and version '%s' do not work together", version) } + case "hcd": + if !IsHCDVersionSupported(version) { + return "", fmt.Errorf("server 'hcd' and version '%s' do not work together", version) + } + default: + return "", fmt.Errorf("server type '%s' is not supported", serverType) } prefix, suffix := getImageComponents(serverType) diff --git a/pkg/images/images_test.go b/pkg/images/images_test.go index 228c93b5..13582e19 100644 --- a/pkg/images/images_test.go +++ b/pkg/images/images_test.go @@ -69,7 +69,6 @@ func TestCassandraOverride(t *testing.T) { } func TestDefaultImageConfigParsing(t *testing.T) { - t.Skip() assert := require.New(t) imageConfigFile := filepath.Join("..", "..", "config", "manager", "image_config.yaml") err := ParseImageConfig(imageConfigFile) @@ -80,14 +79,22 @@ func TestDefaultImageConfigParsing(t *testing.T) { assert.NotNil(GetImageConfig().Images) assert.True(strings.Contains(GetImageConfig().Images.SystemLogger, "k8ssandra/system-logger:")) assert.True(strings.Contains(GetImageConfig().Images.ConfigBuilder, "datastax/cass-config-builder:")) - assert.True(strings.Contains(GetImageConfig().Images.Client, "datastax/k8ssandra-client:")) + assert.True(strings.Contains(GetImageConfig().Images.Client, "k8ssandra/k8ssandra-client:")) assert.Equal("k8ssandra/cass-management-api", GetImageConfig().DefaultImages.CassandraImageComponent.Repository) assert.Equal("datastax/dse-mgmtapi-6_8", GetImageConfig().DefaultImages.DSEImageComponent.Repository) - path, err := GetCassandraImage("dse", "6.8.17") + path, err := GetCassandraImage("dse", "6.8.47") + assert.NoError(err) + assert.Equal("datastax/dse-mgmtapi-6_8:6.8.47-ubi8", path) + + path, err = GetCassandraImage("hcd", "1.0.0") + assert.NoError(err) + assert.Equal("datastax/hcd:1.0.0-ubi", path) + + path, err = GetCassandraImage("cassandra", "4.1.4") assert.NoError(err) - assert.Equal("datastax/dse-mgmtapi-6_8:6.8.17-ubi8", path) + assert.Equal("k8ssandra/cass-management-api:4.1.4-ubi8", path) } func TestImageConfigParsing(t *testing.T) { @@ -133,7 +140,7 @@ func TestDefaultRepositories(t *testing.T) { path, err = GetCassandraImage("dse", "6.8.17") assert.NoError(err) - assert.Equal("datastax/dse-server:6.8.17", path) + assert.Equal("datastax/dse-mgmtapi-6_8:6.8.17", path) } func TestOssValidVersions(t *testing.T) { diff --git a/pkg/reconciliation/construct_podtemplatespec.go b/pkg/reconciliation/construct_podtemplatespec.go index b4cbd50d..56e5397a 100644 --- a/pkg/reconciliation/construct_podtemplatespec.go +++ b/pkg/reconciliation/construct_podtemplatespec.go @@ -454,7 +454,11 @@ func buildInitContainers(dc *api.CassandraDatacenter, rackName string, baseTempl } configContainer.Command = []string{"/bin/sh"} - configContainer.Args = []string{"-c", "cp -rf /etc/cassandra/* /cassandra-base-config/"} + if dc.Spec.ServerType == "cassandra" { + configContainer.Args = []string{"-c", "cp -rf /etc/cassandra/* /cassandra-base-config/"} + } else if dc.Spec.ServerType == "hcd" { + configContainer.Args = []string{"-c", "cp -rf /opt/hcd/resources/cassandra/conf/* /cassandra-base-config/"} + } } configContainer.VolumeMounts = []corev1.VolumeMount{configBaseMount} @@ -631,17 +635,22 @@ func buildContainers(dc *api.CassandraDatacenter, baseTemplate *corev1.PodTempla {Name: "POD_NAME", ValueFrom: selectorFromFieldPath("metadata.name")}, {Name: "NODE_NAME", ValueFrom: selectorFromFieldPath("spec.nodeName")}, {Name: "DS_LICENSE", Value: "accept"}, - {Name: "DSE_AUTO_CONF_OFF", Value: "all"}, {Name: "USE_MGMT_API", Value: "true"}, {Name: "MGMT_API_EXPLICIT_START", Value: "true"}, - // TODO remove this post 1.0 - {Name: "DSE_MGMT_EXPLICIT_START", Value: "true"}, } - if dc.Spec.ServerType == "dse" && dc.Spec.DseWorkloads != nil { - envDefaults = append( - envDefaults, - corev1.EnvVar{Name: "JVM_EXTRA_OPTS", Value: getJvmExtraOpts(dc)}) + if dc.Spec.ServerType == "dse" { + envDefaults = append(envDefaults, corev1.EnvVar{Name: "DSE_AUTO_CONF_OFF", Value: "all"}) + envDefaults = append(envDefaults, corev1.EnvVar{Name: "DSE_MGMT_EXPLICIT_START", Value: "true"}) + if dc.Spec.DseWorkloads != nil { + envDefaults = append( + envDefaults, + corev1.EnvVar{Name: "JVM_EXTRA_OPTS", Value: getJvmExtraOpts(dc)}) + } + } + + if dc.Spec.ServerType == "hcd" { + envDefaults = append(envDefaults, corev1.EnvVar{Name: "HCD_AUTO_CONF_OFF", Value: "all"}) } cassContainer.Env = combineEnvSlices(envDefaults, cassContainer.Env) diff --git a/pkg/reconciliation/construct_podtemplatespec_test.go b/pkg/reconciliation/construct_podtemplatespec_test.go index 70db0e6a..f8926f7e 100644 --- a/pkg/reconciliation/construct_podtemplatespec_test.go +++ b/pkg/reconciliation/construct_podtemplatespec_test.go @@ -428,8 +428,11 @@ func TestServerConfigInitContainerEnvVars(t *testing.T) { } func TestCassandraContainerEnvVars(t *testing.T) { + assert := assert.New(t) podNameEnvVar := corev1.EnvVar{Name: "POD_NAME", ValueFrom: selectorFromFieldPath("metadata.name")} nodeNameEnvVar := corev1.EnvVar{Name: "NODE_NAME", ValueFrom: selectorFromFieldPath("spec.nodeName")} + useMgmtApiEnvVar := corev1.EnvVar{Name: "USE_MGMT_API", Value: "true"} + explicitStartEnvVar := corev1.EnvVar{Name: "MGMT_API_EXPLICIT_START", Value: "true"} templateSpec := &corev1.PodTemplateSpec{} dc := &api.CassandraDatacenter{ @@ -446,13 +449,90 @@ func TestCassandraContainerEnvVars(t *testing.T) { err := buildContainers(dc, templateSpec) require.NoError(t, err) - assert.Equal(t, 2, len(templateSpec.Spec.Containers), "expected to find 2 containers, cassandra and server-system-logger") + assert.Equal(2, len(templateSpec.Spec.Containers), "expected to find 2 containers, cassandra and server-system-logger") + + cassContainer := findContainer(templateSpec.Spec.Containers, CassandraContainerName) + assert.Equal(CassandraContainerName, cassContainer.Name) + + assert.True(envVarsContains(cassContainer.Env, podNameEnvVar)) + assert.True(envVarsContains(cassContainer.Env, nodeNameEnvVar)) + assert.True(envVarsContains(cassContainer.Env, nodeNameEnvVar)) + assert.True(envVarsContains(cassContainer.Env, useMgmtApiEnvVar)) + assert.True(envVarsContains(cassContainer.Env, explicitStartEnvVar)) +} + +func TestHCDContainerEnvVars(t *testing.T) { + assert := assert.New(t) + podNameEnvVar := corev1.EnvVar{Name: "POD_NAME", ValueFrom: selectorFromFieldPath("metadata.name")} + nodeNameEnvVar := corev1.EnvVar{Name: "NODE_NAME", ValueFrom: selectorFromFieldPath("spec.nodeName")} + useMgmtApiEnvVar := corev1.EnvVar{Name: "USE_MGMT_API", Value: "true"} + explicitStartEnvVar := corev1.EnvVar{Name: "MGMT_API_EXPLICIT_START", Value: "true"} + hcdAutoConf := corev1.EnvVar{Name: "HCD_AUTO_CONF_OFF", Value: "all"} + + templateSpec := &corev1.PodTemplateSpec{} + dc := &api.CassandraDatacenter{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test", + Name: "test", + }, + Spec: api.CassandraDatacenterSpec{ + ClusterName: "test", + ServerType: "hcd", + ServerVersion: "1.0.0", + }, + } + + err := buildContainers(dc, templateSpec) + require.NoError(t, err) + assert.Equal(2, len(templateSpec.Spec.Containers), "expected to find 2 containers, cassandra and server-system-logger") cassContainer := findContainer(templateSpec.Spec.Containers, CassandraContainerName) - assert.Equal(t, CassandraContainerName, cassContainer.Name) + assert.Equal(CassandraContainerName, cassContainer.Name) + + assert.True(envVarsContains(cassContainer.Env, podNameEnvVar)) + assert.True(envVarsContains(cassContainer.Env, nodeNameEnvVar)) + assert.True(envVarsContains(cassContainer.Env, nodeNameEnvVar)) + assert.True(envVarsContains(cassContainer.Env, useMgmtApiEnvVar)) + assert.True(envVarsContains(cassContainer.Env, explicitStartEnvVar)) + assert.True(envVarsContains(cassContainer.Env, hcdAutoConf)) +} + +func TestDSEContainerEnvVars(t *testing.T) { + assert := assert.New(t) + podNameEnvVar := corev1.EnvVar{Name: "POD_NAME", ValueFrom: selectorFromFieldPath("metadata.name")} + nodeNameEnvVar := corev1.EnvVar{Name: "NODE_NAME", ValueFrom: selectorFromFieldPath("spec.nodeName")} + useMgmtApiEnvVar := corev1.EnvVar{Name: "USE_MGMT_API", Value: "true"} + explicitStartEnvVar := corev1.EnvVar{Name: "MGMT_API_EXPLICIT_START", Value: "true"} + dseExplicitStartEnvVar := corev1.EnvVar{Name: "DSE_MGMT_EXPLICIT_START", Value: "true"} + dseAutoConf := corev1.EnvVar{Name: "DSE_AUTO_CONF_OFF", Value: "all"} - assert.True(t, envVarsContains(cassContainer.Env, podNameEnvVar)) - assert.True(t, envVarsContains(cassContainer.Env, nodeNameEnvVar)) + templateSpec := &corev1.PodTemplateSpec{} + dc := &api.CassandraDatacenter{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test", + Name: "test", + }, + Spec: api.CassandraDatacenterSpec{ + ClusterName: "test", + ServerType: "dse", + ServerVersion: "6.8.49", + }, + } + + err := buildContainers(dc, templateSpec) + require.NoError(t, err) + assert.Equal(2, len(templateSpec.Spec.Containers), "expected to find 2 containers, cassandra and server-system-logger") + + cassContainer := findContainer(templateSpec.Spec.Containers, CassandraContainerName) + assert.Equal(CassandraContainerName, cassContainer.Name) + + assert.True(envVarsContains(cassContainer.Env, podNameEnvVar)) + assert.True(envVarsContains(cassContainer.Env, nodeNameEnvVar)) + assert.True(envVarsContains(cassContainer.Env, nodeNameEnvVar)) + assert.True(envVarsContains(cassContainer.Env, useMgmtApiEnvVar)) + assert.True(envVarsContains(cassContainer.Env, explicitStartEnvVar)) + assert.True(envVarsContains(cassContainer.Env, dseAutoConf)) + assert.True(envVarsContains(cassContainer.Env, dseExplicitStartEnvVar)) } func TestLoggerContainerEnvVars(t *testing.T) { diff --git a/tests/testdata/default-single-rack-single-node-hcd-dc.yaml b/tests/testdata/default-single-rack-single-node-hcd-dc.yaml new file mode 100644 index 00000000..144ca2ac --- /dev/null +++ b/tests/testdata/default-single-rack-single-node-hcd-dc.yaml @@ -0,0 +1,26 @@ +apiVersion: cassandra.datastax.com/v1beta1 +kind: CassandraDatacenter +metadata: + name: dc2 +spec: + clusterName: cluster2 + serverType: hcd + serverVersion: "1.0.0" + serverImage: "datastax/hcd:1.0.0-early-preview-ubi" + managementApiAuth: + insecure: {} + size: 1 + storageConfig: + cassandraDataVolumeClaimSpec: + storageClassName: standard + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + racks: + - name: r1 + config: + jvm-server-options: + initial_heap_size: "512m" + max_heap_size: "512m" diff --git a/tests/webhook_validation/webhook_validation_suite_test.go b/tests/webhook_validation/webhook_validation_suite_test.go index 4912acfe..40f96473 100644 --- a/tests/webhook_validation/webhook_validation_suite_test.go +++ b/tests/webhook_validation/webhook_validation_suite_test.go @@ -85,7 +85,7 @@ var _ = Describe(testName, func() { json = "{\"spec\": {\"serverType\": \"dse\", \"serverVersion\": \"6.7.0\"}}" k = kubectl.PatchMerge(dcResource, json) ns.ExecAndLogAndExpectErrorString(step, k, - `spec.serverVersion: Invalid value: "6.7.0": spec.serverVersion in body should match '(6\.8\.\d+)|(3\.11\.\d+)|(4\.\d+\.\d+)|(5\.\d+\.\d+)|(7\.\d+\.\d+)'`) + `spec.serverVersion: Invalid value: "6.7.0": spec.serverVersion in body should match '(6\.[89]\.\d+)|(3\.11\.\d+)|(4\.\d+\.\d+)|(5\.\d+\.\d+)|(1\.\d+\.\d+)'`) step = "attempt to change the cluster name" json = "{\"spec\": {\"clusterName\": \"NewName\"}}" k = kubectl.PatchMerge(dcResource, json)