Skip to content

Commit

Permalink
Add DSE 6.8.1 support, and update to config-builder 1.0.1 (#139)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
jimdickinson and sandoichi authored Jun 26, 2020
1 parent 30ac85f commit 8026d36
Show file tree
Hide file tree
Showing 24 changed files with 95 additions and 41 deletions.
4 changes: 2 additions & 2 deletions buildsettings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -5956,6 +5956,7 @@ spec:
server configuration
enum:
- 6.8.0
- 6.8.1
- 3.11.6
- 4.0.0
type: string
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/k8s_targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/user/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -333,7 +333,7 @@ metadata:
name: dtcntr
spec:
serverType: dse
serverVersion: 6.8.0
serverVersion: 6.8.1

```

Expand All @@ -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
```
Expand Down
5 changes: 4 additions & 1 deletion mage/k8s/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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
Expand Down
13 changes: 7 additions & 6 deletions mage/kubectl/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os/user"
"regexp"
"time"

"golang.org/x/crypto/ssh/terminal"

shutil "github.com/datastax/cass-operator/mage/sh"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5946,6 +5946,7 @@ spec:
server configuration
enum:
- 6.8.0
- 6.8.1
- 3.11.6
- 4.0.0
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
clusterName: cluster2
serverType: dse
serverVersion: "6.8.0"
serverVersion: "6.8.1"
managementApiAuth:
insecure: {}
size: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
clusterName: cluster2
serverType: dse
serverVersion: "6.8.0"
serverVersion: "6.8.1"
managementApiAuth:
insecure: {}
size: 3
Expand Down
29 changes: 19 additions & 10 deletions operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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":
Expand All @@ -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":
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
28 changes: 23 additions & 5 deletions operator/pkg/apis/cassandra/v1beta1/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions operator/pkg/apis/cassandra/v1beta1/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion operator/pkg/reconciliation/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func CreateMockReconciliationContext(
Size: size,
ClusterName: clusterName,
ServerType: "dse",
ServerVersion: "6.8.0",
ServerVersion: "6.8.1",
StorageConfig: storageConfig,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterName: cluster2
serverType: dse
serverVersion: "6.8.0"
serverVersion: "6.8.1"
managementApiAuth:
insecure: {}
size: 2
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/default-single-rack-2-node-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterName: cluster2
serverType: dse
serverVersion: "6.8.0"
serverVersion: "6.8.1"
managementApiAuth:
insecure: {}
size: 2
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/default-single-rack-single-node-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterName: cluster2
serverType: dse
serverVersion: "6.8.0"
serverVersion: "6.8.1"
managementApiAuth:
insecure: {}
size: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterName: cluster2
serverType: dse
serverVersion: "6.8.0"
serverVersion: "6.8.1"
managementApiAuth:
insecure: {}
size: 1
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/default-three-rack-three-node-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterName: cluster1
serverType: dse
serverVersion: "6.8.0"
serverVersion: "6.8.1"
managementApiAuth:
insecure: {}
size: 3
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/dse-one-node-dc-with-mtls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/testdata/oss-three-rack-three-node-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/testdata/oss-two-rack-six-node-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/webhook_validation/webhook_validation_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8026d36

Please sign in to comment.