From ddcc12923a3c78829fe408f7b28fe16a2e61f05b Mon Sep 17 00:00:00 2001 From: acekingke Date: Fri, 22 Nov 2024 17:14:22 +0800 Subject: [PATCH] fix the RO readness check --- mysqlcluster/syncer/readonly_statefulset.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mysqlcluster/syncer/readonly_statefulset.go b/mysqlcluster/syncer/readonly_statefulset.go index a0a4bccb..a7010117 100644 --- a/mysqlcluster/syncer/readonly_statefulset.go +++ b/mysqlcluster/syncer/readonly_statefulset.go @@ -167,6 +167,23 @@ func GetReadonlyStatefulSet(cr *StatefulSetSyncer) (*appsv1.StatefulSet, error) } mysql := container.EnsureContainer(utils.ContainerMysqlName, cr.MysqlCluster) + // ReadOnly mysql cannot use the mysqlchecker to do readness check + mysql.ReadinessProbe = &corev1.Probe{ + ProbeHandler: corev1.ProbeHandler{ + Exec: &corev1.ExecAction{ + Command: []string{ + "sh", + "-c", + `if [ -f '/var/lib/mysql/sleep-forever' ] ;then exit 0 ; fi; test $(mysql -uroot -NB -e "SELECT 1") -eq 1`, + }, + }, + }, + InitialDelaySeconds: 10, + TimeoutSeconds: 15, + PeriodSeconds: 15, + SuccessThreshold: 1, + FailureThreshold: 3, + } if cr.Spec.ReadOnlys.Resources != nil { mysql.Resources = *cr.Spec.ReadOnlys.Resources // (RO) calc innodb buffer and add it to env