Skip to content

Commit

Permalink
Fix issues with JMX configuration
Browse files Browse the repository at this point in the history
* make all fields as strings, in other cases boolean values
  with "false" skipped as zero value.
* fix configuration name for jmx remote port
  • Loading branch information
gzimin committed Jan 28, 2025
1 parent ed5ce18 commit 5c9aec6
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 25 deletions.
16 changes: 8 additions & 8 deletions api/v2/cassandracluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,14 +822,14 @@ type CassandraClusterSpec struct {

// JMXConfiguration defines Cassandra JMX variables configuration
type JMXConfiguration struct {
// Flag to tell that JMX remote is enabled
// +kubebuilder:default:=false
JMXRemote bool `json:"jmxRemoteEnable,omitempty"`
// JMX Remote port number
// +kubebuilder:default:=7199
JMXRemotePort int `json:"jmxRemotePort,omitempty"`
JXMRemoteSSL bool `json:"jmxRemoteSSL,omitempty"`
JMXRemoteAuthenticate bool `json:"jmxRemoteAuthenticate,omitempty"`
// JMXRemote defines is JMX remote enabled
JMXRemote string `json:"jmxRemoteEnable,omitempty"`
// JMXRemotePort defines the Remote Method Invocation port for the JMX connection
JMXRemotePort string `json:"jmxRemotePort,omitempty"`
// JXMRemoteSSL defines is SSL for JMX connections enabled or not
JXMRemoteSSL string `json:"jmxRemoteSSL,omitempty"`
// JMXRemoteAuthenticate defines authentication for JMX remote connections
JMXRemoteAuthenticate string `json:"jmxRemoteAuthenticate,omitempty"`
}

// StorageConfig defines additional storage configurations
Expand Down
16 changes: 16 additions & 0 deletions charts/casskop/crds/db.orange.com_cassandraclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,22 @@ spec:
imagepullpolicy:
description: ImagePullPolicy define the pull policy for C* docker image
type: string
jmxConfiguration:
description: JMXConfiguration defines Cassandra JMX variables configuration
type: object
properties:
jmxRemoteAuthenticate:
description: JMXRemoteAuthenticate defines authentication for JMX remote connections
type: string
jmxRemoteEnable:
description: JMXRemote defines is JMX remote enabled
type: string
jmxRemotePort:
description: JMXRemotePort defines the Remote Method Invocation port for the JMX connection
type: string
jmxRemoteSSL:
description: JXMRemoteSSL defines is SSL for JMX connections enabled or not
type: string
keyspaceCleanupThreads:
description: |-
Number of jobs (threads) for keyspace cleanup command.
Expand Down
16 changes: 16 additions & 0 deletions charts/multi-casskop/crds/db.orange.com_cassandraclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,22 @@ spec:
imagepullpolicy:
description: ImagePullPolicy define the pull policy for C* docker image
type: string
jmxConfiguration:
description: JMXConfiguration defines Cassandra JMX variables configuration
type: object
properties:
jmxRemoteAuthenticate:
description: JMXRemoteAuthenticate defines authentication for JMX remote connections
type: string
jmxRemoteEnable:
description: JMXRemote defines is JMX remote enabled
type: string
jmxRemotePort:
description: JMXRemotePort defines the Remote Method Invocation port for the JMX connection
type: string
jmxRemoteSSL:
description: JXMRemoteSSL defines is SSL for JMX connections enabled or not
type: string
keyspaceCleanupThreads:
description: |-
Number of jobs (threads) for keyspace cleanup command.
Expand Down
16 changes: 8 additions & 8 deletions config/crd/bases/db.orange.com_cassandraclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,17 @@ spec:
type: object
properties:
jmxRemoteAuthenticate:
type: boolean
description: JMXRemoteAuthenticate defines authentication for JMX remote connections
type: string
jmxRemoteEnable:
description: Flag to tell that JMX remote is enabled
type: boolean
default: false
description: JMXRemote defines is JMX remote enabled
type: string
jmxRemotePort:
description: JMX Remote port number
type: integer
default: 7199
description: JMXRemotePort defines the Remote Method Invocation port for the JMX connection
type: string
jmxRemoteSSL:
type: boolean
description: JXMRemoteSSL defines is SSL for JMX connections enabled or not
type: string
keyspaceCleanupThreads:
description: |-
Number of jobs (threads) for keyspace cleanup command.
Expand Down
12 changes: 7 additions & 5 deletions controllers/cassandracluster/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const (
// Create a JMX Configuration map to convert values from CR to how they look like as env vars
var JMXConfigurationMap = map[string]string{
"JMXRemote": "-Dcom.sun.management.jmxremote=",
"JMXRemotePort": "-Dcom.sun.management.jmxremote.port=",
"JMXRemotePort": "-Dcom.sun.management.jmxremote.rmi.port=",
"JXMRemoteSSL": "-Dcom.sun.management.jmxremote.ssl=",
"JMXRemoteAuthenticate": "-Dcom.sun.management.jmxremote.authenticate=",
}
Expand Down Expand Up @@ -310,10 +310,12 @@ func generateJMXConfiguration(jmxConf api.JMXConfiguration) v1.EnvVar {
values := reflect.ValueOf(jmxConf)
types := reflect.TypeOf(jmxConf)
for i := 0; i < values.NumField(); i++ {
fieldName := types.Field(i).Name
fieldValue := values.Field(i).Interface()
param := JMXConfigurationMap[fieldName] + fmt.Sprintf("%v", fieldValue) + " "
jmxParam += param
fieldName := types.Field(i)
fieldValue := values.Field(i)
if fieldValue.String() != "" {
param := JMXConfigurationMap[fieldName.Name] + fieldValue.String() + " "
jmxParam += param
}
}
jmxEnvVar = v1.EnvVar{Name: jvmOptsName, Value: jmxParam}
return jmxEnvVar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ spec:
cassandraImage: cassandra:3.11.7
restartCountBeforePodDeletion: 3
jmxConfiguration:
jmxRemoteEnable: false
jmxRemotePort: 7199
jmxRemoteSSL: false
jmxRemoteAuthenticate: false
jmxRemoteEnable: "false"
jmxRemotePort: "7199"
jmxRemoteSSL: "false"
jmxRemoteAuthenticate: "false"
imagePullSecret:
name: advisedev # To authenticate on docker registry
rollingPartition: 0
Expand Down

0 comments on commit 5c9aec6

Please sign in to comment.