Repository: radondb/radondb-mysql-kubernetes
Pull request #846 (2024-05-20 06:57:40)

*: add Optimise about parameters and scripts
<!-- Thanks for sending a pull request!

PR Title Format:
1. pkg [, pkg2, pkg3]: what's changed #xxx
2. *: what's changed #xxx

-->

### What type of PR is this?

<!--
Add one of the following types:
/bug
/documentation
/cleanup

-->
/bug
### Which issue(s) this PR fixes?

<!--
Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes # remove the connection plugin, and change the scripts, and so on.

### What this PR does?

Summary:

### Special notes for your reviewer?



Patch:
diff --git a/Dockerfile.sidecar b/Dockerfile57.sidecar
similarity index 68%
rename from Dockerfile.sidecar
rename to Dockerfile57.sidecar
index 679bec9..4f61f70 100644
--- a/Dockerfile.sidecar
+++ b/Dockerfile57.sidecar
@@ -37,28 +37,29 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -a -o bin/my
 ###############################################################################
 #  Docker image for Sidecar
 ###############################################################################
-FROM ubuntu:focal
+# FROM ubuntu:focal
 
-RUN set -ex; \
-    groupadd --gid 1001 --system mysql; \
-    useradd \
-    --uid 1001 \
-    --system \
-    --home-dir /var/lib/mysql \
-    --no-create-home \
-    --gid mysql \
-    mysql;
+# RUN set -ex; \
+#     groupadd --gid 1001 --system mysql; \
+#     useradd \
+#     --uid 1001 \
+#     --system \
+#     --home-dir /var/lib/mysql \
+#     --no-create-home \
+#     --gid mysql \
+#     mysql;
 
-ARG XTRABACKUP_PKG=percona-xtrabackup-24
-RUN set -ex; \
-    apt-get update; \
-    apt-get install -y --no-install-recommends gnupg2 wget lsb-release curl bc openssh-server  sshpass;\
-    wget -P /tmp --no-check-certificate https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb; \
-    dpkg -i /tmp/percona-release_latest.$(lsb_release -sc)_all.deb; \
-    apt-get update; \
-    apt-get install -y --no-install-recommends ${XTRABACKUP_PKG} mysql-client jq; \
-    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+# ARG XTRABACKUP_PKG=percona-xtrabackup-24
+# RUN set -ex; \
+#     apt-get update; \
+#     apt-get install -y --no-install-recommends gnupg2 wget lsb-release curl bc openssh-server  sshpass;\
+#     wget -P /tmp --no-check-certificate https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb; \
+#     dpkg -i /tmp/percona-release_latest.$(lsb_release -sc)_all.deb; \
+#     apt-get update; \
+#     apt-get install -y --no-install-recommends ${XTRABACKUP_PKG} mysql-client jq; \
+#     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 
+FROM radondb/mysql57-sidecar:v2.4.0
 WORKDIR /
 COPY --from=builder /workspace/bin/sidecar /usr/local/bin/sidecar
 COPY --from=builder /workspace/bin/mysqlchecker /mnt/mysqlchecker
diff --git a/Dockerfile.sidecar-arm64 b/Dockerfile57.sidecar-arm64
similarity index 53%
rename from Dockerfile.sidecar-arm64
rename to Dockerfile57.sidecar-arm64
index d6185e5..342b0bf 100644
--- a/Dockerfile.sidecar-arm64
+++ b/Dockerfile57.sidecar-arm64
@@ -9,12 +9,14 @@ WORKDIR /workspace
 # Copy the Go Modules manifests
 COPY go.mod go.mod
 COPY go.sum go.sum
-
+ARG GO_PROXY=off
 # cache deps before building and copying source so that we don't need to re-download as much
 # and so that source changes don't invalidate our downloaded layer
 # RUN if [ $(date +%z) = "+0800" ] ; then go env -w GOPROXY=https://goproxy.cn,direct; fi
-# RUN go env -w GOPROXY=https://goproxy.cn,direct
-#     go mod download
+RUN echo "GO_PROXY argument is: ${GO_PROXY}"
+RUN if [ "$GO_PROXY" = "on" ]; then \
+    go env -w GOPROXY=https://goproxy.cn,direct; \
+    fi
 RUN go mod download
 
 # Copy the go source
@@ -38,48 +40,49 @@ RUN CGO_ENABLED=0 GOOS=linux  go build -ldflags="-s -w" -a -o bin/mysqlchecker c
 ###############################################################################
 #  Docker image for Sidecar
 ###############################################################################
-FROM oraclelinux:8-slim
+# FROM oraclelinux:8-slim
 
-LABEL org.opencontainers.image.authors="info@percona.com"
-RUN set -ex; \
-    groupadd --gid 1001 --system mysql; \
-    useradd \
-    --uid 1001 \
-    --system \
-    --home-dir /var/lib/mysql \
-    --no-create-home \
-    --gid mysql \
-    mysql;
+# LABEL org.opencontainers.image.authors="info@percona.com"
+# RUN set -ex; \
+#     groupadd --gid 1001 --system mysql; \
+#     useradd \
+#     --uid 1001 \
+#     --system \
+#     --home-dir /var/lib/mysql \
+#     --no-create-home \
+#     --gid mysql \
+#     mysql;
 
-RUN microdnf -y update; \
-    microdnf -y install glibc-langpack-en
+# RUN microdnf -y update; \
+#     microdnf -y install glibc-langpack-en
 
-ARG XTRABACKUP_PKG=percona-xtrabackup-24
+# ARG XTRABACKUP_PKG=percona-xtrabackup-24
 
