Skip to content

Commit

Permalink
*: fix the reviewers' suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyass committed Jul 28, 2021
1 parent 5320b22 commit d6e3c7a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cluster/container/init_sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion cluster/container/init_sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ var (
Value: strconv.Itoa(int(*testInitSidecarCluster.Spec.XenonOpts.ElectionTimeout)),
},
{
Name: "MY_MYSQL_VERSION",
Name: "MYSQL_VERSION",
Value: "5.7.33",
},
{
Expand Down
1 change: 1 addition & 0 deletions cluster/syncer/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion sidecar/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit d6e3c7a

Please sign in to comment.