Skip to content

Instantly share code, notes, and snippets.

@thikade
Created September 26, 2022 13:18
Show Gist options
  • Save thikade/9aef2964ff564f58513c37a5f1289b39 to your computer and use it in GitHub Desktop.
Save thikade/9aef2964ff564f58513c37a5f1289b39 to your computer and use it in GitHub Desktop.
Overriden ArgoCD healthcheck for operator subscriptions to nicely work with manual approvals.
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/name: argocd-cm
app.kubernetes.io/part-of: argocd
name: argocd-cm
data:
resource.customizations: |
argoproj.io/Application:
health.lua: |
hs = {}
hs.status = "Progressing"
hs.message = ""
if obj.status ~= nil then
if obj.status.health ~= nil then
hs.status = obj.status.health.status
if obj.status.health.message ~= nil then
hs.message = obj.status.health.message
end
end
end
return hs
operators.coreos.com/Subscription:
health.lua: |
health_status = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
numDegraded = 0
numPending = 0
msg = ""
for i, condition in pairs(obj.status.conditions) do
msg = msg .. i .. ": " .. condition.type .. " | " .. condition.status .. "\n"
if condition.type == "InstallPlanPending" and condition.status == "True" then
numPending = numPending + 1
elseif (condition.type == "CatalogSourcesUnhealthy" or condition.type == "InstallPlanMissing" or condition.type == "InstallPlanFailed" or condition.type == "ResolutionFailed") and condition.status == "True" then
numDegraded = numDegraded + 1
end
end
if numDegraded == 0 and numPending == 0 then
health_status.status = "Healthy"
health_status.message = msg
return health_status
elseif numPending > 0 and numDegraded == 0 then
if obj.spec.installPlanApproval == "Manual" then
health_status.status = "Degraded"
else
health_status.status = "Progressing"
end
health_status.message = "An install plan for a subscription is pending installation"
return health_status
else
health_status.status = "Degraded"
health_status.message = msg
return health_status
end
end
end
health_status.status = "Progressing"
health_status.message = "An install plan for a subscription is pending installation"
return health_status
@thikade
Copy link
Author

thikade commented Sep 26, 2022

next update, try health_status.status = "Suspended" in L46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment