Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(health): add Rabbitmq topology resource customizations #22066

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions resource_customizations/rabbitmq.com/Binding/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" then
if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then
hs.status = "Healthy"
hs.message = "RabbitMQ binding ready"
return hs
end

if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then
hs.status = "Degraded"
hs.message = "RabbitMQ binding failed to be created or updated"
return hs
end
end
end
end

hs.status = "Unknown"
hs.message = "RabbitMQ binding status is unknown"
return hs
13 changes: 13 additions & 0 deletions resource_customizations/rabbitmq.com/Binding/health_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests:
- healthStatus:
status: Degraded
message: RabbitMQ binding failed to be created or updated
inputPath: testdata/degraded.yaml
- healthStatus:
status: Unknown
message: RabbitMQ binding status is unknown
inputPath: testdata/unknown.yaml
- healthStatus:
status: Healthy
message: RabbitMQ binding ready
inputPath: testdata/healthy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: rabbitmq.com/v1beta1
kind: Binding
metadata:
labels:
app: example-rabbitmq
name: example-rabbitmq
namespace: example
spec:
destination: destination
destinationType: queue
rabbitmqClusterReference:
name: example-rabbitmq
routingKey: v1.example.request
source: operation-requests
vhost: /
status:
conditions:
- lastTransitionTime: 2025-02-24T17:51:10Z
reason: FailedCreateOrUpdate
status: "False"
type: Ready
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: rabbitmq.com/v1beta1
kind: Binding
metadata:
labels:
app: example-rabbitmq
name: example-rabbitmq
namespace: example
spec:
destination: destination
destinationType: queue
rabbitmqClusterReference:
name: example-rabbitmq
routingKey: v1.example.request
source: operation-requests
vhost: /
status:
conditions:
- lastTransitionTime: 2025-02-24T17:51:10Z
reason: SuccessfulCreateOrUpdate
status: "True"
type: Ready
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: rabbitmq.com/v1beta1
kind: Binding
metadata:
labels:
app: example-rabbitmq
name: example-rabbitmq
namespace: example
spec:
destination: destination
destinationType: queue
rabbitmqClusterReference:
name: example-rabbitmq
routingKey: v1.example.request
source: operation-requests
vhost: /
status: {}
22 changes: 22 additions & 0 deletions resource_customizations/rabbitmq.com/Exchange/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" then
if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then
hs.status = "Healthy"
hs.message = "RabbitMQ exchange ready"
return hs
end

if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then
hs.status = "Degraded"
hs.message = "RabbitMQ exchange failed to be created or updated"
return hs
end
end
end
end

hs.status = "Unknown"
hs.message = "RabbitMQ exchange status is unknown"
return hs
13 changes: 13 additions & 0 deletions resource_customizations/rabbitmq.com/Exchange/health_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests:
- healthStatus:
status: Degraded
message: RabbitMQ exchange failed to be created or updated
inputPath: testdata/degraded.yaml
- healthStatus:
status: Unknown
message: RabbitMQ exchange status is unknown
inputPath: testdata/unknown.yaml
- healthStatus:
status: Healthy
message: RabbitMQ exchange ready
inputPath: testdata/healthy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: rabbitmq.com/v1beta1
kind: Exchange
metadata:
generation: 3
name: example-rabbit
namespace: example-rabbit
spec:
autoDelete: false
durable: true
name: example-rabbit
rabbitmqClusterReference:
name: example-rabbit
type: topic
vhost: /
status:
conditions:
- lastTransitionTime: 2025-02-24T17:51:10Z
reason: FailedCreateOrUpdate
status: "False"
type: Ready
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: rabbitmq.com/v1beta1
kind: Exchange
metadata:
generation: 3
name: example-rabbit
namespace: example-rabbit
spec:
autoDelete: false
durable: true
name: example-rabbit
rabbitmqClusterReference:
name: example-rabbit
type: topic
vhost: /
status:
conditions:
- lastTransitionTime: 2025-02-24T17:51:10Z
reason: SuccessfulCreateOrUpdate
status: "True"
type: Ready
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: rabbitmq.com/v1beta1
kind: Exchange
metadata:
generation: 3
name: example-rabbit
namespace: example-rabbit
spec:
autoDelete: false
durable: true
name: example-rabbit
rabbitmqClusterReference:
name: example-rabbit
type: topic
vhost: /
status: {}
22 changes: 22 additions & 0 deletions resource_customizations/rabbitmq.com/Permission/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" then
if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then
hs.status = "Healthy"
hs.message = "RabbitMQ permission ready"
return hs
end

