Skip to content

Commit

Permalink
Merge pull request #37 from mbaldessari/fix-health-check-policy
Browse files Browse the repository at this point in the history
Fix policy healthcheck
  • Loading branch information
mbaldessari authored Jan 7, 2025
2 parents c47cbbd + b8e53a9 commit 9af1f9a
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion templates/plumbing/argocd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,64 @@ spec:
# Adding health checks to argocd to prevent pvc resources
# that aren't bound state from blocking deployments
resourceHealthChecks:
# Drop once https://www.github.com/argoproj/argo-cd/pull/21297 merges
- kind: Policy
group: policy.open-cluster-management.io
check: |
hs = {}
if obj.status == nil then
hs.status = "Progressing"
hs.message = "Waiting for the status to be reported"
return hs
end
-- A policy will not have a compliant field but will have a placement key set if
-- it is not being applied to any clusters
if obj.status.compliant == nil and #obj.status.placement > 0 then
hs.status = "Healthy"
hs.message = "No clusters match this policy"
return hs
end
if obj.status.compliant == nil or obj.status.compliant == "Pending" then
hs.status = "Progressing"
hs.message = "Waiting for the status to be reported"
return hs
end
if obj.status.compliant == "Compliant" then
hs.status = "Healthy"
else
hs.status = "Degraded"
end
noncompliants = {}
if obj.status.status ~= nil then
-- "root" policy
for i, entry in ipairs(obj.status.status) do
if entry.compliant ~= "Compliant" then
table.insert(noncompliants, entry.clustername)
end
end
if #noncompliants == 0 then
hs.message = "All clusters are compliant"
else
hs.message = "NonCompliant clusters: " .. table.concat(noncompliants, ", ")
end
elseif obj.status.details ~= nil then
-- "replicated" policy
for i, entry in ipairs(obj.status.details) do
if entry.compliant ~= "Compliant" then
table.insert(noncompliants, entry.templateMeta.name)
end
end
if #noncompliants == 0 then
hs.message = "All templates are compliant"
else
hs.message = "NonCompliant templates: " .. table.concat(noncompliants, ", ")
end
end
return hs
- kind: PersistentVolumeClaim
check: |
hs = {}
Expand All @@ -35,7 +93,7 @@ spec:
return hs
# FIXME(bandini): To be dropped once 49431b9add9393ef2ece78d4f63968b6c10276e0 in argocd is in a relased version
- kind: InferenceService
- kind: InferenceService
group: serving.kserve.io
check: |
local health_status = {}
Expand Down

0 comments on commit 9af1f9a

Please sign in to comment.