diff --git a/Makefile b/Makefile index 4d4c396b..007e869e 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ vet: ## Run go vet against code. ENVTEST_ASSETS_DIR=$(shell pwd)/testbin test: manifests generate fmt vet ## Run tests. mkdir -p ${ENVTEST_ASSETS_DIR} - test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.9.2/hack/setup-envtest.sh + test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out ##@ Build diff --git a/cluster/cluster.go b/cluster/cluster.go index dfae722f..d10d0f3c 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -64,6 +64,8 @@ func (c *Cluster) Validate() error { return fmt.Errorf("spec.mysqlOpts.user cannot be root|%s|%s|%s", utils.ReplicationUser, utils.OperatorUser, utils.MetricsUser) } + // https://github.com/percona/percona-docker/blob/main/percona-server-5.7/ps-entry.sh#L159 + // ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'127.0.0.1'. if c.Spec.MysqlOpts.RootHost == "127.0.0.1" { return fmt.Errorf("spec.mysqlOpts.rootHost cannot be 127.0.0.1") } diff --git a/cluster/container/init_sidecar.go b/cluster/container/init_sidecar.go index d96bc72c..8514f340 100644 --- a/cluster/container/init_sidecar.go +++ b/cluster/container/init_sidecar.go @@ -87,7 +87,7 @@ func (c *initSidecar) getEnvVars() []corev1.EnvVar { Value: strconv.Itoa(int(*c.Spec.XenonOpts.ElectionTimeout)), }, { - Name: "MY_MYSQL_VERSION", + Name: "MYSQL_VERSION", Value: c.GetMySQLVersion(), }, getEnvVarFromSecret(sctName, "MYSQL_ROOT_PASSWORD", "root-password", false), diff --git a/cluster/container/init_sidecar_test.go b/cluster/container/init_sidecar_test.go index 52d961f0..687fb9b6 100644 --- a/cluster/container/init_sidecar_test.go +++ b/cluster/container/init_sidecar_test.go @@ -100,7 +100,7 @@ var ( Value: strconv.Itoa(int(*testInitSidecarCluster.Spec.XenonOpts.ElectionTimeout)), }, { - Name: "MY_MYSQL_VERSION", + Name: "MYSQL_VERSION", Value: "5.7.33", }, { diff --git a/cluster/syncer/statefulset.go b/cluster/syncer/statefulset.go index f3d068b9..50d72660 100644 --- a/cluster/syncer/statefulset.go +++ b/cluster/syncer/statefulset.go @@ -401,6 +401,7 @@ func (s *StatefulSetSyncer) ensurePodSpec() corev1.PodSpec { } } +// updatePVC used to update the pvc, check and remove the extra pvc. func (s *StatefulSetSyncer) updatePVC(ctx context.Context) error { pvcs := corev1.PersistentVolumeClaimList{} if err := s.cli.List(ctx, diff --git a/sidecar/config.go b/sidecar/config.go index de353ac1..e4a467d1 100644 --- a/sidecar/config.go +++ b/sidecar/config.go @@ -87,8 +87,10 @@ func NewConfig() *Config { mysqlVersion, _ = semver.Parse(utils.MySQLDefaultVersion) } - replicas, err := strconv.ParseInt(getEnvValue("REPLICAS"), 10, 32) + replicaStr := getEnvValue("REPLICAS") + replicas, err := strconv.ParseInt(replicaStr, 10, 32) if err != nil { + log.Error(err, "invalid environment values", "REPLICAS", replicaStr) panic(err) }