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

Add support for Cassandra 4.0 beta images #378

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .github/workflows/kindIntegTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
integration_test:
- smoke_test_dse
- smoke_test_oss
- smoke_test_4x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea

# let other tests continue to run
# even if one fails
fail-fast: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6035,7 +6035,7 @@ spec:
serverVersion:
description: Version string for config builder, used to generate Cassandra
server configuration
pattern: (6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+)
pattern: (6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+)|(4\.0-beta\d+)
type: string
serviceAccount:
description: The k8s service account to use for the server pods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6047,7 +6047,7 @@ spec:
serverVersion:
description: Version string for config builder, used to generate Cassandra
server configuration
pattern: (6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+)
pattern: (6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+)|(4\.0-beta\d+)
type: string
serviceAccount:
description: The k8s service account to use for the server pods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,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\.0\.\d+)
// +kubebuilder:validation:Pattern=(6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+)|(4\.0-beta\d+)
ServerVersion string `json:"serverVersion"`

// Cassandra server image name.
Expand Down
26 changes: 26 additions & 0 deletions operator/pkg/apis/cassandra/v1beta1/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,32 @@ func Test_ValidateSingleDatacenter(t *testing.T) {
},
errString: "",
},
{
name: "Cassandra invalid",
dc: &CassandraDatacenter{
ObjectMeta: metav1.ObjectMeta{
Name: "exampleDC",
},
Spec: CassandraDatacenterSpec{
ServerType: "cassandra",
ServerVersion: "4.0-beta",
},
},
errString: "use unsupported Cassandra version '4.0-beta'",
},
{
name: "Cassandra valid",
dc: &CassandraDatacenter{
ObjectMeta: metav1.ObjectMeta{
Name: "exampleDC",
},
Spec: CassandraDatacenterSpec{
ServerType: "cassandra",
ServerVersion: "4.0-beta4",
},
},
errString: "",
},
{
name: "Cassandra Invalid",
dc: &CassandraDatacenter{
Expand Down
2 changes: 1 addition & 1 deletion operator/pkg/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
envDefaultRegistryOverridePullSecrets = "DEFAULT_CONTAINER_REGISTRY_OVERRIDE_PULL_SECRETS"
EnvBaseImageOS = "BASE_IMAGE_OS"
ValidDseVersionRegexp = "6\\.8\\.\\d+"
ValidOssVersionRegexp = "(3\\.11\\.\\d+)|(4\\.0\\.\\d+)"
ValidOssVersionRegexp = "(3\\.11\\.\\d+)|(4\\.0\\.\\d+)|(4\\.0-beta\\d+)"
UbiImageSuffix = "-ubi7"
)

Expand Down
41 changes: 41 additions & 0 deletions operator/pkg/images/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,44 @@ func Test_CalculateDockerImageRunsAsCassandra(t *testing.T) {
assert.Equal(t, got, tt.want, fmt.Sprintf("Version: %s should not have returned %v", tt.version, got))
}
}

func Test_IsOssVersionSupported(t *testing.T) {
tests := []struct {
version string
expected bool
}{
{
version: "3.11.6",
expected: true,
},
{
version: "3.11.10",
expected: true,
},
{
version: "3.0.23",
expected: false,
},
{
version: "4.0.0",
expected: true,
},
{
version: "4.0.1",
expected: true,
},
{
version: "4.0-beta4",
expected: true,
},
{
version: "4.1.0",
expected: false,
},
}
for _, tt := range tests {
supported := IsOssVersionSupported(tt.version)

assert.Equal(t, supported, tt.expected, fmt.Sprintf("Version: %s should not have returned supported=%v", tt.version, supported))
}
}
97 changes: 97 additions & 0 deletions tests/smoke_test_4x/smoke_test_4x_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright DataStax, Inc.
// Please see the included license file for details.

package smoke_test_4x

import (
"fmt"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

ginkgo_util "github.com/datastax/cass-operator/mage/ginkgo"
"github.com/datastax/cass-operator/mage/kubectl"
)

