mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
feat: add health check for ClusterResourceSet (#20746)
Signed-off-by: nueavv <nuguni@kakao.com>
This commit is contained in:
@@ -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
|
||||
if condition.type == "ResourcesApplied" and condition.status == "False" then
|
||||
hs.status = "Degraded"
|
||||
hs.message = condition.message
|
||||
return hs
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
return hs
|
||||
end
|
||||
|
||||
local hs = getStatus(obj)
|
||||
return hs
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user