-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add health-checks for Percona XtraDB cluster (#13093)
* 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
Showing
8 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
resource_customizations/pxc.percona.com/PerconaXtraDBCluster/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
25 changes: 25 additions & 0 deletions
25
resource_customizations/pxc.percona.com/PerconaXtraDBCluster/health_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
24 changes: 24 additions & 0 deletions
24
resource_customizations/pxc.percona.com/PerconaXtraDBCluster/testdata/error.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
22 changes: 22 additions & 0 deletions
22
resource_customizations/pxc.percona.com/PerconaXtraDBCluster/testdata/initializing.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
22 changes: 22 additions & 0 deletions
22
resource_customizations/pxc.percona.com/PerconaXtraDBCluster/testdata/paused.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
22 changes: 22 additions & 0 deletions
22
resource_customizations/pxc.percona.com/PerconaXtraDBCluster/testdata/ready.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
22 changes: 22 additions & 0 deletions
22
resource_customizations/pxc.percona.com/PerconaXtraDBCluster/testdata/stopping.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
22 changes: 22 additions & 0 deletions
22
resource_customizations/pxc.percona.com/PerconaXtraDBCluster/testdata/unknown.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |