github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/operators.coreos.com/Subscription/health.lua (about)

     1  local health_status = {}
     2  if obj.status ~= nil then
     3    if obj.status.conditions ~= nil then
     4      local numDegraded = 0
     5      local numPending = 0
     6      local msg = ""
     7      for i, condition in pairs(obj.status.conditions) do
     8        msg = msg .. i .. ": " .. condition.type .. " | " .. condition.status .. "\n"
     9        if condition.type == "InstallPlanPending" and condition.status == "True" then
    10          numPending = numPending + 1
    11        elseif (condition.type == "InstallPlanMissing" and condition.reason ~= "ReferencedInstallPlanNotFound") then
    12          numDegraded = numDegraded + 1
    13        elseif (condition.type == "CatalogSourcesUnhealthy" or condition.type == "InstallPlanFailed" or condition.type == "ResolutionFailed") and condition.status == "True" then
    14          numDegraded = numDegraded + 1
    15        end
    16      end
    17  
    18      -- Available states: undef/nil, UpgradeAvailable, UpgradePending, UpgradeFailed, AtLatestKnown
    19      -- Source: https://github.com/openshift/operator-framework-olm/blob/5e2c73b7663d0122c9dc3e59ea39e515a31e2719/staging/api/pkg/operators/v1alpha1/subscription_types.go#L17-L23
    20      if obj.status.state == nil  then
    21        numPending = numPending + 1
    22        msg = msg .. ".status.state not yet known\n"
    23      elseif obj.status.state == "" or obj.status.state == "UpgradeAvailable" or obj.status.state == "UpgradePending" then
    24        numPending = numPending + 1
    25        msg = msg .. ".status.state is '" .. obj.status.state .. "'\n"
    26      elseif obj.status.state == "UpgradeFailed" then
    27        numDegraded = numDegraded + 1
    28        msg = msg .. ".status.state is '" .. obj.status.state .. "'\n"
    29      else
    30        -- Last possiblity of .status.state: AtLatestKnown
    31        msg =  msg .. ".status.state is '" .. obj.status.state .. "'\n"
    32      end
    33   
    34      if numDegraded == 0 and numPending == 0 then
    35        health_status.status = "Healthy"
    36        health_status.message = msg
    37        return health_status
    38      elseif numPending > 0 and numDegraded == 0 then
    39        health_status.status = "Progressing"
    40        health_status.message = msg
    41        return health_status
    42      else
    43        health_status.status = "Degraded"
    44        health_status.message = msg
    45        return health_status
    46      end
    47    end
    48  end
    49  health_status.status = "Progressing"
    50  health_status.message = "An install plan for a subscription is pending installation"
    51  return health_status