feat(health): resource customization for RabbitMQCluster (#15286)

Signed-off-by: Álvaro Aguilar <alvaro.aguilar@scrm.lidl>
Co-authored-by: Blake Pettersson <blake.pettersson@gmail.com>
This commit is contained in:
Álvaro Aguilar-Tablada Espinosa 2024-09-18 20:57:28 +02:00 committed by GitHub
parent 7f417e2be4
commit 7d28c89f36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 353 additions and 0 deletions

View file

@ -0,0 +1,53 @@
hs = {}
clusterAvailable = {}
allReplicasReady = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "ReconcileSuccess" and condition.status == "False" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
if condition.type == "ClusterAvailable" then
clusterAvailable.status = condition.status
clusterAvailable.message = condition.message
end
if condition.type == "AllReplicasReady" then
allReplicasReady.status = condition.status
allReplicasReady.message = condition.message
end
end
if clusterAvailable.status == "Unknown" or allReplicasReady.status == "Unknown" then
hs.status = "Degraded"
hs.message = "No statefulset or endpoints found"
return hs
end
if clusterAvailable.status == "False" then
hs.status = "Progressing"
hs.message = "Waiting for RabbitMQ cluster formation"
return hs
end
if allReplicasReady.status == "False" then
hs.status = "Progressing"
hs.message = "Waiting for RabbitMQ instances ready"
return hs
end
if clusterAvailable.status == "True" and allReplicasReady.status == "True" then
hs.status = "Healthy"
hs.message = "RabbitMQ cluster ready"
return hs
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for RabbitMQ Operator"
return hs

View file

@ -0,0 +1,29 @@
tests:
- healthStatus:
status: Degraded
message: Unknown 'foo' parameter
inputPath: testdata/degraded_badconfig.yaml
- healthStatus:
status: Degraded
message: No statefulset or endpoints found
inputPath: testdata/degraded_cluster_unknown.yaml
- healthStatus:
status: Degraded
message: No statefulset or endpoints found
inputPath: testdata/degraded_replicas_unknown.yaml
- healthStatus:
status: Progressing
message: Waiting for RabbitMQ Operator
inputPath: testdata/progressing_no_status.yaml
- healthStatus:
status: Progressing
message: Waiting for RabbitMQ cluster formation
inputPath: testdata/progressing_cluster_unavailable.yaml
- healthStatus:
status: Progressing
message: Waiting for RabbitMQ instances ready
inputPath: testdata/progressing_pods_not_ready.yaml
- healthStatus:
status: Healthy
message: RabbitMQ cluster ready
inputPath: testdata/healthy.yaml

View file

@ -0,0 +1,31 @@
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
labels:
app: example-rabbitmq
name: example-rabbitmq
namespace: example
spec:
image: docker.io/bitnami/rabbitmq:3.10.7-debian-11-r8
persistence:
storage: 32Gi
storageClassName: default
rabbitmq:
replicas: 3
resources:
limits:
cpu: 250m
memory: 1792Mi
requests:
cpu: 250m
memory: 1792Mi
service:
type: ClusterIP
foo: bar
status:
conditions:
- lastTransitionTime: "2023-08-30T07:44:39Z"
message: Unknown 'foo' parameter
reason: Initializing
status: "False"
type: ReconcileSuccess

View file

@ -0,0 +1,44 @@
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
labels:
app: example-rabbitmq
name: example-rabbitmq
namespace: example
spec:
image: docker.io/bitnami/rabbitmq:3.10.7-debian-11-r8
persistence:
storage: 32Gi
storageClassName: default
rabbitmq:
replicas: 3
resources:
limits:
cpu: 250m
memory: 1792Mi
requests:
cpu: 250m
memory: 1792Mi
service:
type: ClusterIP
status:
conditions:
- lastTransitionTime: "2023-08-30T07:44:34Z"
reason: NotAllPodsReady
message: 0/3 Pods ready
status: "False"
type: AllReplicasReady
- lastTransitionTime: "2023-08-30T07:37:06Z"
reason: CouldNotRetrieveEndpoints
message: Could not verify available service endpoints
status: "Unknown"
type: ClusterAvailable
- lastTransitionTime: "2023-08-30T07:33:06Z"
reason: NoWarnings
status: "True"
type: NoWarnings
- lastTransitionTime: "2023-08-30T07:44:39Z"
message: Finish reconciling
reason: Success
status: "True"
type: ReconcileSuccess

View file

@ -0,0 +1,44 @@
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
labels:
app: example-rabbitmq
name: example-rabbitmq
namespace: example
spec:
image: docker.io/bitnami/rabbitmq:3.10.7-debian-11-r8
persistence:
storage: 32Gi
storageClassName: default
rabbitmq:
replicas: 3
resources:
limits:
cpu: 250m
memory: 1792Mi
requests:
cpu: 250m
memory: 1792Mi
service:
type: ClusterIP
status:
conditions:
- lastTransitionTime: "2023-08-30T07:44:34Z"
reason: MissingStatefulSet
message: Could not find StatefulSet
status: "Unknown"
type: AllReplicasReady
- lastTransitionTime: "2023-08-30T07:37:06Z"
reason: NoEndpointsAvailable
message: The service has no endpoints available
status: "False"
type: ClusterAvailable
- lastTransitionTime: "2023-08-30T07:33:06Z"
reason: NoWarnings
status: "True"
type: NoWarnings
- lastTransitionTime: "2023-08-30T07:44:39Z"
message: Finish reconciling
reason: Success
status: "True"
type: ReconcileSuccess

View file

@ -0,0 +1,42 @@
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
labels:
app: example-rabbitmq
name: example-rabbitmq
namespace: example
spec:
image: docker.io/bitnami/rabbitmq:3.10.7-debian-11-r8
persistence:
storage: 32Gi
storageClassName: default
rabbitmq:
replicas: 3
resources:
limits:
cpu: 250m
memory: 1792Mi
requests:
cpu: 250m
memory: 1792Mi
service:
type: ClusterIP
status:
conditions:
- lastTransitionTime: "2023-08-30T07:44:34Z"
reason: AllPodsAreReady
status: "True"
type: AllReplicasReady
- lastTransitionTime: "2023-08-30T07:37:06Z"
reason: AtLeastOneEndpointAvailable
status: "True"
type: ClusterAvailable
- lastTransitionTime: "2023-08-30T07:33:06Z"
reason: NoWarnings
status: "True"
type: NoWarnings
- lastTransitionTime: "2023-08-30T07:44:39Z"
message: Finish reconciling
reason: Success
status: "True"
type: ReconcileSuccess

View file

@ -0,0 +1,44 @@
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
labels:
app: example-rabbitmq
name: example-rabbitmq
namespace: example
spec:
image: docker.io/bitnami/rabbitmq:3.10.7-debian-11-r8
persistence:
storage: 32Gi
storageClassName: default
rabbitmq:
replicas: 3
resources:
limits:
cpu: 250m
memory: 1792Mi
requests:
cpu: 250m
memory: 1792Mi
service:
type: ClusterIP
status:
conditions:
- lastTransitionTime: "2023-08-30T07:44:34Z"
reason: NotAllPodsReady
message: 0/3 Pods ready
status: "False"
type: AllReplicasReady
- lastTransitionTime: "2023-08-30T07:37:06Z"
reason: NoEndpointsAvailable
message: The service has no endpoints available
status: "False"
type: ClusterAvailable
- lastTransitionTime: "2023-08-30T07:33:06Z"
reason: NoWarnings
status: "True"
type: NoWarnings
- lastTransitionTime: "2023-08-30T07:44:39Z"
message: Finish reconciling
reason: Success
status: "True"
type: ReconcileSuccess

View file

@ -0,0 +1,23 @@
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
labels:
app: example-rabbitmq
name: example-rabbitmq
namespace: example
spec:
image: docker.io/bitnami/rabbitmq:3.10.7-debian-11-r8
persistence:
storage: 32Gi
storageClassName: default
rabbitmq:
replicas: 3
resources:
limits:
cpu: 250m
memory: 1792Mi
requests:
cpu: 250m
memory: 1792Mi
service:
type: ClusterIP

View file

@ -0,0 +1,43 @@
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
labels:
app: example-rabbitmq
name: example-rabbitmq
namespace: example
spec:
image: docker.io/bitnami/rabbitmq:3.10.7-debian-11-r8
persistence:
storage: 32Gi
storageClassName: default
rabbitmq:
replicas: 3
resources:
limits:
cpu: 250m
memory: 1792Mi
requests:
cpu: 250m
memory: 1792Mi
service:
type: ClusterIP
status:
conditions:
- lastTransitionTime: "2023-08-30T07:44:34Z"
reason: NotAllPodsReady
message: 1/3 Pods ready
status: "False"
type: AllReplicasReady
- lastTransitionTime: "2023-08-30T07:37:06Z"
reason: AtLeastOneEndpointAvailable
status: "True"
type: ClusterAvailable
- lastTransitionTime: "2023-08-30T07:33:06Z"
reason: NoWarnings
status: "True"
type: NoWarnings
- lastTransitionTime: "2023-08-30T07:44:39Z"
message: Finish reconciling
reason: Success
status: "True"
type: ReconcileSuccess