fix(health-check): StorageCluster.ocs.openshift.io (#23393)

Signed-off-by: Jennifer Weir <contact@jenniferpweir.com>
This commit is contained in:
Jennifer Weir
2025-06-14 18:08:44 -04:00
committed by GitHub
parent 64198e8042
commit 2801a11efc
7 changed files with 154 additions and 103 deletions

View File

@@ -1,28 +1,31 @@
local hs = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for _, condition in pairs(obj.status.conditions) do
if condition.type == "Degraded" and condition.status == "True" then
hs.status = "Degraded"
hs.message = condition.message
return hs
elseif condition.type == "Progressing" and condition.status == "False" then
hs.status = "Progressing"
hs.message = condition.message
return hs
elseif condition.type == "Upgradeable" and condition.status == "True" then
hs.status = "Healthy"
hs.message = condition.message
return hs
elseif condition.type == "Available" and condition.status == "True" then
hs.status = "Healthy"
hs.message = condition.message
return hs
end
local hs_degraded = {}
local hs_progressing = {}
local hs_healthy = {}
local is_degraded = false
local is_progressing = false
local is_healthy = false
if obj ~= nil and obj.status ~= nil and obj.status.conditions ~= nil then
for _, condition in pairs(obj.status.conditions) do
if condition.type == "Degraded" and condition.status == "True" then
is_degraded = true
hs_degraded.status = "Degraded"
hs_degraded.message = condition.message
elseif condition.type == "Progressing" and condition.status == "True" then
is_progressing = true
hs_progressing.status = "Progressing"
hs_progressing.message = condition.message
elseif condition.type == "Available" and condition.status == "True" then
is_healthy = true
hs_healthy.status = "Healthy"
hs_healthy.message = condition.message
end
end
end
hs.status = "Progressing"
hs.message = "StorageCluster is still being initialized or is in an unknown state."
return hs
if is_degraded then
return hs_degraded
elseif is_progressing then
return hs_progressing
elseif is_healthy then
return hs_healthy
end
return { status = "Unknown", message = "StorageCluster is in an unknown state." }

View File

@@ -1,17 +1,13 @@
tests:
- healthStatus:
status: Degraded
message: "StorageCluster is degraded"
message: "CephCluster error: Failed to configure ceph cluster"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Progressing
message: "StorageCluster is progressing"
message: "Initializing StorageCluster"
inputPath: testdata/progressing.yaml
- healthStatus:
status: Healthy
message: "Reconcile completed successfully"
inputPath: testdata/healthy_available.yaml
- healthStatus:
status: Healthy
message: "StorageCluster is healthy and upgradeable"
inputPath: testdata/healthy_upgradeable.yaml
inputPath: testdata/available.yaml

View File

@@ -0,0 +1,65 @@
apiVersion: ocs.openshift.io/v1
kind: StorageCluster
metadata:
name: test-storagecluster
namespace: argocd
spec:
manageNodes: false
monDataDirHostPath: /var/lib/rook
storageDeviceSets:
- name: test-storagecluster-device-set
count: 1
resources:
limits:
cpu: "1"
memory: 2Gi
requests:
cpu: "1"
memory: 2Gi
portable: true
dataPVCTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
placement: {}
status:
conditions:
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: Version check successful
reason: VersionMatched
status: "False"
type: VersionMismatch
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: "Reconcile completed successfully"
reason: ReconcileCompleted
status: "True"
type: ReconcileComplete
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: "Reconcile completed successfully"
reason: ReconcileCompleted
status: "True"
type: Available
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: "Reconcile completed successfully"
reason: ReconcileCompleted
status: "False"
type: Progressing
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: Reconcile completed successfully
reason: ReconcileCompleted
status: "False"
type: Degraded
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: Reconcile completed successfully
reason: ReconcileCompleted
status: "True"
type: Upgradeable

View File

@@ -29,6 +29,37 @@ status:
conditions:
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: "StorageCluster is degraded"
message: Version check successful
reason: VersionMatched
status: "False"
type: VersionMismatch
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: "Reconcile completed successfully"
reason: ReconcileCompleted
status: "True"
type: ReconcileComplete
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: 'CephCluster error: Failed to configure ceph cluster'
reason: ClusterStateError
status: "False"
type: Available
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: "Reconcile completed successfully"
reason: ReconcileCompleted
status: "False"
type: Progressing
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: "CephCluster error: Failed to configure ceph cluster"
reason: ClusterStateError
status: "True"
type: Degraded
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: Reconcile completed successfully
reason: ReconcileCompleted
status: "True"
type: Upgradeable

View File

@@ -1,35 +0,0 @@
apiVersion: ocs.openshift.io/v1
kind: StorageCluster
metadata:
name: test-storagecluster
namespace: argocd
spec:
manageNodes: false
monDataDirHostPath: /var/lib/rook
storageDeviceSets:
- name: test-storagecluster-device-set
count: 1
resources:
limits:
cpu: "1"
memory: 2Gi
requests:
cpu: "1"
memory: 2Gi
portable: true
dataPVCTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
placement: {}
status:
conditions:
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: Reconcile completed successfully
reason: ReconcileCompleted
status: "True"
type: Available

View File

@@ -1,34 +0,0 @@
apiVersion: ocs.openshift.io/v1
kind: StorageCluster
metadata:
name: test-storagecluster
namespace: argocd
spec:
manageNodes: false
monDataDirHostPath: /var/lib/rook
storageDeviceSets:
- name: test-storagecluster-device-set
count: 1
resources:
limits:
cpu: "1"
memory: 2Gi
requests:
cpu: "1"
memory: 2Gi
portable: true
dataPVCTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
placement: {}
status:
conditions:
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: "StorageCluster is healthy and upgradeable"
status: "True"
type: Upgradeable

View File

@@ -29,6 +29,31 @@ status:
conditions:
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: "StorageCluster is progressing"
message: Version check successful
reason: VersionMatched
status: "False"
type: VersionMismatch
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: Initializing StorageCluster
reason: Init
status: "False"
type: Available
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: Initializing StorageCluster
reason: Init
status: "True"
type: Progressing
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: Initializing StorageCluster
reason: Init
status: "False"
type: Degraded
- lastHeartBeatTime: "2023-10-01T12:00:00Z"
lastTransitionTime: "2023-10-01T12:00:00Z"
message: Initializing StorageCluster
reason: Init
status: Unknown
type: Upgradeable