Skip to content

Commit

Permalink
feat: add MariaDB CRD health checks (argoproj#13143)
Browse files Browse the repository at this point in the history
* feat: add MariaDB CRD health checks

Signed-off-by: Thomas Sirvent <vivi@vivide.re>

* feat: set Degraded health on MariaDB CRD error

Signed-off-by: Thomas Sirvent <vivi@vivide.re>

* style: add missing newline

Signed-off-by: Thomas Sirvent <vivi@vivide.re>

---------

Signed-off-by: Thomas Sirvent <vivi@vivide.re>
  • Loading branch information
Vidalee authored and xiaowu.zhu committed Aug 9, 2023
1 parent 8a5964b commit a2e4b25
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 0 deletions.
25 changes: 25 additions & 0 deletions resource_customizations/mariadb.mmontes.io/MariaDB/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
health_status = {}

if obj.status ~= nil and obj.status.conditions ~= nil then

for i, condition in ipairs(obj.status.conditions) do

health_status.message = condition.message

if condition.status == "False" then
if condition.reason == "Failed" then
health_status.status = "Degraded"
return health_status
end
health_status.status = "Progressing"
return health_status
end
end

health_status.status = "Healthy"
return health_status
end

health_status.status = "Progressing"
health_status.message = "No status info available"
return health_status
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
tests:
- healthStatus:
status: Progressing
message: "No status info available"
inputPath: testdata/no_status.yaml
- healthStatus:
status: Healthy
message: "Running"
inputPath: testdata/statefulset_ready.yaml
- healthStatus:
status: Progressing
message: "Not ready"
inputPath: testdata/statefulset_not_ready.yaml
- healthStatus:
status: Healthy
message: "Running"
inputPath: testdata/restore_complete.yaml
- healthStatus:
status: Progressing
message: "Restoring backup"
inputPath: testdata/restore_not_complete.yaml
- healthStatus:
status: Degraded
message: "Error creating ConfigMap"
inputPath: testdata/mariadb_error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: mariadb.mmontes.io/v1alpha1
kind: MariaDB
metadata:
name: mariadb-server
spec:
rootPasswordSecretKeyRef:
name: mariadb
key: root-password
image:
repository: mariadb
tag: "10.7.4"
pullPolicy: IfNotPresent
port: 3306
volumeClaimTemplate:
resources:
requests:
storage: 100Mi
storageClassName: standard
accessModes:
- ReadWriteOnce
status:
conditions:
- lastTransitionTime: '2023-04-20T15:31:15Z'
message: Error creating ConfigMap
reason: Failed
status: 'False'
type: Ready
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: mariadb.mmontes.io/v1alpha1
kind: MariaDB
metadata:
name: mariadb-server
spec:
rootPasswordSecretKeyRef:
name: mariadb
key: root-password
image:
repository: mariadb
tag: "10.7.4"
pullPolicy: IfNotPresent
port: 3306
volumeClaimTemplate:
resources:
requests:
storage: 100Mi
storageClassName: standard
accessModes:
- ReadWriteOnce
status:
revision: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: mariadb.mmontes.io/v1alpha1
kind: MariaDB
metadata:
name: mariadb-server
spec:
rootPasswordSecretKeyRef:
name: mariadb
key: root-password
image:
repository: mariadb
tag: "10.7.4"
pullPolicy: IfNotPresent
port: 3306
volumeClaimTemplate:
resources:
requests:
storage: 100Mi
storageClassName: standard
accessModes:
- ReadWriteOnce
status:
conditions:
- lastTransitionTime: "2023-04-05T14:18:01Z"
message: Ready
reason: RestoreComplete
status: "True"
type: Bootstrapped
- lastTransitionTime: "2023-04-05T14:18:02Z"
message: Running
reason: RestoreComplete
status: "True"
type: Ready
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: mariadb.mmontes.io/v1alpha1
kind: MariaDB
metadata:
name: mariadb-server
spec:
rootPasswordSecretKeyRef:
name: mariadb
key: root-password
image:
repository: mariadb
tag: "10.7.4"
pullPolicy: IfNotPresent
port: 3306
volumeClaimTemplate:
resources:
requests:
storage: 100Mi
storageClassName: standard
accessModes:
- ReadWriteOnce
status:
conditions:
- lastTransitionTime: "2023-04-05T14:18:01Z"
message: Restoring backup
reason: RestoreNotComplete
status: "False"
type: Ready
- lastTransitionTime: "2023-04-05T14:18:02Z"
message: Not ready
reason: RestoreNotComplete
status: "False"
type: Bootstrapped
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: mariadb.mmontes.io/v1alpha1
kind: MariaDB
metadata:
name: mariadb-server
spec:
rootPasswordSecretKeyRef:
name: mariadb
key: root-password
image:
repository: mariadb
tag: "10.7.4"
pullPolicy: IfNotPresent
port: 3306
volumeClaimTemplate:
resources:
requests:
storage: 100Mi
storageClassName: standard
accessModes:
- ReadWriteOnce
status:
conditions:
- lastTransitionTime: "2023-04-05T14:18:01Z"
message: Not ready
reason: StatefulSetNotReady
status: "False"
type: Ready
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: mariadb.mmontes.io/v1alpha1
kind: MariaDB
metadata:
name: mariadb-server
spec:
rootPasswordSecretKeyRef:
name: mariadb
key: root-password
image:
repository: mariadb
tag: "10.7.4"
pullPolicy: IfNotPresent
port: 3306
volumeClaimTemplate:
resources:
requests:
storage: 100Mi
storageClassName: standard
accessModes:
- ReadWriteOnce
status:
conditions:
- lastTransitionTime: "2023-04-05T14:18:01Z"
message: Running
reason: StatefulSetReady
status: "True"
type: Ready

0 comments on commit a2e4b25

Please sign in to comment.