Skip to content

Commit

Permalink
Merge branch 'main' into CLOUD-869
Browse files Browse the repository at this point in the history
  • Loading branch information
ptankov authored Dec 12, 2024
2 parents 6646808 + 317c7bb commit b168e9b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions build/readiness-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion cmd/mysql-state-monitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import (
"strings"
)

var (
GitCommit string
GitBranch string
BuildTime string
)

type MySQLState string

const (
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/pxc/v1/pxc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit b168e9b

Please sign in to comment.