github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/promoter.argoproj.io/PullRequest/health.lua (about)

     1  local hs = {}
     2  hs.status = "Progressing"
     3  hs.message = "Initializing pull request"
     4  
     5  -- Check for deletion timestamp
     6  if obj.metadata.deletionTimestamp then
     7      hs.status = "Progressing"
     8      hs.message = "Pull request is being deleted"
     9      return hs
    10  end
    11  
    12  -- Check if status exists
    13  if not obj.status then
    14      return hs
    15  end
    16  
    17  -- Check for reconciliation conditions
    18  local hasReadyCondition = false
    19  if obj.status.conditions then
    20      for _, condition in ipairs(obj.status.conditions) do
    21          if condition.type == "Reconciled" or condition.type == "Ready" then
    22              hasReadyCondition = true
    23              -- Check observedGeneration vs metadata.generation within the reconciliation condition
    24              if condition.observedGeneration and obj.metadata.generation and condition.observedGeneration ~= obj.metadata.generation then
    25                  hs.status = "Progressing"
    26                  hs.message = "Waiting for pull request spec update to be observed"
    27                  return hs
    28              end
    29              if condition.status == "False" then
    30                  hs.status = "Degraded"
    31                  local msg = condition.message or "Unknown error"
    32                  local reason = condition.reason or "Unknown"
    33                  -- Don't include ReconciliationError in the message since it's redundant
    34                  if reason == "ReconciliationError" then
    35                      hs.message = "Pull request reconciliation failed: " .. msg
    36                  else
    37                      hs.message = "Pull request reconciliation failed (" .. reason .. "): " .. msg
    38                  end
    39                  return hs
    40              end
    41          end
    42      end
    43  end
    44  if not hasReadyCondition then
    45      hs.status = "Progressing"
    46      hs.message = "Pull request is not ready yet"
    47      return hs
    48  end
    49  
    50  -- This shouldn't happen, but if the condition says reconciliation succeeded, just trust it.
    51  if not obj.status.id or not obj.status.state then
    52      hs.status = "Healthy"
    53      hs.message = "Pull request is healthy"
    54      return hs
    55  end
    56  
    57  hs.status = "Healthy"
    58  hs.message = "Pull request is " .. obj.status.state .. " as PR " .. obj.status.id
    59  return hs