diff --git a/build/Dockerfile b/build/Dockerfile index 1e18a7587..a11a5ab35 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -31,8 +31,8 @@ RUN GOOS=$GOOS GOARCH=${TARGETARCH} CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFL && cp -r build/_output/bin/pitr /usr/local/bin/pitr RUN GOOS=$GOOS GOARCH=${TARGETARCH} CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFLAGS \ - go build -o build/_output/bin/mysql-state-monitor \ - cmd/mysql-state-monitor/main.go \ + go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH -X main.BuildTime=$BUILD_TIME" \ + -o build/_output/bin/mysql-state-monitor cmd/mysql-state-monitor/main.go \ && cp -r build/_output/bin/mysql-state-monitor /usr/local/bin/mysql-state-monitor # Looking for all possible License/Notice files and copying them to the image diff --git a/build/readiness-check.sh b/build/readiness-check.sh index de0464958..767387275 100755 --- a/build/readiness-check.sh +++ b/build/readiness-check.sh @@ -16,12 +16,6 @@ MYSQL_PASSWORD="${mysql_pass:-$MONITOR_PASSWORD}" DEFAULTS_EXTRA_FILE=${DEFAULTS_EXTRA_FILE:-/etc/my.cnf} AVAILABLE_WHEN_DONOR=${AVAILABLE_WHEN_DONOR:-1} NODE_IP=$(hostname -I | awk ' { print $1 } ') -MYSQL_STATE=ready -MYSQL_VERSION=$(mysqld -V | awk '{print $3}' | awk -F'.' '{print $1"."$2}') -if [[ ${MYSQL_VERSION} =~ ^(8\.0|8\.4)$ && -f ${MYSQL_STATE_FILE} ]]; then - MYSQL_STATE=$(tr -d '\0' < ${MYSQL_STATE_FILE}) -fi - #Timeout exists for instances where mysqld may be hung TIMEOUT=$((${READINESS_CHECK_TIMEOUT:-10} - 1)) @@ -41,8 +35,7 @@ WSREP_STATUS=($(MYSQL_PWD="${MYSQL_PASSWORD}" $MYSQL_CMDLINE --init-command="SET sed -n -e '2p' -e '5p' | tr '\n' ' ')) set -x -if [[ "${MYSQL_STATE}" == "ready" && ${WSREP_STATUS[1]} == 'Primary' && - (${WSREP_STATUS[0]} -eq 4 || (${WSREP_STATUS[0]} -eq 2 && $AVAILABLE_WHEN_DONOR -eq 1)) ]]; then +if [[ ${WSREP_STATUS[1]} == 'Primary' && (${WSREP_STATUS[0]} -eq 4 || (${WSREP_STATUS[0]} -eq 2 && $AVAILABLE_WHEN_DONOR -eq 1)) ]]; then exit 0 else exit 1 diff --git a/cmd/mysql-state-monitor/main.go b/cmd/mysql-state-monitor/main.go index 58f7c04a5..33468edb7 100644 --- a/cmd/mysql-state-monitor/main.go +++ b/cmd/mysql-state-monitor/main.go @@ -8,6 +8,12 @@ import ( "strings" ) +var ( + GitCommit string + GitBranch string + BuildTime string +) + type MySQLState string const ( @@ -56,6 +62,7 @@ func parseDatum(datum string) MySQLState { "Components initialization in progress", "Components initialization successful", "Connection shutdown complete", + "Execution of SQL Commands from Init-file in progress", "Execution of SQL Commands from Init-file successful", "Initialization of dynamic plugins in progress", "Initialization of dynamic plugins successful", @@ -91,7 +98,8 @@ func parseDatum(datum string) MySQLState { } func main() { - log.Println("Starting mysql-state-monitor") + log.Println("Starting mysql-state-monitor...") + log.Printf("GitCommit=%s GitBranch=%s BuildTime=%s", GitCommit, GitBranch, BuildTime) socketPath, ok := os.LookupEnv("NOTIFY_SOCKET") if !ok { diff --git a/pkg/apis/pxc/v1/pxc_types.go b/pkg/apis/pxc/v1/pxc_types.go index fa23e5b90..160e62b39 100644 --- a/pkg/apis/pxc/v1/pxc_types.go +++ b/pkg/apis/pxc/v1/pxc_types.go @@ -417,6 +417,14 @@ func (cr *PerconaXtraDBCluster) Validate() error { return errors.Errorf("ProxySQL or HAProxy should be enabled if SmartUpdate set") } + customUsers := make(map[string]int8, len(c.Users)) + for _, user := range c.Users { + customUsers[user.Name]++ + if customUsers[user.Name] > 1 { + return errors.Errorf("user %s is duplicated", user.Name) + } + } + return nil }