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

feat(my.cnf): support to set bool config in my.cnf #765

Open
wants to merge 1 commit into
base: main
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
9 changes: 9 additions & 0 deletions api/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ type MysqlOpts struct {
// +optional
MysqlConf MysqlConf `json:"mysqlConf,omitempty"`

// A []string that will be passed to my.cnf file
// The string array is persisted in the configmap.
// Delete key is not valid, it is recommended to edit the configmap directly.
// +optional
MysqlBoolConf MysqlBoolConfig `json:"mysqlBoolConf,omitempty"`

// A map[string]string that will be passed to plugin.cnf file.
// The key/value pairs is persisted in the configmap.
// Delete key is not valid, it is recommended to edit the configmap directly.
Expand Down Expand Up @@ -234,6 +240,9 @@ type MetricsOpts struct {
// string and string.
type MysqlConf map[string]string

// MysqlBoolConfig defines type for extra cluster bool configs. It's a string array.
type MysqlBoolConfig []string

// PodPolicy defines the general configuration and extra resources of pod.
type PodPolicy struct {
// +kubebuilder:validation:Enum=Always;IfNotPresent;Never
Expand Down
24 changes: 24 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions config/crd/bases/mysql.radondb.com_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ spec:
the mysqld container will not be not healthy.
minimum: 0
type: integer
mysqlBoolConf:
description: A []string that will be passed to my.cnf file The
string array is persisted in the configmap. Delete key is not
valid, it is recommended to edit the configmap directly.
items:
type: string
type: array
mysqlConf:
additionalProperties:
type: string
Expand Down
7 changes: 7 additions & 0 deletions mysqlcluster/syncer/mysql_cm.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ func buildMysqlConf(c *mysqlcluster.MysqlCluster) (string, error) {
log.Error(err, "failed to add boolean key to config section", "key", key)
}
}
if len(c.Spec.MysqlOpts.MysqlBoolConf) != 0 {
for _, key := range c.Spec.MysqlOpts.MysqlBoolConf {
if _, err := sec.NewBooleanKey(key); err != nil {
log.Error(err, "failed to add boolean key to config section", "key", key)
}
}
}
if len(c.Spec.TlsSecretName) != 0 {
addKVConfigsToSection(sec, mysqlSSLConfigs)
}
Expand Down