if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then
hs.status = "Degraded"
hs.message = "RabbitMQ permission failed to be created or updated"
return hs
end
end
end
end

hs.status = "Unknown"
hs.message = "RabbitMQ permission status is unknown"
return hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests:
- healthStatus:
status: Degraded
message: RabbitMQ permission failed to be created or updated
inputPath: testdata/degraded.yaml
- healthStatus:
status: Unknown
message: RabbitMQ permission status is unknown
inputPath: testdata/unknown.yaml
- healthStatus:
status: Healthy
message: RabbitMQ permission ready
inputPath: testdata/healthy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: rabbitmq.com/v1beta1
kind: Permission
metadata:
generation: 1
name: example-rabbit
namespace: example-rabbit
spec:
permissions:
configure: .*
read: .*
write: .*
rabbitmqClusterReference:
name: example-rabbit
namespace: exmple-rabbit
user: example_user
vhost: /
status:
conditions:
- lastTransitionTime: 2025-02-24T17:51:10Z
reason: FailedCreateOrUpdate
status: "False"
type: Ready
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: rabbitmq.com/v1beta1
kind: Permission
metadata:
generation: 1
name: example-rabbit
namespace: example-rabbit
spec:
permissions:
configure: .*
read: .*
write: .*
rabbitmqClusterReference:
name: example-rabbit
namespace: exmple-rabbit
user: example_user
vhost: /
status:
conditions:
- lastTransitionTime: 2025-02-24T17:51:10Z
reason: SuccessfulCreateOrUpdate
status: "True"
type: Ready
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: rabbitmq.com/v1beta1
kind: Permission
metadata:
generation: 1
name: example-rabbit
namespace: example-rabbit
spec:
permissions:
configure: .*
read: .*
write: .*
rabbitmqClusterReference:
name: example-rabbit
namespace: exmple-rabbit
user: example_user
vhost: /
status: {}
22 changes: 22 additions & 0 deletions resource_customizations/rabbitmq.com/Policy/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" then
if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then
hs.status = "Healthy"
hs.message = "RabbitMQ policy ready"
return hs
end

if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then
hs.status = "Degraded"
hs.message = "RabbitMQ policy failed to be created or updated"
return hs
end
end
end
end

hs.status = "Unknown"
hs.message = "RabbitMQ policy status is unknown"
return hs
13 changes: 13 additions & 0 deletions resource_customizations/rabbitmq.com/Policy/health_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests:
- healthStatus:
status: Degraded
message: RabbitMQ policy failed to be created or updated
inputPath: testdata/degraded.yaml
- healthStatus:
status: Unknown
message: RabbitMQ policy status is unknown
inputPath: testdata/unknown.yaml
- healthStatus:
status: Healthy
message: RabbitMQ policy ready
inputPath: testdata/healthy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: rabbitmq.com/v1beta1
kind: Policy
metadata:
namespace: example-rabbit
name: example-rabbit
spec:
name: example-rabbit
vhost: example-rabbit
pattern: .*
applyTo: queues
definition: {}
rabbitmqClusterReference:
name: example-rabbit
namespace: example-rabbit
status:
conditions:
- lastTransitionTime: 2025-02-24T17:51:10Z
reason: FailedCreateOrUpdate
status: "False"
type: Ready
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: rabbitmq.com/v1beta1
kind: Policy
metadata:
namespace: example-rabbit
name: example-rabbit
spec:
name: example-rabbit
vhost: example-rabbit
pattern: .*
applyTo: queues
definition: {}
rabbitmqClusterReference:
name: example-rabbit
namespace: example-rabbit
status:
conditions:
- lastTransitionTime: 2025-02-24T17:51:10Z
reason: SuccessfulCreateOrUpdate
status: "True"
type: Ready
observedGeneration: 1
Loading
Loading