forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add MariaDB CRD health checks (argoproj#13143)
* 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
Showing
8 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
resource_customizations/mariadb.mmontes.io/MariaDB/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,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 |
25 changes: 25 additions & 0 deletions
25
resource_customizations/mariadb.mmontes.io/MariaDB/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: "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 |
27 changes: 27 additions & 0 deletions
27
resource_customizations/mariadb.mmontes.io/MariaDB/testdata/mariadb_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,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 |
22 changes: 22 additions & 0 deletions
22
resource_customizations/mariadb.mmontes.io/MariaDB/testdata/no_status.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: 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 |
32 changes: 32 additions & 0 deletions
32
resource_customizations/mariadb.mmontes.io/MariaDB/testdata/restore_complete.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,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 |
32 changes: 32 additions & 0 deletions
32
resource_customizations/mariadb.mmontes.io/MariaDB/testdata/restore_not_complete.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,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 |
27 changes: 27 additions & 0 deletions
27
resource_customizations/mariadb.mmontes.io/MariaDB/testdata/statefulset_not_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,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 |
27 changes: 27 additions & 0 deletions
27
resource_customizations/mariadb.mmontes.io/MariaDB/testdata/statefulset_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,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 |