-# check repository package signature in secure way
-#percona-xtrabackup-24-2.4.26
-#percona-xtrabackup-test-80-8.0.28
-RUN set -ex; \
-         { \
-    echo '[mysql-server-minimal]'; \
-    echo 'name=MySQL  Server Minimal'; \
-    echo 'enabled=1'; \
-    echo 'baseurl=http://139.198.40.93:801' ;\
-    echo 'gpgcheck=0'; \
-    echo 'module_hotfixes=true' ;\
-    } | tee /etc/yum.repos.d/mysql-community-minimal.repo
+# # check repository package signature in secure way
+# #percona-xtrabackup-24-2.4.26
+# #percona-xtrabackup-test-80-8.0.28
+# RUN set -ex; \
+#          { \
+#     echo '[mysql-server-minimal]'; \
+#     echo 'name=MySQL  Server Minimal'; \
+#     echo 'enabled=1'; \
+#     echo 'baseurl=http://139.198.40.93:801' ;\
+#     echo 'gpgcheck=0'; \
+#     echo 'module_hotfixes=true' ;\
+#     } | tee /etc/yum.repos.d/mysql-community-minimal.repo
 
-RUN set -ex; \
-    #dnf --setopt=install_weak_deps=False install -y \
-    microdnf -y install \
-        ${XTRABACKUP_PKG} \
-        libev \
-        curl \
-        gnutls \
-        wget; 
-RUN microdnf --enablerepo='*' update; \
-    microdnf clean all; \
-    rm -rf /var/cache/dnf /var/cache/yum; 
+# RUN set -ex; \
+#     #dnf --setopt=install_weak_deps=False install -y \
+#     microdnf -y install \
+#         ${XTRABACKUP_PKG} \
+#         libev \
+#         curl \
+#         gnutls \
+#         wget; 
+# RUN microdnf --enablerepo='*' update; \
+#     microdnf clean all; \
+#     rm -rf /var/cache/dnf /var/cache/yum; 
+from radondb/mysql57-sidecar:v2.4.0
 WORKDIR /
 COPY --from=builder /workspace/bin/sidecar /usr/local/bin/sidecar
 COPY --from=builder /workspace/bin/mysqlchecker /mnt/mysqlchecker
diff --git a/Dockerfile80.sidecar b/Dockerfile80.sidecar
new file mode 100644
index 0000000..784d414
--- /dev/null
+++ b/Dockerfile80.sidecar
@@ -0,0 +1,67 @@
+##############################################################################
+#  Build Sidecar
+###############################################################################
+# Build the manager binary
+FROM golang:1.17.13 as builder
+
+WORKDIR /workspace
+# Copy the Go Modules manifests
+COPY go.mod go.mod
+COPY go.sum go.sum
+ARG GO_PROXY=off
+RUN if [ "$GO_PROXY" = "on" ]; then \
+    go env -w GOPROXY=https://goproxy.cn,direct; \
+    fi
+# cache deps before building and copying source so that we don't need to re-download as much
+# and so that source changes don't invalidate our downloaded layer
+#     go mod download
+RUN go mod download
+
+# Copy the go source
+COPY cmd/sidecar/main.go cmd/sidecar/main.go
+COPY sidecar/ sidecar/
+COPY utils/ utils/
+
+# Build
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -a -o bin/sidecar cmd/sidecar/main.go
+
+# Build mysql checker for mysql conatiner
+COPY cmd/s3cmd/main.go cmd/s3cmd/main.go
+COPY cmd/s3cmd/s3upload.go cmd/s3cmd/s3upload.go
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -a -o bin/s3upload cmd/s3cmd/main.go cmd/s3cmd/s3upload.go
+
+# Build mysql checker for mysql conatiner
+COPY cmd/mysql/main.go cmd/mysql/main.go
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -a -o bin/mysqlchecker cmd/mysql/main.go
+
+###############################################################################
+#  Docker image for Sidecar
+###############################################################################
+# FROM ubuntu:focal
+
+# RUN set -ex; \
+#     groupadd --gid 1001 --system mysql; \
+#     useradd \
+#     --uid 1001 \
+#     --system \
+#     --home-dir /var/lib/mysql \
+#     --no-create-home \
+#     --gid mysql \
+#     mysql;
+
+# ARG XTRABACKUP_PKG=percona-xtrabackup-24
+# RUN set -ex; \
+#     apt-get update; \
+#     apt-get install -y --no-install-recommends gnupg2 wget lsb-release curl bc openssh-server  sshpass;\
+#     wget -P /tmp --no-check-certificate https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb; \
+#     dpkg -i /tmp/percona-release_latest.$(lsb_release -sc)_all.deb; \
+#     apt-get update; \
+#     apt-get install -y --no-install-recommends ${XTRABACKUP_PKG} mysql-client jq; \
+#     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+
+FROM radondb/mysql80-sidecar:v2.4.0
+WORKDIR /
+COPY --from=builder /workspace/bin/sidecar /usr/local/bin/sidecar
+COPY --from=builder /workspace/bin/mysqlchecker /mnt/mysqlchecker
+COPY --from=builder /workspace/bin/s3upload /mnt/s3upload
+ENTRYPOINT ["sidecar"]
diff --git a/Dockerfile80.sidecar-arm64 b/Dockerfile80.sidecar-arm64
new file mode 100644
index 0000000..387a475
--- /dev/null
+++ b/Dockerfile80.sidecar-arm64
@@ -0,0 +1,90 @@
+
+##############################################################################
+#  Build Sidecar
+###############################################################################
+# Build the manager binary
+FROM golang:1.17.13 as builder
+
+WORKDIR /workspace
+# Copy the Go Modules manifests
+COPY go.mod go.mod
+COPY go.sum go.sum
+ARG GO_PROXY=off
+# cache deps before building and copying source so that we don't need to re-download as much
+# and so that source changes don't invalidate our downloaded layer
+# RUN if [ $(date +%z) = "+0800" ] ; then go env -w GOPROXY=https://goproxy.cn,direct; fi
+RUN echo "GO_PROXY argument is: ${GO_PROXY}"
+RUN if [ "$GO_PROXY" = "on" ]; then \
+    go env -w GOPROXY=https://goproxy.cn,direct; \
+    fi
+RUN go mod download
+
+# Copy the go source
+COPY cmd/sidecar/main.go cmd/sidecar/main.go
+COPY sidecar/ sidecar/
+COPY utils/ utils/
+
+# Build
+RUN CGO_ENABLED=0 GOOS=linux  go build -a -o bin/sidecar cmd/sidecar/main.go
+
+
+# Build mysql checker for mysql conatiner
+COPY cmd/s3cmd/main.go cmd/s3cmd/main.go
+COPY cmd/s3cmd/s3upload.go cmd/s3cmd/s3upload.go
+RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -a -o bin/s3upload cmd/s3cmd/main.go cmd/s3cmd/s3upload.go
+
+# Build mysql checker for mysql conatiner
+COPY cmd/mysql/main.go cmd/mysql/main.go
+RUN CGO_ENABLED=0 GOOS=linux  go build -ldflags="-s -w" -a -o bin/mysqlchecker cmd/mysql/main.go
+
+###############################################################################
+#  Docker image for Sidecar
+###############################################################################
+# FROM oraclelinux:8-slim
+
+# LABEL org.opencontainers.image.authors="info@percona.com"
+# RUN set -ex; \
+#     groupadd --gid 1001 --system mysql; \
+#     useradd \
+#     --uid 1001 \
+#     --system \
+#     --home-dir /var/lib/mysql \
+#     --no-create-home \
+#     --gid mysql \
+#     mysql;
+
+# RUN microdnf -y update; \
+#     microdnf -y install glibc-langpack-en
+
+# ARG XTRABACKUP_PKG=percona-xtrabackup-24
+
+# # check repository package signature in secure way
+# #percona-xtrabackup-24-2.4.26
+# #percona-xtrabackup-test-80-8.0.28
+# RUN set -ex; \
+#          { \
+#     echo '[mysql-server-minimal]'; \
+#     echo 'name=MySQL  Server Minimal'; \
+#     echo 'enabled=1'; \
+#     echo 'baseurl=http://139.198.40.93:801' ;\
+#     echo 'gpgcheck=0'; \
+#     echo 'module_hotfixes=true' ;\
+#     } | tee /etc/yum.repos.d/mysql-community-minimal.repo
+
+# RUN set -ex; \
+#     #dnf --setopt=install_weak_deps=False install -y \
+#     microdnf -y install \
+#         ${XTRABACKUP_PKG} \
+#         libev \
+#         curl \
+#         gnutls \
+#         wget; 
+# RUN microdnf --enablerepo='*' update; \
+#     microdnf clean all; \
+#     rm -rf /var/cache/dnf /var/cache/yum; 
+from radondb/mysql80-sidecar:v2.4.0
+WORKDIR /
+COPY --from=builder /workspace/bin/sidecar /usr/local/bin/sidecar
+COPY --from=builder /workspace/bin/mysqlchecker /mnt/mysqlchecker
+COPY --from=builder /workspace/bin/s3upload /mnt/s3upload
+ENTRYPOINT ["sidecar"]
\ No newline at end of file
diff --git a/Makefile b/Makefile
index cc0e5d9..9afbfed 100644
--- a/Makefile
+++ b/Makefile
@@ -97,11 +97,12 @@ run: manifests generate fmt vet ## Run a controller from your host.
 	go run ./cmd/manager/main.go
 
 docker-build: test ## Build docker image with the manager.
