From 8026d3687ee6eb783743ea5481ee51e69e284e1c Mon Sep 17 00:00:00 2001 From: Jim Dickinson Date: Fri, 26 Jun 2020 16:31:51 -0400 Subject: [PATCH] Add DSE 6.8.1 support, and update to config-builder 1.0.1 (#139) * Add DSE 6.8.1 support * Updating unit tests for 6.8.1 * Docs and examples * Update int tests * update buildsettings.yaml * Ran operator:sdkGenerate * Fix typo * always load build settings when ensuring empty cluster * Bump config builder to 1.0.1 * fix * Clean up the lowest level of checking output in tests * Remove an arg from these call sites * 6.8.0 -> 6.8.x * Fix a couple references to the moved files Co-authored-by: Chris Mills --- buildsettings.yaml | 4 +-- .../templates/customresourcedefinition.yaml | 1 + docs/developer/k8s_targets.md | 2 +- docs/user/README.md | 6 ++-- mage/k8s/lib.go | 5 +++- mage/kubectl/lib.go | 13 +++++---- ...datastax.com_cassandradatacenters_crd.yaml | 1 + .../example-cassdc-full.yaml | 2 +- .../example-cassdc-minimal.yaml | 2 +- .../example-cassdc-three-rack-three-node.yaml | 2 +- .../v1beta1/cassandradatacenter_types.go | 29 ++++++++++++------- .../v1beta1/cassandradatacenter_types_test.go | 10 +++++++ .../pkg/apis/cassandra/v1beta1/webhook.go | 28 ++++++++++++++---- .../apis/cassandra/v1beta1/webhook_test.go | 13 +++++++++ operator/pkg/reconciliation/testing.go | 2 +- ...-rack-2-node-dc-with-superuser-secret.yaml | 2 +- .../default-single-rack-2-node-dc.yaml | 2 +- .../default-single-rack-single-node-dc.yaml | 2 +- ...e-rack-single-node-extra-container-dc.yaml | 2 +- .../default-three-rack-three-node-dc.yaml | 2 +- tests/testdata/dse-one-node-dc-with-mtls.yaml | 2 +- .../oss-three-rack-three-node-dc.yaml | 1 - tests/testdata/oss-two-rack-six-node-dc.yaml | 1 - .../webhook_validation_suite_test.go | 2 +- 24 files changed, 95 insertions(+), 41 deletions(-) rename operator/example-cassdc-yaml/{dse-6.8.0 => dse-6.8.x}/example-cassdc-full.yaml (99%) rename operator/example-cassdc-yaml/{dse-6.8.0 => dse-6.8.x}/example-cassdc-minimal.yaml (96%) rename operator/example-cassdc-yaml/{dse-6.8.0 => dse-6.8.x}/example-cassdc-three-rack-three-node.yaml (98%) diff --git a/buildsettings.yaml b/buildsettings.yaml index eb04779fa..67cbfc661 100644 --- a/buildsettings.yaml +++ b/buildsettings.yaml @@ -17,6 +17,6 @@ jenkins: - simple-theme-plugin dev: images: - - datastax/dse-server:6.8.0 - - datastax/cass-config-builder:1.0.0 + - datastax/dse-server:6.8.1 + - datastax/cass-config-builder:1.0.1 - datastax/cassandra-mgmtapi-3_11_6:v0.1.5 diff --git a/charts/cass-operator-chart/templates/customresourcedefinition.yaml b/charts/cass-operator-chart/templates/customresourcedefinition.yaml index 5e14a0a43..2e4addbba 100644 --- a/charts/cass-operator-chart/templates/customresourcedefinition.yaml +++ b/charts/cass-operator-chart/templates/customresourcedefinition.yaml @@ -5956,6 +5956,7 @@ spec: server configuration enum: - 6.8.0 + - 6.8.1 - 3.11.6 - 4.0.0 type: string diff --git a/docs/developer/k8s_targets.md b/docs/developer/k8s_targets.md index ca48a3e68..fbb0135c3 100644 --- a/docs/developer/k8s_targets.md +++ b/docs/developer/k8s_targets.md @@ -75,7 +75,7 @@ operator/deploy/crds/cassandra.datastax.com_cassandradatacenters_crd.yaml, operator/deploy/operator.yaml, # if using dse -operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-minimal.yaml +operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-minimal.yaml # if using cassandra operator/example-cassdc-yaml/cassandra-3.11.6/example-cassdc-minimal.yaml diff --git a/docs/user/README.md b/docs/user/README.md index 8a36c780e..ce434030c 100644 --- a/docs/user/README.md +++ b/docs/user/README.md @@ -318,7 +318,7 @@ for your `CassandraDatacenter` resource, you can use the `serverType`, `serverVe spec properties. `serverType` is required and must be either `dse` or `cassandra`. `serverVersion` is also required, -and the supported version for DSE is `6.8.0` and for Cassandra it is `3.11.6`. More versions +and the supported versions for DSE are `6.8.0`/`6.8.1` and for Cassandra it is `3.11.6`. More versions will be supported in the future. If `serverImage` is not specified, a default image for the provided `serverType` and @@ -333,7 +333,7 @@ metadata: name: dtcntr spec: serverType: dse - serverVersion: 6.8.0 + serverVersion: 6.8.1 ``` @@ -359,7 +359,7 @@ metadata: name: dtcntr spec: serverType: dse - serverVersion: 6.8.0 + serverVersion: 6.8.1 serverImage: private-docker-registry.example.com/dse-img/dse:5f6e7d8c ``` diff --git a/mage/k8s/lib.go b/mage/k8s/lib.go index 8bb44e525..447a3b658 100644 --- a/mage/k8s/lib.go +++ b/mage/k8s/lib.go @@ -172,7 +172,7 @@ func SetupCassandraCluster() { func SetupDSECluster() { mg.Deps(SetupExampleCluster) kubectl.ApplyFiles( - "operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-minimal.yaml", + "operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-minimal.yaml", ).ExecVPanic() kubectl.WatchPods() } @@ -190,6 +190,9 @@ func EnsureEmptyCluster() { if !clusterActions.ClusterExists() { SetupEmptyCluster() } else { + // always load settings in case we have new images + // that an existing cluster is missing + loadSettings(*clusterActions) // make sure kubectl is pointing to our cluster clusterActions.SetupKubeconfig() // we should still ensure that the storage is set up diff --git a/mage/kubectl/lib.go b/mage/kubectl/lib.go index 35d3df701..f2e579a17 100644 --- a/mage/kubectl/lib.go +++ b/mage/kubectl/lib.go @@ -9,6 +9,7 @@ import ( "os/user" "regexp" "time" + "golang.org/x/crypto/ssh/terminal" shutil "github.com/datastax/cass-operator/mage/sh" @@ -206,7 +207,7 @@ func erasePreviousLine() { fmt.Print("\033[K") } -func waitForOutputPattern(k KCmd, pattern string, expected string, seconds int) error { +func waitForOutputPattern(k KCmd, pattern string, seconds int) error { re := regexp.MustCompile(pattern) c := make(chan string) timer := time.NewTimer(time.Duration(seconds) * time.Second) @@ -250,8 +251,8 @@ func waitForOutputPattern(k KCmd, pattern string, expected string, seconds int) select { case <-timer.C: var expectedPhrase string - expectedPhrase = "Expected to output to contain:" - msg := fmt.Sprintf("Timed out waiting for value. %s %s, but got %s.", expectedPhrase, expected, actual) + expectedPhrase = "Expected output to match regex: " + msg := fmt.Sprintf("Timed out waiting for value. %s '%s', but '%s' did not match", expectedPhrase, pattern, actual) if err != nil { msg = fmt.Sprintf("%s\nThe following error occured while querying k8s: %v", msg, err) } @@ -263,15 +264,15 @@ func waitForOutputPattern(k KCmd, pattern string, expected string, seconds int) } func WaitForOutputPattern(k KCmd, pattern string, seconds int) error { - return waitForOutputPattern(k, pattern, pattern, seconds) + return waitForOutputPattern(k, pattern, seconds) } func WaitForOutput(k KCmd, expected string, seconds int) error { - return waitForOutputPattern(k, fmt.Sprintf("^%s$", regexp.QuoteMeta(expected)), expected, seconds) + return waitForOutputPattern(k, fmt.Sprintf("^%s$", regexp.QuoteMeta(expected)), seconds) } func WaitForOutputContains(k KCmd, expected string, seconds int) error { - return waitForOutputPattern(k, regexp.QuoteMeta(expected), expected, seconds) + return waitForOutputPattern(k, regexp.QuoteMeta(expected), seconds) } func DumpAllLogs(path string) KCmd { diff --git a/operator/deploy/crds/cassandra.datastax.com_cassandradatacenters_crd.yaml b/operator/deploy/crds/cassandra.datastax.com_cassandradatacenters_crd.yaml index 68b4bca72..cb4447307 100644 --- a/operator/deploy/crds/cassandra.datastax.com_cassandradatacenters_crd.yaml +++ b/operator/deploy/crds/cassandra.datastax.com_cassandradatacenters_crd.yaml @@ -5946,6 +5946,7 @@ spec: server configuration enum: - 6.8.0 + - 6.8.1 - 3.11.6 - 4.0.0 type: string diff --git a/operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-full.yaml b/operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-full.yaml similarity index 99% rename from operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-full.yaml rename to operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-full.yaml index 8faf29f5f..349584236 100644 --- a/operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-full.yaml +++ b/operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-full.yaml @@ -79,7 +79,7 @@ spec: serverType: "dse" # Which server version to use. Required. - serverVersion: "6.8.0" + serverVersion: "6.8.1" # Use the serverImage configuration to override Cass Operator's logic to map # the serverType plus serverVersion into a public container image on Docker diff --git a/operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-minimal.yaml b/operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-minimal.yaml similarity index 96% rename from operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-minimal.yaml rename to operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-minimal.yaml index 748840386..c5ec2a014 100644 --- a/operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-minimal.yaml +++ b/operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-minimal.yaml @@ -7,7 +7,7 @@ metadata: spec: clusterName: cluster2 serverType: dse - serverVersion: "6.8.0" + serverVersion: "6.8.1" managementApiAuth: insecure: {} size: 3 diff --git a/operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-three-rack-three-node.yaml b/operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-three-rack-three-node.yaml similarity index 98% rename from operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-three-rack-three-node.yaml rename to operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-three-rack-three-node.yaml index aa765a959..a2da8e8bf 100644 --- a/operator/example-cassdc-yaml/dse-6.8.0/example-cassdc-three-rack-three-node.yaml +++ b/operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-three-rack-three-node.yaml @@ -7,7 +7,7 @@ metadata: spec: clusterName: cluster2 serverType: dse - serverVersion: "6.8.0" + serverVersion: "6.8.1" managementApiAuth: insecure: {} size: 3 diff --git a/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types.go b/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types.go index 85a8bd98c..cec4479e1 100644 --- a/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types.go +++ b/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types.go @@ -46,15 +46,20 @@ const ( type ProgressState string const ( - defaultConfigBuilderImage = "datastax/cass-config-builder:1.0.0" - cassandra_3_11_6 = "datastax/cassandra-mgmtapi-3_11_6:v0.1.5" - cassandra_4_0_0 = "datastax/cassandra-mgmtapi-4_0_0:v0.1.5" - dse_6_8_0 = "datastax/dse-server:6.8.0" - ubi_cassandra_3_11_6 = "datastax/cassandra:3.11.6-ubi7" - ubi_cassandra_4_0_0 = "datastax/cassandra:4.0-ubi7" - ubi_dse_6_8_0 = "datastax/dse-server:6.8.0-ubi7" - ubi_defaultConfigBuilderImage = "datastax/cass-config-builder:1.0.0-ubi7" - EnvBaseImageOs = "BASE_IMAGE_OS" + defaultConfigBuilderImage = "datastax/cass-config-builder:1.0.1" + ubi_defaultConfigBuilderImage = "datastax/cass-config-builder:1.0.1-ubi7" + + cassandra_3_11_6 = "datastax/cassandra-mgmtapi-3_11_6:v0.1.5" + cassandra_4_0_0 = "datastax/cassandra-mgmtapi-4_0_0:v0.1.5" + ubi_cassandra_3_11_6 = "datastax/cassandra:3.11.6-ubi7" + ubi_cassandra_4_0_0 = "datastax/cassandra:4.0-ubi7" + + dse_6_8_0 = "datastax/dse-server:6.8.0" + dse_6_8_1 = "datastax/dse-server:6.8.1" + ubi_dse_6_8_0 = "datastax/dse-server:6.8.0-ubi7" + ubi_dse_6_8_1 = "datastax/dse-server:6.8.1-ubi7" + + EnvBaseImageOs = "BASE_IMAGE_OS" ) // getImageForServerVersion tries to look up a known image for a server type and version number. @@ -91,6 +96,8 @@ func getImageForDefaultBaseOs(sv string) (string, bool) { switch sv { case "dse-6.8.0": return dse_6_8_0, true + case "dse-6.8.1": + return dse_6_8_1, true case "cassandra-3.11.6": return cassandra_3_11_6, true case "cassandra-4.0.0": @@ -103,6 +110,8 @@ func getImageForUniversalBaseOs(sv string) (string, bool) { switch sv { case "dse-6.8.0": return ubi_dse_6_8_0, true + case "dse-6.8.1": + return ubi_dse_6_8_1, true case "cassandra-3.11.6": return ubi_cassandra_3_11_6, true case "cassandra-4.0.0": @@ -129,7 +138,7 @@ type CassandraDatacenterSpec struct { // Version string for config builder, // used to generate Cassandra server configuration - // +kubebuilder:validation:Enum="6.8.0";"3.11.6";"4.0.0" + // +kubebuilder:validation:Enum="6.8.0";"6.8.1";"3.11.6";"4.0.0" ServerVersion string `json:"serverVersion"` // Cassandra server image name. diff --git a/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types_test.go b/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types_test.go index 1e726c097..23833680a 100644 --- a/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types_test.go +++ b/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types_test.go @@ -64,6 +64,16 @@ func Test_makeImage(t *testing.T) { want: "", errString: "server 'dse' and version '6.7.0' do not work together", }, + { + name: "test 6.8.1", + args: args{ + serverImage: "", + serverType: "dse", + serverVersion: "6.8.1", + }, + want: "datastax/dse-server:6.8.1", + errString: "", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/operator/pkg/apis/cassandra/v1beta1/webhook.go b/operator/pkg/apis/cassandra/v1beta1/webhook.go index da748d96b..05215328e 100644 --- a/operator/pkg/apis/cassandra/v1beta1/webhook.go +++ b/operator/pkg/apis/cassandra/v1beta1/webhook.go @@ -30,15 +30,33 @@ func attemptedTo(action string, actionStrArgs ...interface{}) error { func ValidateSingleDatacenter(dc CassandraDatacenter) error { // Ensure serverVersion and serverType are compatible - if dc.Spec.ServerType == "dse" && dc.Spec.ServerVersion != "6.8.0" { - return attemptedTo("use unsupported DSE version '%s'", dc.Spec.ServerVersion) + var err error + if dc.Spec.ServerType == "dse" { + switch dc.Spec.ServerVersion { + case "6.8.0": + err = nil + case "6.8.1": + err = nil + default: + err = attemptedTo("use unsupported DSE version '%s'", dc.Spec.ServerVersion) + } + } + if err != nil { + return err } - if dc.Spec.ServerType == "cassandra" && dc.Spec.ServerVersion != "3.11.6" && dc.Spec.ServerVersion != "4.0.0" { - return attemptedTo("use unsupported Cassandra version '%s'", dc.Spec.ServerVersion) + if dc.Spec.ServerType == "cassandra" { + switch dc.Spec.ServerVersion { + case "3.11.6": + err = nil + case "4.0.0": + err = nil + default: + err = attemptedTo("use unsupported Cassandra version '%s'", dc.Spec.ServerVersion) + } } - return nil + return err } // Ensure that no values are improperly set diff --git a/operator/pkg/apis/cassandra/v1beta1/webhook_test.go b/operator/pkg/apis/cassandra/v1beta1/webhook_test.go index 1d990770f..9365da929 100644 --- a/operator/pkg/apis/cassandra/v1beta1/webhook_test.go +++ b/operator/pkg/apis/cassandra/v1beta1/webhook_test.go @@ -32,6 +32,19 @@ func Test_ValidateSingleDatacenter(t *testing.T) { }, errString: "", }, + { + name: "Dse 6.8.1 Valid", + dc: &CassandraDatacenter{ + ObjectMeta: metav1.ObjectMeta{ + Name: "exampleDC", + }, + Spec: CassandraDatacenterSpec{ + ServerType: "dse", + ServerVersion: "6.8.1", + }, + }, + errString: "", + }, { name: "Dse Invalid", dc: &CassandraDatacenter{ diff --git a/operator/pkg/reconciliation/testing.go b/operator/pkg/reconciliation/testing.go index 819e62be7..ae146cb66 100644 --- a/operator/pkg/reconciliation/testing.go +++ b/operator/pkg/reconciliation/testing.go @@ -83,7 +83,7 @@ func CreateMockReconciliationContext( Size: size, ClusterName: clusterName, ServerType: "dse", - ServerVersion: "6.8.0", + ServerVersion: "6.8.1", StorageConfig: storageConfig, }, } diff --git a/tests/testdata/default-single-rack-2-node-dc-with-superuser-secret.yaml b/tests/testdata/default-single-rack-2-node-dc-with-superuser-secret.yaml index 380ff6418..fd4160e5c 100644 --- a/tests/testdata/default-single-rack-2-node-dc-with-superuser-secret.yaml +++ b/tests/testdata/default-single-rack-2-node-dc-with-superuser-secret.yaml @@ -5,7 +5,7 @@ metadata: spec: clusterName: cluster2 serverType: dse - serverVersion: "6.8.0" + serverVersion: "6.8.1" managementApiAuth: insecure: {} size: 2 diff --git a/tests/testdata/default-single-rack-2-node-dc.yaml b/tests/testdata/default-single-rack-2-node-dc.yaml index 8845f0b09..e48fe37b3 100644 --- a/tests/testdata/default-single-rack-2-node-dc.yaml +++ b/tests/testdata/default-single-rack-2-node-dc.yaml @@ -5,7 +5,7 @@ metadata: spec: clusterName: cluster2 serverType: dse - serverVersion: "6.8.0" + serverVersion: "6.8.1" managementApiAuth: insecure: {} size: 2 diff --git a/tests/testdata/default-single-rack-single-node-dc.yaml b/tests/testdata/default-single-rack-single-node-dc.yaml index ac3f9a016..64ebc7604 100644 --- a/tests/testdata/default-single-rack-single-node-dc.yaml +++ b/tests/testdata/default-single-rack-single-node-dc.yaml @@ -5,7 +5,7 @@ metadata: spec: clusterName: cluster2 serverType: dse - serverVersion: "6.8.0" + serverVersion: "6.8.1" managementApiAuth: insecure: {} size: 1 diff --git a/tests/testdata/default-single-rack-single-node-extra-container-dc.yaml b/tests/testdata/default-single-rack-single-node-extra-container-dc.yaml index a69677a9e..3720affa5 100644 --- a/tests/testdata/default-single-rack-single-node-extra-container-dc.yaml +++ b/tests/testdata/default-single-rack-single-node-extra-container-dc.yaml @@ -5,7 +5,7 @@ metadata: spec: clusterName: cluster2 serverType: dse - serverVersion: "6.8.0" + serverVersion: "6.8.1" managementApiAuth: insecure: {} size: 1 diff --git a/tests/testdata/default-three-rack-three-node-dc.yaml b/tests/testdata/default-three-rack-three-node-dc.yaml index bd5347626..3ca2c5b97 100644 --- a/tests/testdata/default-three-rack-three-node-dc.yaml +++ b/tests/testdata/default-three-rack-three-node-dc.yaml @@ -5,7 +5,7 @@ metadata: spec: clusterName: cluster1 serverType: dse - serverVersion: "6.8.0" + serverVersion: "6.8.1" managementApiAuth: insecure: {} size: 3 diff --git a/tests/testdata/dse-one-node-dc-with-mtls.yaml b/tests/testdata/dse-one-node-dc-with-mtls.yaml index 15c8737a1..85623692c 100644 --- a/tests/testdata/dse-one-node-dc-with-mtls.yaml +++ b/tests/testdata/dse-one-node-dc-with-mtls.yaml @@ -5,7 +5,7 @@ metadata: spec: clusterName: cluster1 serverType: dse - serverVersion: "6.8.0" + serverVersion: "6.8.1" managementApiAuth: manual: clientSecretName: mgmt-api-client-credentials diff --git a/tests/testdata/oss-three-rack-three-node-dc.yaml b/tests/testdata/oss-three-rack-three-node-dc.yaml index ae0467404..21d7562a4 100644 --- a/tests/testdata/oss-three-rack-three-node-dc.yaml +++ b/tests/testdata/oss-three-rack-three-node-dc.yaml @@ -7,7 +7,6 @@ spec: serverType: cassandra serverVersion: "3.11.6" serverImage: datastax/cassandra-mgmtapi-3_11_6:v0.1.5 - configBuilderImage: datastax/cass-config-builder:1.0.0 managementApiAuth: insecure: {} size: 3 diff --git a/tests/testdata/oss-two-rack-six-node-dc.yaml b/tests/testdata/oss-two-rack-six-node-dc.yaml index 0534e7be7..1b70999c8 100644 --- a/tests/testdata/oss-two-rack-six-node-dc.yaml +++ b/tests/testdata/oss-two-rack-six-node-dc.yaml @@ -7,7 +7,6 @@ spec: serverType: cassandra serverVersion: "3.11.6" serverImage: datastax/cassandra-mgmtapi-3_11_6:v0.1.5 - configBuilderImage: datastax/cass-config-builder:1.0.0 managementApiAuth: insecure: {} size: 6 diff --git a/tests/webhook_validation/webhook_validation_suite_test.go b/tests/webhook_validation/webhook_validation_suite_test.go index ec1821063..dfeae0238 100644 --- a/tests/webhook_validation/webhook_validation_suite_test.go +++ b/tests/webhook_validation/webhook_validation_suite_test.go @@ -77,7 +77,7 @@ var _ = Describe(testName, func() { json = "{\"spec\": {\"serverType\": \"dse\", \"serverVersion\": \"4.8.0\"}}" k = kubectl.PatchMerge(dcResource, json) ns.ExecAndLogAndExpectErrorString(step, k, - `spec.serverVersion: Unsupported value: "4.8.0": supported values: "6.8.0", "3.11.6", "4.0.0"`) + `spec.serverVersion: Unsupported value: "4.8.0": supported values: "6.8.0", "6.8.1", "3.11.6", "4.0.0"`) step = "attempt to change the dc name" json = "{\"spec\": {\"clusterName\": \"NewName\"}}" k = kubectl.PatchMerge(dcResource, json)