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