diff --git a/api/v1alpha1/mysqlcluster_types.go b/api/v1alpha1/mysqlcluster_types.go index 932a7e467..26821755c 100644 --- a/api/v1alpha1/mysqlcluster_types.go +++ b/api/v1alpha1/mysqlcluster_types.go @@ -31,7 +31,7 @@ type MysqlClusterSpec struct { // Replicas is the number of pods. // +optional - // +kubebuilder:validation:Enum=0;2;3;5 + // +kubebuilder:validation:Enum=0;1;2;3;5 // +kubebuilder:default:=3 Replicas *int32 `json:"replicas,omitempty"` diff --git a/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml b/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml index 88d891c56..2472051bd 100644 --- a/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml +++ b/charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml @@ -1259,6 +1259,7 @@ spec: description: Replicas is the number of pods. enum: - 0 + - 1 - 2 - 3 - 5 diff --git a/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml b/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml index 88d891c56..2472051bd 100644 --- a/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml +++ b/config/crd/bases/mysql.radondb.com_mysqlclusters.yaml @@ -1259,6 +1259,7 @@ spec: description: Replicas is the number of pods. enum: - 0 + - 1 - 2 - 3 - 5 diff --git a/mysqlcluster/container/xenon.go b/mysqlcluster/container/xenon.go index 37f520c50..e7bfd8aa9 100644 --- a/mysqlcluster/container/xenon.go +++ b/mysqlcluster/container/xenon.go @@ -43,7 +43,11 @@ func (c *xenon) getImage() string { // getCommand get the container command. func (c *xenon) getCommand() []string { - return nil + if *c.Spec.Replicas == 1 { + return []string{"xenon", "-c", "/etc/xenon/xenon.json", "-r", "LEADER"} + } + // If return nil, statefulset never update command , And I don't know why. + return []string{"xenon", "-c", "/etc/xenon/xenon.json"} } // getEnvVars get the container env. @@ -86,7 +90,7 @@ func (c *xenon) getLifecycle() *corev1.Lifecycle { Command: []string{ "/bin/bash", "-c", - "/xenonchecker preStop", + "timeout 7 /xenonchecker preStop", }, }, }, @@ -95,7 +99,7 @@ func (c *xenon) getLifecycle() *corev1.Lifecycle { Command: []string{ "/bin/bash", "-c", - "/xenonchecker postStart", + "timeout 7 /xenonchecker postStart", }, }, }, diff --git a/sidecar/config.go b/sidecar/config.go index e8b46d96a..a0c41a1f4 100644 --- a/sidecar/config.go +++ b/sidecar/config.go @@ -363,8 +363,8 @@ func (cfg *Config) buildXenonConf() []byte { "semi-sync-degrade": true, "purge-binlog-disabled": true, "super-idle": false, - "leader-start-command": "/xenonchecker leaderStart", - "leader-stop-command": "/xenonchecker leaderStop" + "leader-start-command": "timeout 7 /xenonchecker leaderStart", + "leader-stop-command": "timeout 7 /xenonchecker leaderStop" } } `, hostName, utils.XenonPort, hostName, utils.XenonPeerPort, cfg.ReplicationPassword, cfg.ReplicationUser,