2023-09-21 13:20:42 +00:00
|
|
|
local health_check = {}
|
2021-09-03 15:26:31 +00:00
|
|
|
if obj.status ~= nil then
|
2022-02-06 19:19:46 +00:00
|
|
|
if obj.status.conditions ~= nil and obj.status.replicas ~= nil then
|
2023-09-21 13:20:42 +00:00
|
|
|
local numTrue = 0
|
2021-09-03 15:26:31 +00:00
|
|
|
for i, condition in pairs(obj.status.conditions) do
|
2022-08-30 19:34:11 +00:00
|
|
|
if (condition.type == "Available" or (condition.type == "Progressing" and condition.reason == "NewReplicationControllerAvailable")) and condition.status == "True" then
|
2021-09-03 15:26:31 +00:00
|
|
|
numTrue = numTrue + 1
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-02-06 19:19:46 +00:00
|
|
|
if numTrue == 2 or obj.status.replicas == 0 then
|
2021-09-03 15:26:31 +00:00
|
|
|
health_check.status = "Healthy"
|
|
|
|
|
health_check.message = "replication controller successfully rolled out"
|
|
|
|
|
return health_check
|
|
|
|
|
elseif numTrue == 1 then
|
|
|
|
|
health_check.status = "Progressing"
|
|
|
|
|
health_check.message = "replication controller is waiting for pods to run"
|
|
|
|
|
return health_check
|
|
|
|
|
else
|
|
|
|
|
health_check.status = "Degraded"
|
|
|
|
|
health_check.message = "Deployment config is degraded"
|
|
|
|
|
return health_check
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
health_check.status = "Progressing"
|
|
|
|
|
health_check.message = "replication controller is waiting for pods to run"
|
|
|
|
|
return health_check
|