Skip to content

Commit

Permalink
feat: add health-checks for Percona XtraDB cluster (#13093)
Browse files Browse the repository at this point in the history
* feat: Add health-checks for Percona XtraDB cluster

Signed-off-by: Thomas Decaux <ebuildy@gmail.com>
Signed-off-by: ebuildy <ebuildy@gmail.com>

* add tests

Signed-off-by: ebuildy <ebuildy@gmail.com>

---------

Signed-off-by: Thomas Decaux <ebuildy@gmail.com>
Signed-off-by: ebuildy <ebuildy@gmail.com>
  • Loading branch information
ebuildy authored May 28, 2023
1 parent 9656795 commit 64e718c
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
hs = {}
if obj.status ~= nil then

if obj.status.state == "initializing" then
hs.status = "Progressing"
hs.message = obj.status.ready .. "/" .. obj.status.size .. " node(s) are ready"
return hs
end

if obj.status.state == "ready" then
hs.status = "Healthy"
hs.message = obj.status.ready .. "/" .. obj.status.size .. " node(s) are ready"
return hs
end

if obj.status.state == "paused" then
hs.status = "Unknown"
hs.message = "Cluster is paused"
return hs
end

if obj.status.state == "stopping" then
hs.status = "Degraded"
hs.message = "Cluster is stopping (" .. obj.status.ready .. "/" .. obj.status.size .. " node(s) are ready)"
return hs
end

if obj.status.state == "error" then
hs.status = "Degraded"
hs.message = "Cluster is on error: " .. table.concat(obj.status.messages, ", ")
return hs
end

end

hs.status = "Unknown"
hs.message = "Cluster status is unknown. Ensure your ArgoCD is current and then check for/file a bug report: https://github.com/argoproj/argo-cd/issues"
return hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
tests:
- healthStatus:
status: Progressing
message: "0/1 node(s) are ready"
inputPath: testdata/initializing.yaml
- healthStatus:
status: Healthy
message: "1/1 node(s) are ready"
inputPath: testdata/ready.yaml
- healthStatus:
status: Unknown
message: "Cluster is paused"
inputPath: testdata/paused.yaml
- healthStatus:
status: Degraded
message: "Cluster is stopping (1/2 node(s) are ready)"
inputPath: testdata/stopping.yaml
- healthStatus:
status: Degraded
message: "Cluster is on error: we lost node"
inputPath: testdata/error.yaml
- healthStatus:
status: Unknown
message: "Cluster status is unknown. Ensure your ArgoCD is current and then check for/file a bug report: https://github.com/argoproj/argo-cd/issues"
inputPath: testdata/unknown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: quickstart
spec: {}
status:
backup: {}
haproxy: {}
host: pxc-mysql-pxc
logcollector: {}
observedGeneration: 1
pmm: {}
proxysql: {}
pxc:
image: ''
ready: 1
size: 2
status: error
version: 8.0.21-12.1
ready: 1
size: 2
state: error
messages:
- we lost node
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: quickstart
spec: {}
status:
backup: {}
haproxy: {}
host: pxc-mysql-pxc
logcollector: {}
observedGeneration: 1
pmm: {}
proxysql: {}
pxc:
image: ''
ready: 0
size: 1
status: initializing
version: 8.0.21-12.1
ready: 0
size: 1
state: initializing
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: quickstart
spec: {}
status:
backup: {}
haproxy: {}
host: pxc-mysql-pxc
logcollector: {}
observedGeneration: 1
pmm: {}
proxysql: {}
pxc:
image: ''
ready: 1
size: 1
status: paused
version: 8.0.21-12.1
ready: 1
size: 1
state: paused
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: quickstart
spec: {}
status:
backup: {}
haproxy: {}
host: pxc-mysql-pxc
logcollector: {}
observedGeneration: 1
pmm: {}
proxysql: {}
pxc:
image: ''
ready: 1
size: 1
status: ready
version: 8.0.21-12.1
ready: 1
size: 1
state: ready
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: quickstart
spec: {}
status:
backup: {}
haproxy: {}
host: pxc-mysql-pxc
logcollector: {}
observedGeneration: 1
pmm: {}
proxysql: {}
pxc:
image: ''
ready: 1
size: 2
status: stopping
version: 8.0.21-12.1
ready: 1
size: 2
state: stopping
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: quickstart
spec: {}
status:
backup: {}
haproxy: {}
host: pxc-mysql-pxc
logcollector: {}
observedGeneration: 1
pmm: {}
proxysql: {}
pxc:
image: ''
ready: 1
size: 1
status: dontknow
version: 8.0.21-12.1
ready: 1
size: 1
state: dontknow

0 comments on commit 64e718c

Please sign in to comment.