argo-cd/resource_customizations/apps.kruise.io/DaemonSet/health.lua
Jingchao f980187f17
fix: openkruise health check npe error #19545 (#19660)
* test: add broken unit test data

Signed-off-by: Jingchao <alswlx@gmail.com>

* fix: npe error in kruise ds health-check

Signed-off-by: Jingchao <alswlx@gmail.com>

---------

Signed-off-by: Jingchao <alswlx@gmail.com>
2024-09-11 15:32:37 -07:00

35 lines
1.5 KiB
Lua

hs={ status = "Progressing", message = "Waiting for initialization" }
if obj.status ~= nil then
if obj.metadata.generation == obj.status.observedGeneration then
if obj.spec.updateStrategy.rollingUpdate.paused == true or not obj.status.updatedNumberScheduled then
hs.status = "Suspended"
hs.message = "Daemonset is paused"
return hs
elseif (obj.spec.updateStrategy.rollingUpdate.partition ~= nil) and (obj.spec.updateStrategy.rollingUpdate.partition ~= 0 and obj.metadata.generation > 1) then
if obj.status.updatedNumberScheduled > (obj.status.desiredNumberScheduled - obj.spec.updateStrategy.rollingUpdate.partition) then
hs.status = "Suspended"
hs.message = "Daemonset needs manual intervention"
return hs
end
elseif (obj.status.updatedNumberScheduled == obj.status.desiredNumberScheduled) and (obj.status.numberAvailable == obj.status.desiredNumberScheduled) then
hs.status = "Healthy"
hs.message = "All Daemonset workloads are ready and updated"
return hs
else
if (obj.status.updatedNumberScheduled == obj.status.desiredNumberScheduled) and (obj.status.numberUnavailable == obj.status.desiredNumberScheduled) then
hs.status = "Degraded"
hs.message = "Some pods are not ready or available"
return hs
end
end
end
end
return hs