github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/gateway.networking.k8s.io/Gateway/health.lua (about) 1 local hs = {} 2 3 function checkConditions(conditions, conditionType) 4 for _, condition in ipairs(conditions) do 5 if condition.type == conditionType and condition.status == "False" then 6 return false, condition.message or ("Failed condition: " .. conditionType) 7 end 8 end 9 return true 10 end 11 12 if obj.status ~= nil then 13 if obj.status.conditions ~= nil then 14 local resolvedRefsFalse, resolvedRefsMsg = checkConditions(obj.status.conditions, "ResolvedRefs") 15 local acceptedFalse, acceptedMsg = checkConditions(obj.status.conditions, "Accepted") 16 17 if not resolvedRefsFalse then 18 hs.status = "Degraded" 19 hs.message = resolvedRefsMsg 20 return hs 21 end 22 23 if not acceptedFalse then 24 hs.status = "Degraded" 25 hs.message = acceptedMsg 26 return hs 27 end 28 29 local isProgressing = false 30 local progressingMsg = "" 31 32 for _, condition in ipairs(obj.status.conditions) do 33 if condition.type == "Programmed" and condition.status ~= "True" then 34 isProgressing = true 35 progressingMsg = condition.message or "Gateway is still being programmed" 36 break 37 end 38 end 39 40 if isProgressing then 41 hs.status = "Progressing" 42 hs.message = progressingMsg 43 return hs 44 end 45 end 46 47 if obj.status.listeners ~= nil then 48 for _, listener in ipairs(obj.status.listeners) do 49 if listener.conditions ~= nil then 50 local resolvedRefsFalse, resolvedRefsMsg = checkConditions(listener.conditions, "ResolvedRefs") 51 local acceptedFalse, acceptedMsg = checkConditions(listener.conditions, "Accepted") 52 53 if not resolvedRefsFalse then 54 hs.status = "Degraded" 55 hs.message = "Listener: " .. resolvedRefsMsg 56 return hs 57 end 58 59 if not acceptedFalse then 60 hs.status = "Degraded" 61 hs.message = "Listener: " .. acceptedMsg 62 return hs 63 end 64 65 local isProgressing = false 66 local progressingMsg = "" 67 68 for _, condition in ipairs(listener.conditions) do 69 if condition.type == "Programmed" and condition.status ~= "True" then 70 isProgressing = true 71 progressingMsg = condition.message or "Listener is still being programmed" 72 break 73 end 74 end 75 76 if isProgressing then 77 hs.status = "Progressing" 78 hs.message = "Listener: " .. progressingMsg 79 return hs 80 end 81 end 82 end 83 end 84 85 if obj.status.conditions ~= nil or (obj.status.listeners ~= nil and #obj.status.listeners > 0) then 86 hs.status = "Healthy" 87 hs.message = "Gateway is healthy" 88 return hs 89 end 90 end 91 92 hs.status = "Progressing" 93 hs.message = "Waiting for Gateway status" 94 return hs