Skip to content

Commit 2ea88df

Browse files
egegunesgithub-actions[bot]hors
authored
K8SPS-283: Add HAProxy for group replication (#399)
* K8SPS-283: Add HAProxy for group replication * fix tests * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix endpoint if router and haproxy is both disabled * fix tests * don't use ERROR prefix for haproxy checks * enable mysql admin port * don't allow enabling proxies at the same time * cleanup proxy resources after it's disabled * add gr-haproxy test * fix tests * fix haproxy checks * fix tests * fix gr-haproxy * add custom config for haproxy * configure probes for haproxy * allow configuring env variables for components * address review comments * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * update k8s to 1.24 * fix haproxy entrypoint --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Viacheslav Sarzhan <[email protected]>
1 parent f9866f9 commit 2ea88df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2381
-303
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void createCluster(String CLUSTER_SUFFIX, String SUBNETWORK = CLUSTER_SUFFIX) {
1515
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
1616
gcloud config set project $GCP_PROJECT
1717
gcloud container clusters list --filter $CLUSTER_NAME-${CLUSTER_SUFFIX} --zone $GKERegion --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $GKERegion --quiet || true
18-
gcloud container clusters create --zone $GKERegion $CLUSTER_NAME-${CLUSTER_SUFFIX} --cluster-version=1.22 --machine-type=n1-standard-4 --preemptible --num-nodes=\$NODES_NUM --network=jenkins-ps-vpc --subnetwork=jenkins-ps-${SUBNETWORK} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 && \
18+
gcloud container clusters create --zone $GKERegion $CLUSTER_NAME-${CLUSTER_SUFFIX} --cluster-version=1.24 --machine-type=n1-standard-4 --preemptible --num-nodes=\$NODES_NUM --network=jenkins-ps-vpc --subnetwork=jenkins-ps-${SUBNETWORK} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 && \
1919
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user jenkins@"$GCP_PROJECT".iam.gserviceaccount.com || ret_val=\$?
2020
if [ \${ret_val} -eq 0 ]; then break; fi
2121
ret_num=\$((ret_num + 1))

api/v1alpha1/perconaservermysql_types.go

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ type MySQLSpec struct {
9393
SidecarVolumes []corev1.Volume `json:"sidecarVolumes,omitempty"`
9494
SidecarPVCs []SidecarPVC `json:"sidecarPVCs,omitempty"`
9595

96-
Configuration string `json:"configuration,omitempty"`
97-
9896
PodSpec `json:",inline"`
9997
}
10098

@@ -130,6 +128,9 @@ type ContainerSpec struct {
130128
LivenessProbe corev1.Probe `json:"livenessProbe,omitempty"`
131129

132130
ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
131+
132+
Env []corev1.EnvVar `json:"env,omitempty"`
133+
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
133134
}
134135

135136
type PodSpec struct {
@@ -150,6 +151,8 @@ type PodSpec struct {
150151
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
151152
ServiceAccountName string `json:"serviceAccountName,omitempty"`
152153

154+
Configuration string `json:"configuration,omitempty"`
155+
153156
ContainerSpec `json:",inline"`
154157
}
155158

@@ -268,9 +271,9 @@ type ProxySpec struct {
268271
}
269272

270273
type MySQLRouterSpec struct {
271-
Expose ServiceExpose `json:"expose,omitempty"`
274+
Enabled bool `json:"enabled,omitempty"`
272275

273-
Configuration string `json:"configuration,omitempty"`
276+
Expose ServiceExpose `json:"expose,omitempty"`
274277

275278
PodSpec `json:",inline"`
276279
}
@@ -280,8 +283,9 @@ type ToolkitSpec struct {
280283
}
281284

282285
type HAProxySpec struct {
283-
Enabled bool `json:"enabled,omitempty"`
284-
Expose ServiceExpose `json:"expose,omitempty"`
286+
Enabled bool `json:"enabled,omitempty"`
287+
288+
Expose ServiceExpose `json:"expose,omitempty"`
285289

286290
PodSpec `json:",inline"`
287291
}
@@ -517,6 +521,36 @@ func (cr *PerconaServerMySQL) CheckNSetDefaults(ctx context.Context, serverVersi
517521
cr.Spec.Proxy.Router.ReadinessProbe.TimeoutSeconds = 3
518522
}
519523

524+
if cr.Spec.Proxy.HAProxy == nil {
525+
cr.Spec.Proxy.HAProxy = new(HAProxySpec)
526+
}
527+
528+
if cr.Spec.Proxy.HAProxy.LivenessProbe.PeriodSeconds == 0 {
529+
cr.Spec.Proxy.HAProxy.LivenessProbe.PeriodSeconds = 5
530+
}
531+
if cr.Spec.Proxy.HAProxy.LivenessProbe.FailureThreshold == 0 {
532+
cr.Spec.Proxy.HAProxy.LivenessProbe.FailureThreshold = 3
533+
}
534+
if cr.Spec.Proxy.HAProxy.LivenessProbe.SuccessThreshold == 0 {
535+
cr.Spec.Proxy.HAProxy.LivenessProbe.SuccessThreshold = 1
536+
}
537+
if cr.Spec.Proxy.HAProxy.LivenessProbe.TimeoutSeconds == 0 {
538+
cr.Spec.Proxy.HAProxy.LivenessProbe.TimeoutSeconds = 3
539+
}
540+
541+
if cr.Spec.Proxy.HAProxy.ReadinessProbe.PeriodSeconds == 0 {
542+
cr.Spec.Proxy.HAProxy.ReadinessProbe.PeriodSeconds = 5
543+
}
544+
if cr.Spec.Proxy.HAProxy.ReadinessProbe.FailureThreshold == 0 {
545+
cr.Spec.Proxy.HAProxy.ReadinessProbe.FailureThreshold = 3
546+
}
547+
if cr.Spec.Proxy.HAProxy.ReadinessProbe.SuccessThreshold == 0 {
548+
cr.Spec.Proxy.HAProxy.ReadinessProbe.SuccessThreshold = 1
549+
}
550+
if cr.Spec.Proxy.HAProxy.ReadinessProbe.TimeoutSeconds == 0 {
551+
cr.Spec.Proxy.HAProxy.ReadinessProbe.TimeoutSeconds = 3
552+
}
553+
520554
var fsgroup *int64
521555
if serverVersion.Platform != platform.PlatformOpenshift {
522556
var tp int64 = 1001
@@ -574,7 +608,11 @@ func (cr *PerconaServerMySQL) CheckNSetDefaults(ctx context.Context, serverVersi
574608
}
575609
}
576610

577-
if cr.Spec.MySQL.ClusterType == ClusterTypeGR && cr.Spec.Proxy.Router != nil && !cr.Spec.AllowUnsafeConfig {
611+
if cr.RouterEnabled() && cr.HAProxyEnabled() {
612+
return errors.New("MySQL Router and HAProxy can't be enabled at the same time")
613+
}
614+
615+
if cr.RouterEnabled() && !cr.Spec.AllowUnsafeConfig {
578616
if cr.Spec.Proxy.Router.Size < MinSafeProxySize {
579617
cr.Spec.Proxy.Router.Size = MinSafeProxySize
580618
}
@@ -584,7 +622,7 @@ func (cr *PerconaServerMySQL) CheckNSetDefaults(ctx context.Context, serverVersi
584622
cr.Spec.Proxy.HAProxy = new(HAProxySpec)
585623
}
586624

587-
if cr.HAProxyEnabled() && cr.Spec.MySQL.ClusterType != ClusterTypeGR && !cr.Spec.AllowUnsafeConfig {
625+
if cr.HAProxyEnabled() && !cr.Spec.AllowUnsafeConfig {
588626
if cr.Spec.Proxy.HAProxy.Size < MinSafeProxySize {
589627
cr.Spec.Proxy.HAProxy.Size = MinSafeProxySize
590628
}
@@ -802,17 +840,31 @@ func (pmm *PMMSpec) HasSecret(secret *corev1.Secret) bool {
802840
return false
803841
}
804842

843+
func (cr *PerconaServerMySQL) RouterEnabled() bool {
844+
if cr.MySQLSpec().IsAsync() {
845+
return false
846+
}
847+
848+
return cr.Spec.Proxy.Router != nil && cr.Spec.Proxy.Router.Enabled
849+
}
850+
805851
func (cr *PerconaServerMySQL) HAProxyEnabled() bool {
806-
if !cr.Spec.AllowUnsafeConfig {
852+
if cr.MySQLSpec().IsAsync() && !cr.Spec.AllowUnsafeConfig {
807853
return true
808854
}
855+
809856
return cr.Spec.Proxy.HAProxy != nil && cr.Spec.Proxy.HAProxy.Enabled
810857
}
811858

812859
func (cr *PerconaServerMySQL) OrchestratorEnabled() bool {
813-
if !cr.Spec.AllowUnsafeConfig {
860+
if cr.MySQLSpec().IsGR() {
861+
return false
862+
}
863+
864+
if cr.MySQLSpec().IsAsync() && !cr.Spec.AllowUnsafeConfig {
814865
return true
815866
}
867+
816868
return cr.Spec.Orchestrator.Enabled
817869
}
818870

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/haproxy-entrypoint.sh

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,41 @@
33
set -e
44
set -o xtrace
55

6+
log() {
7+
local message=$1
8+
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N")
9+
10+
echo "{\"time\":\"${date}\", \"message\": \"${message}\"}"
11+
}
12+
13+
echo "${CLUSTER_TYPE}" >/tmp/cluster_type
14+
615
if [ "$1" = 'haproxy' ]; then
7-
if [ ! -f '/etc/haproxy/mysql/haproxy.cfg' ]; then
8-
cp /opt/percona/haproxy.cfg /etc/haproxy/mysql
9-
fi
16+
if [ ! -f '/etc/haproxy/mysql/haproxy.cfg' ]; then
17+
cp /opt/percona/haproxy.cfg /etc/haproxy/mysql
18+
fi
19+
20+
custom_conf='/etc/haproxy-custom/haproxy.cfg'
21+
if [ -f "$custom_conf" ]; then
22+
log "haproxy -c -f $custom_conf -f /etc/haproxy/mysql/haproxy.cfg"
23+
haproxy -c -f $custom_conf -f /etc/haproxy/mysql/haproxy.cfg || EC=$?
24+
if [ -n "$EC" ]; then
25+
log "The custom config $custom_conf is not valid and will be ignored."
26+
fi
27+
fi
28+
29+
haproxy_opt='-W -db '
30+
if [ -f "$custom_conf" -a -z "$EC" ]; then
31+
haproxy_opt+="-f $custom_conf "
32+
else
33+
haproxy_opt+='-f /opt/percona/haproxy-global.cfg '
34+
fi
35+
36+
haproxy_opt+='-f /etc/haproxy/mysql/haproxy.cfg -p /etc/haproxy/mysql/haproxy.pid -S /etc/haproxy/mysql/haproxy-main.sock'
1037

11-
haproxy_opt='-W -db -f /opt/percona/haproxy-global.cfg -f /etc/haproxy/mysql/haproxy.cfg -p /etc/haproxy/mysql/haproxy.pid -S /etc/haproxy/mysql/haproxy-main.sock'
38+
if [ -f '/etc/haproxy/config/haproxy.cfg' ]; then
39+
haproxy_opt="${haproxy_opt} -f /etc/haproxy/config/haproxy.cfg"
40+
fi
1241
fi
1342

1443
exec "$@" ${haproxy_opt}

build/haproxy-global.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
option clitcpka
2727
default_backend mysql-replicas
2828

29+
frontend mysqlx-in
30+
bind *:33060
31+
mode tcp
32+
option clitcpka
33+
default_backend mysql-primary
34+
35+
frontend mysql-admin-in
36+
bind *:33062
37+
mode tcp
38+
option clitcpka
39+
default_backend mysql-primary
40+
2941
frontend stats
3042
bind *:8404
3143
mode http

build/haproxy_check_primary.sh

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,63 @@
22

33
set -e
44

5+
log() {
6+
local level=$1
7+
local message=$2
8+
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N")
9+
10+
echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}"
11+
}
12+
513
MYSQL_SERVER_IP=$3
614
MYSQL_SERVER_PORT='33062'
715

816
MONITOR_USER='monitor'
917
MONITOR_PASSWORD=$(/bin/cat /etc/mysql/mysql-users-secret/monitor)
1018

11-
TIMEOUT=${CUSTOM_TIMEOUT:-10}
19+
TIMEOUT=${HA_CONNECTION_TIMEOUT:-10}
1220
MYSQL_CMDLINE="/usr/bin/timeout $TIMEOUT /usr/bin/mysql -nNE -u${MONITOR_USER} -h ${MYSQL_SERVER_IP} -P ${MYSQL_SERVER_PORT}"
1321

14-
READ_ONLY=$(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e 'select @@super_read_only' | /usr/bin/sed -n -e '2p' | /usr/bin/tr -d '\n')
22+
CLUSTER_TYPE=$(/bin/cat /tmp/cluster_type)
23+
24+
check_async() {
25+
READ_ONLY=$(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e 'select @@super_read_only' | /usr/bin/sed -n -e '2p' | /usr/bin/tr -d '\n')
26+
27+
# ${REPLICATION_STATUS[0]} - Replica_IO_Running
28+
# ${REPLICATION_STATUS[1]} - Replica_SQL_Running
29+
REPLICATION_STATUS=($(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e 'SHOW REPLICA STATUS' | /usr/bin/sed -n -e '12p' -e '13p' | /usr/bin/tr '\n' ' '))
30+
31+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} super_read_only: ${READ_ONLY} Replica_IO_Running: ${REPLICATION_STATUS[0]} Replica_SQL_Running: ${REPLICATION_STATUS[1]}"
32+
33+
if [[ ${READ_ONLY} == '0' ]] && [[ ${REPLICATION_STATUS[0]} != 'Yes' ]] && [[ ${REPLICATION_STATUS[1]} != 'Yes' ]]; then
34+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is OK"
35+
exit 0
36+
else
37+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is NOT OK"
38+
exit 1
39+
fi
40+
}
41+
42+
check_gr() {
43+
READ_ONLY=$(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e 'select @@super_read_only' | /usr/bin/sed -n -e '2p' | /usr/bin/tr -d '\n')
44+
APPLIER_STATUS=$(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e "SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name = 'group_replication_applier'" | /usr/bin/sed -n -e '2p' | /usr/bin/tr -d '\n')
1545

16-
# ${REPLICATION_STATUS[0]} - Replica_IO_Running
17-
# ${REPLICATION_STATUS[1]} - Replica_SQL_Running
18-
REPLICATION_STATUS=($(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e 'SHOW REPLICA STATUS' | /usr/bin/sed -n -e '12p' -e '13p' | /usr/bin/tr '\n' ' '))
46+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} @@super_read_only: ${READ_ONLY} Applier: ${APPLIER_STATUS}"
1947

20-
echo "MySQL node ${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT}"
21-
echo "read_only: ${READ_ONLY}"
22-
echo "Replica_IO_Running: ${REPLICATION_STATUS[0]}"
23-
echo "Replica_SQL_Running: ${REPLICATION_STATUS[1]}"
48+
if [[ ${READ_ONLY} == '0' ]] && [[ ${APPLIER_STATUS} == "ON" ]]; then
49+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is OK"
50+
exit 0
51+
else
52+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is NOT OK"
53+
exit 1
54+
fi
55+
}
2456

25-
if [[ ${READ_ONLY} == '0' ]] && [[ ${REPLICATION_STATUS[0]} != 'Yes' ]] && [[ ${REPLICATION_STATUS[1]} != 'Yes' ]]; then
26-
echo "MySQL node ${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is ok"
27-
exit 0
57+
if [[ ${CLUSTER_TYPE} == "async" ]]; then
58+
check_async
59+
elif [[ ${CLUSTER_TYPE} == "group-replication" ]]; then
60+
check_gr
2861
else
29-
echo "MySQL node ${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is not ok"
62+
log ERROR "Invalid cluster type: ${CLUSTER_TYPE}"
3063
exit 1
3164
fi

build/haproxy_check_replicas.sh

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
set -e
44

5+
log() {
6+
local level=$1
7+
local message=$2
8+
local date=$(/usr/bin/date +"%d/%b/%Y:%H:%M:%S.%3N")
9+
10+
echo "{\"time\":\"${date}\", \"level\": \"${level}\", \"message\": \"${message}\"}"
11+
}
12+
513
MYSQL_SERVER_IP=$3
614
MYSQL_SERVER_PORT='33062'
715

@@ -11,21 +19,46 @@ MONITOR_PASSWORD=$(/bin/cat /etc/mysql/mysql-users-secret/monitor)
1119
TIMEOUT=${CUSTOM_TIMEOUT:-10}
1220
MYSQL_CMDLINE="/usr/bin/timeout $TIMEOUT /usr/bin/mysql -nNE -u${MONITOR_USER} -h ${MYSQL_SERVER_IP} -P ${MYSQL_SERVER_PORT}"
1321

14-
READ_ONLY=$(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e 'select @@super_read_only' | /usr/bin/sed -n -e '2p' | /usr/bin/tr -d '\n')
22+
CLUSTER_TYPE=$(/bin/cat /tmp/cluster_type)
23+
24+
check_async() {
25+
READ_ONLY=$(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e 'select @@super_read_only' | /usr/bin/sed -n -e '2p' | /usr/bin/tr -d '\n')
26+
27+
# ${REPLICATION_STATUS[0]} - Replica_IO_Running
28+
# ${REPLICATION_STATUS[1]} - Replica_SQL_Running
29+
REPLICATION_STATUS=($(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e 'SHOW REPLICA STATUS' | /usr/bin/sed -n -e '12p' -e '13p' | /usr/bin/tr '\n' ' '))
30+
31+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} @@super_read_only: ${READ_ONLY} Replica_IO_Running: ${REPLICATION_STATUS[0]} Replica_SQL_Running: ${REPLICATION_STATUS[1]}"
32+
33+
if [[ ${READ_ONLY} == '1' ]] && [[ ${REPLICATION_STATUS[0]} == 'Yes' ]] && [[ ${REPLICATION_STATUS[1]} == 'Yes' ]]; then
34+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is OK"
35+
exit 0
36+
else
37+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is NOT OK"
38+
exit 1
39+
fi
40+
}
41+
42+
check_gr() {
43+
READ_ONLY=$(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e 'SELECT @@super_read_only' | /usr/bin/sed -n -e '2p' | /usr/bin/tr -d '\n')
44+
APPLIER_STATUS=$(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e "SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name = 'group_replication_applier'" | /usr/bin/sed -n -e '2p' | /usr/bin/tr -d '\n')
1545

16-
# ${REPLICATION_STATUS[0]} - Replica_IO_Running
17-
# ${REPLICATION_STATUS[1]} - Replica_SQL_Running
18-
REPLICATION_STATUS=($(MYSQL_PWD="${MONITOR_PASSWORD}" ${MYSQL_CMDLINE} -e 'SHOW REPLICA STATUS' | /usr/bin/sed -n -e '12p' -e '13p' | /usr/bin/tr '\n' ' '))
46+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} @@super_read_only: ${READ_ONLY} Applier: ${APPLIER_STATUS}"
1947

20-
echo "MySQL node ${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT}"
21-
echo "read_only: ${READ_ONLY}"
22-
echo "Replica_IO_Running: ${REPLICATION_STATUS[0]}"
23-
echo "Replica_SQL_Running: ${REPLICATION_STATUS[1]}"
48+
if [[ ${READ_ONLY} == '1' ]] && [[ ${APPLIER_STATUS} == "ON" ]]; then
49+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is OK"
50+
exit 0
51+
else
52+
log INFO "${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is NOT OK"
53+
exit 1
54+
fi
55+
}
2456

25-
if [[ ${READ_ONLY} == '1' ]] && [[ ${REPLICATION_STATUS[0]} == 'Yes' ]] && [[ ${REPLICATION_STATUS[1]} == 'Yes' ]]; then
26-
echo "MySQL node ${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is ok"
27-
exit 0
57+
if [[ ${CLUSTER_TYPE} == "async" ]]; then
58+
check_async
59+
elif [[ ${CLUSTER_TYPE} == "group-replication" ]]; then
60+
check_gr
2861
else
29-
echo "MySQL node ${MYSQL_SERVER_IP}:${MYSQL_SERVER_PORT} for backend ${HAPROXY_PROXY_NAME} is not ok"
62+
log ERROR "Invalid cluster type: ${CLUSTER_TYPE}"
3063
exit 1
3164
fi

0 commit comments

Comments
 (0)