github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/gateway.networking.k8s.io/HTTPRoute/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 -- isParentGenerationObserved checks if a parent's conditions match the current resource generation 13 -- For HTTPRoute, observedGeneration is stored in each condition within a parent 14 function isParentGenerationObserved(obj, parent) 15 if obj.metadata.generation == nil then 16 -- If no generation is set, accept all conditions 17 return true 18 end 19 20 if parent.conditions == nil or #parent.conditions == 0 then 21 return false 22 end 23 24 -- Check if all conditions have observedGeneration matching current generation 25 for _, condition in ipairs(parent.conditions) do 26 if condition.observedGeneration ~= nil then 27 if condition.observedGeneration ~= obj.metadata.generation then 28 return false 29 end 30 end 31 end 32 33 return true 34 end 35 36 if obj.status ~= nil then 37 if obj.status.parents ~= nil then 38 for _, parent in ipairs(obj.status.parents) do 39 if parent.conditions ~= nil then 40 -- Skip this parent if it's not from the current generation 41 if not isParentGenerationObserved(obj, parent) then 42 goto continue 43 end 44 45 local resolvedRefsFalse, resolvedRefsMsg = checkConditions(parent.conditions, "ResolvedRefs") 46 local acceptedFalse, acceptedMsg = checkConditions(parent.conditions, "Accepted") 47 48 if not resolvedRefsFalse then 49 hs.status = "Degraded" 50 hs.message = "Parent " .. (parent.parentRef.name or "") .. ": " .. resolvedRefsMsg 51 return hs 52 end 53 54 if not acceptedFalse then 55 hs.status = "Degraded" 56 hs.message = "Parent " .. (parent.parentRef.name or "") .. ": " .. acceptedMsg 57 return hs 58 end 59 60 local isProgressing = false 61 local progressingMsg = "" 62 63 for _, condition in ipairs(parent.conditions) do 64 if condition.type == "Programmed" and condition.status ~= "True" then 65 isProgressing = true 66 progressingMsg = condition.message or "Route is still being programmed" 67 break 68 end 69 end 70 71 if isProgressing then 72 hs.status = "Progressing" 73 hs.message = "Parent " .. (parent.parentRef.name or "") .. ": " .. progressingMsg 74 return hs 75 end 76 77 ::continue:: 78 end 79 end 80 81 if #obj.status.parents > 0 then 82 for _, parent in ipairs(obj.status.parents) do 83 if parent.conditions ~= nil and #parent.conditions > 0 then 84 -- Only mark as healthy if we found a parent from the current generation 85 if isParentGenerationObserved(obj, parent) then 86 hs.status = "Healthy" 87 hs.message = "HTTPRoute is healthy" 88 return hs 89 end 90 end 91 end 92 end 93 end 94 end 95 96 hs.status = "Progressing" 97 hs.message = "Waiting for HTTPRoute status" 98 return hs