var (
testName = "Smoke test of basic functionality for one-node OSS Cassandra 4.x cluster."
namespace = "test-smoke-test-4x"
dcName = "dc2"
dcYaml = "../testdata/smoke-test-4x.yaml"
operatorYaml = "../testdata/operator.yaml"
dcResource = fmt.Sprintf("CassandraDatacenter/%s", dcName)
dcLabel = fmt.Sprintf("cassandra.datastax.com/datacenter=%s", dcName)
ns = ginkgo_util.NewWrapper(testName, namespace)
)

func TestLifecycle(t *testing.T) {
AfterSuite(func() {
logPath := fmt.Sprintf("%s/aftersuite", ns.LogDir)
kubectl.DumpAllLogs(logPath).ExecV()
fmt.Printf("\n\tPost-run logs dumped at: %s\n\n", logPath)
ns.Terminate()
})

RegisterFailHandler(Fail)
RunSpecs(t, testName)
}

var _ = Describe(testName, func() {
Context("when in a new cluster", func() {
Specify("the operator can stand up a one node cluster", func() {
By("creating a namespace")
err := kubectl.CreateNamespace(namespace).ExecV()
Expect(err).ToNot(HaveOccurred())

step := "setting up cass-operator resources via helm chart"
ns.HelmInstall("../../charts/cass-operator-chart")

step = "waiting for the operator to become ready"
json := "jsonpath={.items[0].status.containerStatuses[0].ready}"
k := kubectl.Get("pods").
WithLabel("name=cass-operator").
WithFlag("field-selector", "status.phase=Running").
FormatOutput(json)
ns.WaitForOutputAndLog(step, k, "true", 360)

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

ns.WaitForDatacenterReady(dcName)

step = "deleting the dc"
k = kubectl.DeleteFromFiles(dcYaml)
ns.ExecAndLog(step, k)

step = "checking that the dc no longer exists"
json = "jsonpath={.items}"
k = kubectl.Get("CassandraDatacenter").
WithLabel(dcLabel).
FormatOutput(json)
ns.WaitForOutputAndLog(step, k, "[]", 600)

step = "checking that no dc pods remain"
json = "jsonpath={.items}"
k = kubectl.Get("pods").
WithLabel(dcLabel).
FormatOutput(json)
ns.WaitForOutputAndLog(step, k, "[]", 600)

step = "checking that no dc services remain"
json = "jsonpath={.items}"
k = kubectl.Get("services").
WithLabel(dcLabel).
FormatOutput(json)
ns.WaitForOutputAndLog(step, k, "[]", 600)

step = "checking that no dc stateful sets remain"
json = "jsonpath={.items}"
k = kubectl.Get("statefulsets").
WithLabel(dcLabel).
FormatOutput(json)
ns.WaitForOutputAndLog(step, k, "[]", 600)
})
})
})
26 changes: 26 additions & 0 deletions tests/testdata/smoke-test-4x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: cassandra.datastax.com/v1beta1
kind: CassandraDatacenter
metadata:
name: dc2
spec:
clusterName: cluster2
serverType: cassandra
serverVersion: "4.0-beta4"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will the config builder accept this string?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That I'm not sure. I'll check it out and see.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my initial testing it does not appear that changes are needed in the config builder.

For reference I am testing with this k8ssandra branch k8ssandra/k8ssandra#336. The medusa image changes have not been merged yet, so I built the medusa image from source my branch here https://github.com/jsanda/cassandra-medusa/tree/reduce_docker_filesize.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My cassandra pods are in the ready state but there are some problems. Here is what happened when I tried to run nodetool status:

