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

Fix policy healthcheck #37

Merged
Merged
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
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
Loading