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 10, 2024
2 parents ffa45dd + d119e53 commit f4bb946
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 13 deletions.
44 changes: 41 additions & 3 deletions cmd/mysql-state-monitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,58 @@ func parseDatum(datum string) MySQLState {
switch status {
case "Server is operational":
return MySQLReady
case "Server shutdown in progress":
case "Server shutdown in progress",
"Forceful shutdown of connections in progress",
"Graceful shutdown of connections in progress",
"Components initialization unsuccessful",
"Execution of SQL Commands from Init-file unsuccessful",
"Initialization of dynamic plugins unsuccessful",
"Initialization of MySQL system tables unsuccessful",
"InnoDB crash recovery unsuccessful",
"InnoDB initialization unsuccessful":
return MySQLDown
case "Server startup in progress",
"Data Dictionary upgrade in progress",
"Data Dictionary upgrade complete",
"Server initialization in progress",
"Server upgrade in progress",
"Server upgrade complete",
"Server downgrade in progress",
"Server downgrade complete",
"Data Dictionary upgrade in progress",
"Data Dictionary upgrade complete",
"Data Dictionary upgrade from MySQL 5.7 in progress",
"Data Dictionary upgrade from MySQL 5.7 complete",
"Components initialization in progress",
"Components initialization successful",
"Connection shutdown complete",
"Execution of SQL Commands from Init-file successful",
"Initialization of dynamic plugins in progress",
"Initialization of dynamic plugins successful",
"Initialization of MySQL system tables in progress",
"Initialization of MySQL system tables successful",
"InnoDB crash recovery in progress",
"InnoDB crash recovery successful",
"InnoDB initialization in progress",
"InnoDB initialization successful",
"Shutdown of plugins complete",
"Shutdown of components in progress",
"Shutdown of components successful",
"Shutdown of plugins in progress",
"Shutdown of replica threads in progress",
"Server shutdown complete": // we treat this as startup because during init, MySQL notifies this even if it's up
return MySQLStartup
}

// these statuses have variables in it
// that's why we're handling them separately
switch {
case strings.HasPrefix(status, "Pre DD shutdown of MySQL SE plugin"):
return MySQLStartup
case strings.HasPrefix(status, "Server shutdown complete"):
return MySQLStartup
case strings.HasPrefix(status, "Server initialization complete"):
return MySQLStartup
}

}

return MySQLUnknown
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/tls-issue-self/compare/pxc_some-name-enabled.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
generation: 10
generation: 9
name: some-name
spec:
backup:
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/tls-issue-self/compare/pxc_some-name.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
generation: 6
generation: 5
name: some-name
spec:
backup:
Expand Down
13 changes: 6 additions & 7 deletions e2e-tests/tls-issue-self/run
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ main() {

# generation = 2 on this step
desc 'check disabling tls'
kubectl_bin patch pxc "$cluster" --type=merge --patch '{"spec": {"tls":{"enabled": false}}}' # generation + 1 (total 3)
kubectl_bin patch pxc "$cluster" --type=merge --patch '{"spec": {"tls":{"enabled": false}, "unsafeFlags": {"tls": true}}}' # generation + 1 (total 3)
sleep 10
# operator performs:
# - patch .spec.pause to true (generation = 4)
# - patch spec.unsafeFlags.tls to true (generation = 5)
# - patch .spec.pause to false (generation = 6)
# - patch .spec.pause to false (generation = 5)
wait_cluster_consistency "$cluster" 3 2
desc 'secrets should be deleted'
if kubectl get secret "$cluster-ssl" &>/dev/null; then
Expand All @@ -47,12 +46,12 @@ main() {
compare_kubectl "pxc/$cluster"

desc 'check enabling tls'
kubectl_bin patch pxc "$cluster" --type=merge --patch '{"spec": {"tls":{"enabled": true}}}' # generation + 1 (total = 7)
kubectl_bin patch pxc "$cluster" --type=merge --patch '{"spec": {"tls":{"enabled": true}}}' # generation + 1 (total = 6)
sleep 10
# operator performs:
# - patch .spec.pause to true (generation = 8)
# - patch spec.unsafeFlags.tls to false (generation = 9)
# - patch .spec.pause to false (generation = 10)
# - patch .spec.pause to true (generation = 7)
# - patch spec.unsafeFlags.tls to false (generation = 8)
# - patch .spec.pause to false (generation = 9)
wait_cluster_consistency "$cluster" 3 2
compare_kubectl "pxc/$cluster" "-enabled"
desc 'secrets should be recreated'
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pxc/v1/pxc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ func (cr *PerconaXtraDBCluster) setProbesDefaults() {
}

func (cr *PerconaXtraDBCluster) checkSafeDefaults() error {
if !cr.Spec.Unsafe.TLS && !cr.TLSEnabled() {
if !cr.Spec.Unsafe.TLS && !*cr.Spec.TLS.Enabled {
return errors.New("TLS must be enabled. Set spec.unsafeFlags.tls to true to disable this check")
}

Expand Down

0 comments on commit f4bb946

Please sign in to comment.