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: add health check for ClusterResourceSet #20746

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function getStatus(obj)
local hs = {}
hs.status = "Progressing"
hs.message = "Initializing cluster resource set"

if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do

-- Ready
if condition.type == "ResourcesApplied" and condition.status == "True" then
hs.status = "Healthy"
hs.message = "cluster resource set is applied"
return hs
end

-- Resources Applied
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resourced not applied?

if condition.type == "ResourcesApplied" and condition.status == "False" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What other conditions are possible? Should we consider them?


end
end
end
return hs
end

local hs = getStatus(obj)
return hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests:
- healthStatus:
status: Progressing
message: 'Initializing cluster resource set'
inputPath: testdata/progressing_resourceapplied.yaml
- healthStatus:
status: Degraded
message: 'Failed to apply resources'
inputPath: testdata/degraded_resourceapplied.yaml
- healthStatus:
status: Healthy
message: 'cluster resource set is applied'
inputPath: testdata/healthy_resourceapplied.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
finalizers:
- addons.cluster.x-k8s.io
generation: 1
labels:
app.argocd.io/instance: clustername
name: clustername-resource-set
namespace: capi-managed-cluster
spec:
clusterSelector:
matchLabels:
clusterName: clustername
resources:
- kind: ConfigMap
name: clustername-default-rbac
strategy: ApplyOnce
status:
conditions:
- lastTransitionTime: '2024-11-11T03:28:48Z'
message: "Failed to apply resources"
reason: RemoteClusterClientFailed
severity: Error
status: 'False'
type: ResourcesApplied
observedGeneration: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
finalizers:
- addons.cluster.x-k8s.io
generation: 2
labels:
app.argocd.io/instance: clustername
name: clustername-resource-set
namespace: capi-managed-cluster
spec:
clusterSelector:
matchLabels:
clusterName: clustername
resources:
- kind: ConfigMap
name: clustername-default-rbac
strategy: ApplyOnce
status:
conditions:
- lastTransitionTime: '2024-11-08T08:49:13Z'
status: 'True'
type: ResourcesApplied
observedGeneration: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
finalizers:
- addons.cluster.x-k8s.io
generation: 2
labels:
app.argocd.io/instance: clustername
name: clustername-resource-set
namespace: capi-managed-cluster
spec:
clusterSelector:
matchLabels:
clusterName: clustername
resources:
- kind: ConfigMap
name: clustername-default-rbac
strategy: ApplyOnce
Loading