-	DOCKER_BUILDKIT=1 docker build --build-arg GO_PROXY=${GO_PROXY} -t ${IMG} .
-	DOCKER_BUILDKIT=1 docker build -f Dockerfile.sidecar --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR57_IMG} .
-	DOCKER_BUILDKIT=1 docker build -f Dockerfile.sidecar --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR80_IMG} .
-	DOCKER_BUILDKIT=1 docker build -f build/xenon/Dockerfile --build-arg GO_PROXY=${GO_PROXY} -t ${XENON_IMG} .
-	DOCKER_BUILDKIT=1 docker build --build-arg XTRABACKUP_PKG=percona-xtrabackup-80  --build-arg GO_PROXY=${GO_PROXY} -f  Dockerfile.sidecar -t ${SIDECAR80_IMG} .
+	# DOCKER_BUILDKIT=1 docker build --build-arg GO_PROXY=${GO_PROXY} -t ${IMG} .
+	# DOCKER_BUILDKIT=1 docker build -f Dockerfile.sidecar --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR57_IMG} .
+	# DOCKER_BUILDKIT=1 docker build -f Dockerfile.sidecar --build-arg IMAGE_FROM="radondb/mysql80-sidecar:v2.4.0" --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR80_IMG} .
+	# DOCKER_BUILDKIT=1 docker build -f build/xenon/Dockerfile --build-arg GO_PROXY=${GO_PROXY} -t ${XENON_IMG} .
+	# DOCKER_BUILDKIT=1 docker build --build-arg XTRABACKUP_PKG=percona-xtrabackup-80  --build-arg GO_PROXY=${GO_PROXY} -f  Dockerfile.sidecar -t ${SIDECAR80_IMG} .
+	bash ./build_mutiplatform.sh
 docker-push: ## Push docker image with the manager.
 	docker push ${IMG}
 	docker push ${SIDECAR57_IMG}
diff --git a/build_mutiplatform.sh b/build_mutiplatform.sh
index e2ba038..b6dd01b 100644
--- a/build_mutiplatform.sh
+++ b/build_mutiplatform.sh
@@ -3,22 +3,25 @@
 TAG=v3.0.0
 IMGPREFIX=radondb/
 builder_exists=$(docker buildx ls | awk '{if ($1=="multi-platform") print $1}')
