github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/numaplane.numaproj.io/ISBServiceRollout/health.lua (about) 1 -- return true if degraded, along with the reason 2 function isDegraded(obj) 3 if obj.status == nil then 4 return false, "" 5 end 6 -- check phase=Failed, healthy condition failed, progressive upgrade failed 7 if obj.status.phase == "Failed" then 8 return true, obj.status.message 9 end 10 11 if obj.status.conditions ~= nil then 12 for i, condition in ipairs(obj.status.conditions) do 13 if condition.type == "ChildResourcesHealthy" and condition.status == "False" and condition.reason == "ISBSvcFailed" then 14 return true, condition.message 15 elseif condition.type == "ProgressiveUpgradeSucceeded" and condition.status == "False" then 16 return true, "Progressive upgrade failed" 17 end 18 end 19 end 20 21 return false, "" 22 end 23 24 function isProgressing(obj) 25 -- if there's no Status at all, we haven't been reconciled 26 if obj.status == nil then 27 return true, "Not yet reconciled" 28 end 29 30 if obj.metadata.generation ~= obj.status.observedGeneration then 31 return true, "Not yet reconciled" 32 end 33 34 -- if we are in the middle of an upgrade 35 if obj.status.upgradeInProgress ~= nil and obj.status.upgradeInProgress ~= "" or obj.status.phase == "Pending" then 36 -- first check if Progressive Upgrade Failed; in that case, we won't return true (because "Degraded" will take precedence) 37 progressiveUpgradeFailed = false 38 if obj.status.conditions ~= nil then 39 for i, condition in ipairs(obj.status.conditions) do 40 if condition.type == "ProgressiveUpgradeSucceeded" and condition.status == "False" then 41 progressiveUpgradeFailed = true 42 end 43 end 44 end 45 46 if progressiveUpgradeFailed == false then 47 return true, "Update in progress" 48 end 49 end 50 51 -- if the child is Progressing 52 if obj.status.conditions ~= nil then 53 for i, condition in ipairs(obj.status.conditions) do 54 if condition.type == "ChildResourcesHealthy" and condition.status == "False" and condition.reason == "Progressing" then 55 return true, "Child Progressing" 56 end 57 end 58 end 59 60 return false, "" 61 end 62 63 -- return true if healthy, along with the reason 64 function isHealthy(obj) 65 if obj.status == nil then 66 return false, "" 67 end 68 69 if obj.status.conditions ~= nil then 70 for i, condition in ipairs(obj.status.conditions) do 71 if condition.type == "ChildResourcesHealthy" and condition.status == "True" then 72 return true, "Healthy" 73 end 74 end 75 end 76 end 77 78 local hs = {} 79 80 81 progressing, reason = isProgressing(obj) 82 if progressing then 83 hs.status = "Progressing" 84 hs.message = reason 85 return hs 86 end 87 88 degraded, reason = isDegraded(obj) 89 if degraded then 90 hs.status = "Degraded" 91 hs.message = reason 92 return hs 93 end 94 95 healthy, reason = isHealthy(obj) 96 if healthy then 97 hs.status = "Healthy" 98 hs.message = reason 99 return hs 100 end 101 102 hs.status = "Unknown" 103 hs.message = "Unknown status" 104 return hs