$ kubectl exec -it test-dc1-default-sts-0 -c cassandra -- nodetool -u 3jFWL5YitK -pw SsOuaP8rV7hYGHJzdY59 version
grep: /opt/cassandra/conf/jvm-clients.options: No such file or directory
grep: /opt/cassandra/conf/jvm11-clients.options: No such file or directory
00:55:31,618 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-tools.xml]
00:55:31,619 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
00:55:31,621 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
00:55:31,622 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/etc/cassandra/logback.xml]
00:55:31,787 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
00:55:31,799 |-INFO in ch.qos.logback.classic.joran.action.JMXConfiguratorAction - begin
00:55:31,970 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
00:55:31,981 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [SYSTEMLOG]
00:55:32,005 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@2805d709 - Will use zip compression
00:55:32,066 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
00:55:32,087 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[SYSTEMLOG] - Active log file name: cassandra.logdir_IS_UNDEFINED/system.log
00:55:32,087 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[SYSTEMLOG] - File property is set to [cassandra.logdir_IS_UNDEFINED/system.log]
00:55:32,089 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[SYSTEMLOG] - Failed to create parent directories for [/cassandra.logdir_IS_UNDEFINED/system.log]
00:55:32,089 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[SYSTEMLOG] - openFile(cassandra.logdir_IS_UNDEFINED/system.log,true) call failed. java.io.FileNotFoundException: cassandra.logdir_IS_UNDEFINED/system.log (No such file or directory)
	at java.io.FileNotFoundException: cassandra.logdir_IS_UNDEFINED/system.log (No such file or directory)
	at 	at java.base/java.io.FileOutputStream.open0(Native Method)
	at 	at java.base/java.io.FileOutputStream.open(Unknown Source)
	at 	at java.base/java.io.FileOutputStream.<init>(Unknown Source)
	at 	at ch.qos.logback.core.recovery.ResilientFileOutputStream.<init>(ResilientFileOutputStream.java:26)
	at 	at ch.qos.logback.core.FileAppender.openFile(FileAppender.java:204)
	at 	at ch.qos.logback.core.FileAppender.start(FileAppender.java:127)
	at 	at ch.qos.logback.core.rolling.RollingFileAppender.start(RollingFileAppender.java:100)
	at 	at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
	at 	at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
	at 	at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
	at 	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
	at 	at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
	at 	at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
	at 	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
	at 	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
	at 	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
	at 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
	at 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
	at 	at org.apache.cassandra.utils.FBUtilities.<clinit>(FBUtilities.java:81)
	at 	at org.apache.cassandra.tools.NodeTool.<clinit>(NodeTool.java:74)
00:55:32,089 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
00:55:32,089 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DEBUGLOG]
00:55:32,090 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@194bcebf - Will use zip compression
00:55:32,091 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
00:55:32,092 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[DEBUGLOG] - Active log file name: cassandra.logdir_IS_UNDEFINED/debug.log
00:55:32,092 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[DEBUGLOG] - File property is set to [cassandra.logdir_IS_UNDEFINED/debug.log]
00:55:32,092 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[DEBUGLOG] - Failed to create parent directories for [/cassandra.logdir_IS_UNDEFINED/debug.log]
00:55:32,092 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[DEBUGLOG] - openFile(cassandra.logdir_IS_UNDEFINED/debug.log,true) call failed. java.io.FileNotFoundException: cassandra.logdir_IS_UNDEFINED/debug.log (No such file or directory)
	at java.io.FileNotFoundException: cassandra.logdir_IS_UNDEFINED/debug.log (No such file or directory)
	at 	at java.base/java.io.FileOutputStream.open0(Native Method)
	at 	at java.base/java.io.FileOutputStream.open(Unknown Source)
	at 	at java.base/java.io.FileOutputStream.<init>(Unknown Source)
	at 	at ch.qos.logback.core.recovery.ResilientFileOutputStream.<init>(ResilientFileOutputStream.java:26)
	at 	at ch.qos.logback.core.FileAppender.openFile(FileAppender.java:204)
	at 	at ch.qos.logback.core.FileAppender.start(FileAppender.java:127)
	at 	at ch.qos.logback.core.rolling.RollingFileAppender.start(RollingFileAppender.java:100)
	at 	at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
	at 	at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
	at 	at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
	at 	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
	at 	at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
	at 	at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
	at 	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
	at 	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
	at 	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
	at 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
	at 	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
	at 	at org.apache.cassandra.utils.FBUtilities.<clinit>(FBUtilities.java:81)
	at 	at org.apache.cassandra.tools.NodeTool.<clinit>(NodeTool.java:74)

@jimdickinson do you think this is config builder related?

serverImage: "datastax/cassandra-mgmtapi-4_0_0:v0.1.20"
managementApiAuth:
insecure: {}
size: 1
storageConfig:
cassandraDataVolumeClaimSpec:
storageClassName: server-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 250Mi
racks:
- name: r1
config:
jvm-server-options:
initial_heap_size: "800m"
max_heap_size: "800m"