+	# docker buildx rm multi-platform
+	# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
 if [ "$builder_exists" ]; then
-	docker buildx rm multi-platform
-	docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
+	echo "exist the multiarch"
+else
+	docker buildx create --use --name multi-platform --platform=linux/amd64,linux/arm64 > /dev/null
 fi
-docker buildx create --use --name multi-platform --platform=linux/amd64,linux/arm64 > /dev/null
+
 
 IMGAMD=${IMGPREFIX}mysql-operator-amd64:${TAG}
 IMGARM=${IMGPREFIX}mysql-operator-arm64:${TAG}
 GO_PROXY=on
 DOCKER_BUILDKIT=1 docker build --build-arg GO_PROXY=${GO_PROXY} -t ${IMGAMD} .
 
-docker buildx create --use --name multi-platform --driver docker-container --platform=linux/amd64,linux/arm64 --config /root/radondb-mysql-kubernetes/buildkitd.toml > /dev/null
+#docker buildx create --use --name multi-platform --driver docker-container --platform=linux/amd64,linux/arm64 --config /root/radondb-mysql-kubernetes/buildkitd.toml > /dev/null
 docker buildx build --build-arg GO_PROXY=on   --platform linux/arm64  -t $IMGARM -o type=docker .
 docker push ${IMGAMD}
 docker push ${IMGARM}
-docker manifest create ${IMGPREFIX}mysql-operator:${TAG}  ${IMGAMD} ${IMGARM}
+docker manifest create --amend ${IMGPREFIX}mysql-operator:${TAG}  ${IMGAMD} ${IMGARM}
 docker manifest  push --purge  ${IMGPREFIX}mysql-operator:${TAG}
 
 
@@ -42,10 +45,10 @@ SIDECAR80_IMGAMD=${IMGPREFIX}mysql80-sidecar-amd64:${TAG}
 SIDECAR57_IMGARM=${IMGPREFIX}mysql57-sidecar-arm64:${TAG}
 SIDECAR80_IMGARM=${IMGPREFIX}mysql80-sidecar-arm64:${TAG}
 GO_PROXY=on
-DOCKER_BUILDKIT=1 docker build --build-arg XTRABACKUP_PKG=percona-xtrabackup-80  --build-arg GO_PROXY=${GO_PROXY} -f  Dockerfile.sidecar -t ${SIDECAR80_IMGAMD} .
-DOCKER_BUILDKIT=1 docker build -f Dockerfile.sidecar --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR57_IMGAMD} .
-docker buildx build --build-arg GO_PROXY=on   --platform linux/arm64  --build-arg XTRABACKUP_PKG=percona-xtrabackup-80  --build-arg GO_PROXY=${GO_PROXY} -f  Dockerfile.sidecar-arm64  -t ${SIDECAR80_IMGARM}  -o type=docker  .
-docker buildx build --build-arg GO_PROXY=on   --platform linux/arm64  -f Dockerfile.sidecar2 --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR57_IMGARM}  -o type=docker .
+DOCKER_BUILDKIT=1 docker build --build-arg IMAGE_FROM=radondb/mysql80-sidecar:v2.4.0  --build-arg GO_PROXY=${GO_PROXY} -f  Dockerfile80.sidecar -t ${SIDECAR80_IMGAMD} .
+DOCKER_BUILDKIT=1 docker build -f Dockerfile57.sidecar --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR57_IMGAMD} .
+docker buildx build --build-arg GO_PROXY=on   --platform linux/arm64  --build-arg GO_PROXY=${GO_PROXY} -f  Dockerfile80.sidecar-arm64  -t ${SIDECAR80_IMGARM}  -o type=docker  .
+docker buildx build --build-arg GO_PROXY=on   --platform linux/arm64  -f Dockerfile57.sidecar-arm64 --build-arg GO_PROXY=${GO_PROXY} -t ${SIDECAR57_IMGARM}  -o type=docker .
 docker push ${SIDECAR57_IMGAMD}
 docker push ${SIDECAR80_IMGAMD}
 docker push ${SIDECAR57_IMGARM}
diff --git a/controllers/backup/backup_controller.go b/controllers/backup/backup_controller.go
index be1c4fd..7207675 100644
--- a/controllers/backup/backup_controller.go
+++ b/controllers/backup/backup_controller.go
@@ -455,7 +455,7 @@ func (r *BackupReconciler) generateBackupJobSpec(backup *v1beta1.Backup, cluster
 	// If backup.Spec.BackupOpts.NFS is not nil then use ENV BACKUP_TYPE=nfs and mount the nfs volume
 
 	backupHost := GetBackupHost(cluster)
-	backupImage := cluster.Spec.Backup.Image
+	backupImage := mysqlcluster.GetImage(cluster.Spec.Backup.Image)
 	serviceAccountName := backup.Spec.ClusterName
 	clusterAuthsctName := fmt.Sprintf("%s-secret", cluster.GetName())
 	var S3BackuptEnv []corev1.EnvVar
@@ -734,7 +734,7 @@ func (r *BackupReconciler) genBinlogJobTemplate(backup *v1beta1.Backup, cluster
 				InitContainers: []corev1.Container{
 					{
 						Name:            "initial",
-						Image:           cluster.Spec.Backup.Image,
+						Image:           mysqlcluster.GetImage(cluster.Spec.Backup.Image),
 						ImagePullPolicy: cluster.Spec.ImagePullPolicy,
 						Command: []string{
 							"bash", "-c", "cp /mnt/s3upload /opt/radondb; chown -R 1001.1001 /opt/radondb",
diff --git a/controllers/backupcron_controller.go b/controllers/backupcron_controller.go
index e0056e1..a345e17 100644
--- a/controllers/backupcron_controller.go
+++ b/controllers/backupcron_controller.go
@@ -166,9 +166,9 @@ func (r *BackupCronReconciler) updateClusterSchedule(ctx context.Context, cluste
 				}
 				break
 			}
-			if j.Image != cluster.Spec.PodPolicy.SidecarImage {
-				log.Info("update cluster image", "key", cluster, "image", cluster.Spec.PodPolicy.SidecarImage)
-				j.Image = cluster.Spec.PodPolicy.SidecarImage
+			if j.Image != mysqlcluster.GetImage(cluster.Spec.PodPolicy.SidecarImage) {
+				log.Info("update cluster image", "key", cluster, "image", mysqlcluster.GetImage(cluster.Spec.PodPolicy.SidecarImage))
+				j.Image = mysqlcluster.GetImage(cluster.Spec.PodPolicy.SidecarImage)
 			}
 			return nil
 		}
@@ -184,7 +184,7 @@ func (r *BackupCronReconciler) updateClusterSchedule(ctx context.Context, cluste
 		ClusterName:                    cluster.Name,
 		Namespace:                      cluster.Namespace,
 		Client:                         r.Client,
-		Image:                          cluster.Spec.PodPolicy.SidecarImage,
+		Image:                          mysqlcluster.GetImage(cluster.Spec.PodPolicy.SidecarImage),
 		BackupScheduleJobsHistoryLimit: cluster.Spec.BackupScheduleJobsHistoryLimit,
 		NFSServerAddress:               nfsServerAddress,
 		BackupType:                     BackupType,
diff --git a/mysqlcluster/container/init_mysql.go b/mysqlcluster/container/init_mysql.go
index 0c28a58..180d240 100644
--- a/mysqlcluster/container/init_mysql.go
+++ b/mysqlcluster/container/init_mysql.go
@@ -45,11 +45,11 @@ func (c *initMysql) getImage() string {
 // getCommand get the container command.
 func (c *initMysql) getCommand() []string {
 	// Because initialize mysql contain error, so do it in commands.
-	return []string{"bash", "-c", "/docker-entrypoint.sh mysqld;" +
-		"if test -f /docker-entrypoint-initdb.d/restore.sh; then /docker-entrypoint-initdb.d/restore.sh; fi ;" +
-		"if test -f /docker-entrypoint-initdb.d/upgrade.sh; then /docker-entrypoint-initdb.d/upgrade.sh;fi;" +
-		"if test -f /docker-entrypoint-initdb.d/clone.sh; then /docker-entrypoint-initdb.d/clone.sh;fi;" +
-		"if test -f /docker-entrypoint-initdb.d/plugin.sh; then /docker-entrypoint-initdb.d/plugin.sh; fi "}
+	pluginscript := "if test -f /docker-entrypoint-initdb.d/plugin.sh; then /docker-entrypoint-initdb.d/plugin.sh; fi ;"
+	clonescript := "if test -f " + utils.RadonDBBinDir + "/clone.sh;" + " then " + utils.RadonDBBinDir + "/clone.sh;fi;"
+	updgradescript := "if test -f " + utils.RadonDBBinDir + "/upgrade.sh; then " + utils.RadonDBBinDir + "/upgrade.sh;fi;"
+	restorescript := "if test -f " + utils.RadonDBBinDir + "/restore.sh; then " + utils.RadonDBBinDir + "/restore.sh; fi ;"
+	return []string{"bash", "-c", "/docker-entrypoint.sh mysqld;" + pluginscript + clonescript + updgradescript + restorescript}
 }
 
 // getEnvVars get the container env.
@@ -133,5 +133,9 @@ func (c *initMysql) getVolumeMounts() []corev1.VolumeMount {
 			Name:      utils.SysLocalTimeZone,
 			MountPath: utils.SysLocalTimeZoneMountPath,
 		},
+		{
+			Name:      utils.MySQLcheckerVolumeName,
+			MountPath: utils.RadonDBBinDir,
+		},
 	}
 }
diff --git a/mysqlcluster/container/xenon.go b/mysqlcluster/container/xenon.go
index f73a026..4119006 100644
--- a/mysqlcluster/container/xenon.go
+++ b/mysqlcluster/container/xenon.go
@@ -17,6 +17,8 @@ limitations under the License.
 package container
 
 import (
+	"strings"
+
 	corev1 "k8s.io/api/core/v1"
 
 	"github.com/radondb/radondb-mysql-kubernetes/mysqlcluster"
@@ -43,11 +45,14 @@ func (c *xenon) getImage() string {
 
 // getCommand get the container command.
 func (c *xenon) getCommand() []string {
+	cmdstr := ""
 	if *c.Spec.Replicas == 1 {
-		return []string{"xenon", "-c", "/etc/xenon/xenon.json", "-r", "LEADER"}
+		cmdstr = strings.Join([]string{"xenon", "-c", "/etc/xenon/xenon.json", "-r", "LEADER"}, " ")
+	} else {
+		// If return nil, statefulset never update command , And I don't know why.
+		cmdstr = strings.Join([]string{"xenon", "-c", "/etc/xenon/xenon.json"}, " ")
 	}
-	// If return nil, statefulset never update command , And I don't know why.
-	return []string{"xenon", "-c", "/etc/xenon/xenon.json"}
+	return []string{"sh", "-c", "while  [ -f '/etc/xenon/sleep-forever' ] ;do sleep 2;done; command " + cmdstr + " & pid=$!;wait $pid;"}
 }
 
 // getEnvVars get the container env.
@@ -129,7 +134,7 @@ func (c *xenon) getLivenessProbe() *corev1.Probe {
 				Command: []string{
 					"sh",
 					"-c",
-					"pgrep xenon && xenoncli xenon ping",
+					"while  [ -f '/etc/xenon/sleep-forever' ] ;do sleep 2;done;pgrep xenon && xenoncli xenon ping",
 				},
 			},
 		},
@@ -146,7 +151,7 @@ func (c *xenon) getReadinessProbe() *corev1.Probe {
 	return &corev1.Probe{
 		ProbeHandler: corev1.ProbeHandler{
 			Exec: &corev1.ExecAction{
-				Command: []string{"sh", "-c", "xenoncli xenon ping"},
+				Command: []string{"sh", "-c", "while  [ -f '/etc/xenon/sleep-forever' ] ;do sleep 2;done; xenoncli xenon ping"},
 			},
 		},
 		InitialDelaySeconds: 10,
diff --git a/mysqlcluster/syncer/mysql_cm.go b/mysqlcluster/syncer/mysql_cm.go
index 449101f..075fb88 100644
--- a/mysqlcluster/syncer/mysql_cm.go
+++ b/mysqlcluster/syncer/mysql_cm.go
@@ -24,6 +24,7 @@ import (
 	"sort"
 	"strings"
 
+	"github.com/blang/semver"
 	"github.com/go-ini/ini"
 	"github.com/go-logr/logr"
 	corev1 "k8s.io/api/core/v1"
@@ -253,7 +254,10 @@ func buildMysqlConf(c *mysqlcluster.MysqlCluster) (string, error) {
 	var log = logf.Log.WithName("mysqlcluster.syncer.buildMysqlConf")
 	cfg := ini.Empty(ini.LoadOptions{IgnoreInlineComment: true})
 	sec := cfg.Section("mysqld")
-
+	arr := strings.Split(c.Spec.MysqlOpts.Image, ":")
+	VerCurrent := arr[len(arr)-1]
+	mysqlSemVerCurr, _ := semver.Parse(VerCurrent)
+	mysqlSemVer31, _ := semver.Parse("8.0.31")
 	c.EnsureMysqlConf()
 	mysqlVersion := ""
 	if strings.Contains(c.Spec.MysqlOpts.Image, "8.0") {
@@ -267,14 +271,47 @@ func buildMysqlConf(c *mysqlcluster.MysqlCluster) (string, error) {
 	case "5.7":
 		addKVConfigsToSection(sec, mysql57Configs)
 	}
-
-	addKVConfigsToSection(sec, mysqlSysConfigs, mysqlCommonConfigs, mysqlStaticConfigs)
+	if mysqlSemVerCurr.GE(mysqlSemVer31) {
+		// at first , copy all the map, just for version over 8.0.31
+		//var mysqlStaticConfigsCpy, mysqlSysConfigsCpy, mysqlCommonConfigsCpy map[string]string
+		mysqlStaticConfigsCpy := make(map[string]string)
+		mysqlSysConfigsCpy := make(map[string]string)
+		mysqlCommonConfigsCpy := make(map[string]string)
+		cpyMap(mysqlStaticConfigs, mysqlStaticConfigsCpy)
+		cpyMap(mysqlSysConfigs, mysqlSysConfigsCpy)
+		cpyMap(mysqlCommonConfigs, mysqlCommonConfigsCpy)
+		replaceMapKey(mysqlStaticConfigsCpy, "slave_pending_jobs_size_max", "replica_pending_jobs_size_max")
+		replaceMapKey(mysqlStaticConfigsCpy, "slave_preserve_commit_order", "replica_preserve_commit_order")
+		// slave_parallel_workers -> replica_parallel_workers
+		replaceMapKey(mysqlStaticConfigsCpy, "slave_parallel_workers", "replica_parallel_workers")
+		mysqlStaticConfigsCpy["replica_parallel_workers"] = "1"
+		// mysqlSysConfigs
+		// 1. slave_parallel_type -> replica_parallel_type
+		replaceMapKey(mysqlSysConfigsCpy, "slave_parallel_type", "replica_parallel_type")
+		// mysqlCommonConfigs
+		// sync_master_info -> sync_source_info
+		replaceMapKey(mysqlCommonConfigsCpy, "sync_master_info", "sync_source_info")
+		addKVConfigsToSection(sec, mysqlSysConfigsCpy, mysqlCommonConfigsCpy, mysqlStaticConfigsCpy)
+	} else {
+		addKVConfigsToSection(sec, mysqlSysConfigs, mysqlCommonConfigs, mysqlStaticConfigs)
+	}
 
 	if c.Spec.MysqlOpts.InitTokuDB {
 		addKVConfigsToSection(sec, mysqlTokudbConfigs)
 	}
 
 	for _, key := range mysqlBooleanConfigs {
+		if mysqlSemVerCurr.GE(mysqlSemVer31) {
+			switch key {
+			case "skip-host-cache":
+				sec.NewKey("host_cache_size", "0")
+				continue
+			case "skip-slave-start":
+				key = "skip_replica_start"
+			case "log-slave-updates":
+				key = "log_replica_updates"
+			}
+		}
 		if _, err := sec.NewBooleanKey(key); err != nil {
 			log.Error(err, "failed to add boolean key to config section", "key", key)
 		}
@@ -359,3 +396,14 @@ type StringsConnectedByBar []string
 func (x StringsConnectedByBar) Len() int           { return len(x) }
 func (x StringsConnectedByBar) Less(i, j int) bool { return barskey(x[i]) < barskey(x[j]) }
 func (x StringsConnectedByBar) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }
+
+func replaceMapKey(dict map[string]string, key1 string, key2 string) {
+	dict[key2] = dict[key1]
+	delete(dict, key1)
+}
+
+func cpyMap(src map[string]string, dest map[string]string) {
+	for k, v := range src {
+		dest[k] = v
+	}
+}
diff --git a/mysqlcluster/syncer/mysql_configs.go b/mysqlcluster/syncer/mysql_configs.go
index ffacabe..46aafc9 100644
--- a/mysqlcluster/syncer/mysql_configs.go
+++ b/mysqlcluster/syncer/mysql_configs.go
@@ -45,7 +45,7 @@ var mysqlSysConfigs = map[string]string{
 }
 
 var pluginConfigs = map[string]string{
-	"plugin-load": "\"semisync_master.so;semisync_slave.so;audit_log.so;connection_control.so\"",
+	"plugin-load": "\"semisync_master.so;semisync_slave.so;audit_log.so\"",
 
 	"rpl_semi_sync_master_enabled":       "OFF",
 	"rpl_semi_sync_slave_enabled":        "ON",
@@ -59,10 +59,6 @@ var pluginConfigs = map[string]string{
 	"audit_log_rotate_on_size":   "104857600",
 	"audit_log_rotations":        "6",
 	"audit_log_format":           "OLD",
-
-	"connection_control_failed_connections_threshold": "3",
-	"connection_control_min_connection_delay":         "1000",
-	"connection_control_max_connection_delay":         "2147483647",
 }
 
 var mysql57Configs = map[string]string{
@@ -126,13 +122,14 @@ var mysqlStaticConfigs = map[string]string{
 	"innodb_ft_max_token_size":    "84",
 	"innodb_ft_min_token_size":    "3",
 	"sql_mode":                    "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION",
-	"slave_parallel_workers":      "8",
+	"slave_parallel_workers":      "0",
 	"slave_pending_jobs_size_max": "1073741824",
 	"innodb_log_buffer_size":      "16777216",
 	//"innodb_log_file_size":        "1073741824",
 	"innodb_log_files_in_group": "2",
 	"innodb_flush_method":       "O_DIRECT",
 
+	"slave_preserve_commit_order": "ON",
 	// TODO(cluster): Some machine do not support native aio.
 	//"innodb_use_native_aio": "1",
 
diff --git a/sidecar/config.go b/sidecar/config.go
index ea988dc..355ff2d 100644
--- a/sidecar/config.go
+++ b/sidecar/config.go
@@ -655,13 +655,17 @@ func (cfg *Config) executeS3Restore(pathArg string) error {
 				return fmt.Errorf("error mkdir %s: %s", buildBinlogDir(cfg.XRestoreFrom), err)
 			}
 		}
-		restorePoint, err := time.Parse("2006-01-02 15:04:05", cfg.RestorePoint)
-		if err != nil {
-			return fmt.Errorf("restore point parse error : %s", err)
+		if len(cfg.RestorePoint) != 0 {
+			restorePoint, err := time.Parse("2006-01-02 15:04:05", cfg.RestorePoint)
+			if err != nil {
+				log.Info("restore point parse error : %s", err)
+			} else {
+				s3.S3Download(cfg, buildBinlogDir(cfg.XRestoreFrom))
+				cfg.BuildScript(gtid, restorePoint)
+			}
+
 		}
 
-		s3.S3Download(cfg, buildBinlogDir(cfg.XRestoreFrom))
-		cfg.BuildScript(gtid, restorePoint)
 	}
 	return nil
 }
@@ -694,7 +698,7 @@ if ! kill -s TERM "$pid" || ! wait "$pid"; then
 fi
 `, binlogPathDir, skipGtid, restorePoint.Format(RestoreTimeSample))
 	fmt.Println(script)
-	if err := ioutil.WriteFile(utils.InitFileVolumeMountPath+"/restore.sh", []byte(script), 0755); err != nil {
+	if err := ioutil.WriteFile(utils.RadonDBBinDir+"/restore.sh", []byte(script), 0755); err != nil {
 		return err
 	}
 
diff --git a/sidecar/init.go b/sidecar/init.go
index eebd2b6..67e7f4d 100644
--- a/sidecar/init.go
+++ b/sidecar/init.go
@@ -126,6 +126,11 @@ func runCloneAndInit(cfg *Config) (bool, error) {
 		}
 	}
 	if len(serviceURL) != 0 {
+		// When it has /var/lib/mysql/mysql do not need clone and restore.
+		if hasInitialized {
+			log.Info("MySQL data directory existing!")
+			return hasInitialized, nil
+		}
 		// is MySQL8, CLone it
 		if cfg.MySQLVersion.Major == 8 && len(cfg.XRestoreFrom) == 0 {
 			// return clone int
@@ -134,11 +139,6 @@ func runCloneAndInit(cfg *Config) (bool, error) {
 			return hasInitialized, err
 		}
 
-		if hasInitialized {
-			log.Info("MySQL data directory existing!")
-			return hasInitialized, nil
-		}
-
 		// backup at first
 		Args := fmt.Sprintf("curl --user $BACKUP_USER:$BACKUP_PASSWORD %s/download|xbstream -x -C %s; exit ${PIPESTATUS[0]}",
 			serviceURL, utils.DataVolumeMountPath)
@@ -329,6 +329,8 @@ func runInitCommand(cfg *Config, hasInitialized bool) error {
 			}
 		}
 	}
+	//hasInitialized, _ = checkIfPathExists(path.Join(dataPath, "mysql"))
+	log.Info("begin writing initsql", "initialize", hasInitialized)
 	// Build init.sql after restore
 	if err = ioutil.WriteFile(initSqlPath, cfg.buildInitSql(hasInitialized), 0644); err != nil {
 		return fmt.Errorf("failed to write init.sql: %s", err)
@@ -609,24 +611,41 @@ func DoCLone(cfg *Config, server string) error {
 `, server, cfg.DonorClone, server, cfg.DonorClonePassword)
 	cloneSh := fmt.Sprintf(`#!/bin/bash
 echo 'now is doing clone.'
+while true; do
+	if pgrep mysqld; then
+		echo 'waiting mysqld exit'
+	else
+		break
+	fi	
+	sleep 1
+done
 mysqld &
+pid=$!
 mysql=( mysql -uroot -hlocalhost  --password="" )
 
-for i in {120..0}; do
+for i in {500..0}; do
 	if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
 		break
 	fi
 	echo 'MySQL run process in progress...'
 	sleep 1
 done
+for i in {500..0}; do
+	if echo SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS where PLUGIN_NAME="'clone'"| "${mysql[@]}" |grep -q ACTIVE; then
+		break
+	fi
+	echo 'check plugin whether is installed...'
+	sleep 1
+done
 mysql -uroot -hlocalhost  --password="" -e "%s"
+wait $pid
 echo "now delete socks file"
 rm -rf /var/lib/mysql/*.sock
 rm -rf /var/lib/mysql/mysql.sock.lock
 `, sql)
 	log.Info("write clone shell", "shell", cloneSh)
 	//write to docker.
-	if err := ioutil.WriteFile(initFilePath+"/clone.sh", []byte(cloneSh), 0755); err != nil {
+	if err := ioutil.WriteFile(utils.RadonDBBinDir+"/clone.sh", []byte(cloneSh), 0755); err != nil {
 		return fmt.Errorf("failed to write clone.sh: %s", err)
 	}
 	return nil
@@ -666,7 +685,7 @@ func UpgradeShGen(cfg *Config) error {
 	`
 	log.Info("write upgrade shell", "shell", upgradesh)
 	//write to docker.
-	if err := ioutil.WriteFile(initFilePath+"/upgrade.sh", []byte(upgradesh), 0755); err != nil {
+	if err := ioutil.WriteFile(utils.RadonDBBinDir+"/upgrade.sh", []byte(upgradesh), 0755); err != nil {
 		return fmt.Errorf("failed to write upgrade.sh: %s", err)
 	}
 	return nil


Test patch:
diff --git a/mysqlcluster/container/init_mysql_test.go b/mysqlcluster/container/init_mysql_test.go
index 053d66b..7bb387a 100644
--- a/mysqlcluster/container/init_mysql_test.go
+++ b/mysqlcluster/container/init_mysql_test.go
@@ -71,6 +71,10 @@ var (
 			Name:      utils.SysLocalTimeZone,
 			MountPath: utils.SysLocalTimeZoneMountPath,
 		},
+		{
+			Name:      utils.MySQLcheckerVolumeName,
+			MountPath: utils.RadonDBBinDir,
+		},
 	}
 	optFalse      = false
 	optTrue       = true
@@ -113,12 +117,7 @@ func TestGetInitMysqlImage(t *testing.T) {
 }
 
 func TestGetInitMysqlCommand(t *testing.T) {
-	assert.Equal(t, initMysqlCase.Command, []string{"bash", "-c", "/docker-entrypoint.sh mysqld;" +
-		"if test -f /docker-entrypoint-initdb.d/restore.sh; then /docker-entrypoint-initdb.d/restore.sh; fi ;" +
-		"if test -f /docker-entrypoint-initdb.d/upgrade.sh; then /docker-entrypoint-initdb.d/upgrade.sh;fi;" +
-		"if test -f /docker-entrypoint-initdb.d/clone.sh; then /docker-entrypoint-initdb.d/clone.sh;fi;" +
-		"if test -f /docker-entrypoint-initdb.d/plugin.sh; then /docker-entrypoint-initdb.d/plugin.sh; fi ",
-	})
+	assert.Equal(t, initMysqlCase.Command, []string{"bash", "-c", "/docker-entrypoint.sh mysqld;if test -f /docker-entrypoint-initdb.d/plugin.sh; then /docker-entrypoint-initdb.d/plugin.sh; fi ;if test -f /opt/radondb/clone.sh; then /opt/radondb/clone.sh;fi;if test -f /opt/radondb/upgrade.sh; then /opt/radondb/upgrade.sh;fi;if test -f /opt/radondb/restore.sh; then /opt/radondb/restore.sh; fi ;"})
 }
 
 func TestGetInitMysqlEnvVar(t *testing.T) {
diff --git a/mysqlcluster/container/xenon_test.go b/mysqlcluster/container/xenon_test.go
index c0237fa..00de14c 100644
--- a/mysqlcluster/container/xenon_test.go
+++ b/mysqlcluster/container/xenon_test.go
@@ -64,7 +64,7 @@ func TestGetXenonImage(t *testing.T) {
 }
 
 func TestGetXenonCommand(t *testing.T) {
-	assert.Equal(t, []string{"xenon", "-c", "/etc/xenon/xenon.json"}, xenonCase.Command)
+	assert.Equal(t, []string{"sh", "-c", "while  [ -f '/etc/xenon/sleep-forever' ] ;do sleep 2;done; command xenon -c /etc/xenon/xenon.json & pid=$!;wait $pid;"}, xenonCase.Command)
 }
 
 func TestGetXenonEnvVar(t *testing.T) {
@@ -143,7 +143,7 @@ func TestGetXenonLivenessProbe(t *testing.T) {
 				Command: []string{
 					"sh",
 					"-c",
-					"pgrep xenon && xenoncli xenon ping",
+					"while  [ -f '/etc/xenon/sleep-forever' ] ;do sleep 2;done;pgrep xenon && xenoncli xenon ping",
 				},
 			},
 		},
@@ -160,7 +160,7 @@ func TestGetXenonReadinessProbe(t *testing.T) {
 	readinessProbe := &corev1.Probe{
 		ProbeHandler: corev1.ProbeHandler{
 			Exec: &corev1.ExecAction{
-				Command: []string{"sh", "-c", "xenoncli xenon ping"},
+				Command: []string{"sh", "-c", "while  [ -f '/etc/xenon/sleep-forever' ] ;do sleep 2;done; xenoncli xenon ping"},
 			},
 		},
 		InitialDelaySeconds: 10,