github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/postgresql.cnpg.io/Cluster/health.lua (about)

     1  local hs = {}
     2  
     3  local cnpgStatus = {
     4      ["Cluster in healthy state"] = "Healthy",
     5      ["Setting up primary"] = "Progressing",
     6      ["Setting up primary"] = "Progressing",
     7      ["Creating a new replica"] = "Progressing",
     8      ["Upgrading cluster"] = "Progressing",
     9      ["Waiting for the instances to become active"] = "Progressing",
    10      ["Promoting to primary cluster"] = "Progressing",
    11      ["Switchover in progress"] = "Degraded",
    12      ["Failing over"] = "Degraded",
    13      ["Upgrading Postgres major version"] = "Degraded",
    14      ["Cluster upgrade delayed"] = "Degraded",
    15      ["Waiting for user action"] = "Degraded",
    16      ["Primary instance is being restarted in-place"] = "Degraded",
    17      ["Primary instance is being restarted without a switchover"] = "Degraded",
    18      ["Cluster cannot execute instance online upgrade due to missing architecture binary"] = "Degraded",
    19      ["Online upgrade in progress"] = "Degraded",
    20      ["Applying configuration"] = "Degraded",
    21      ["Unable to create required cluster objects"] = "Suspended",
    22      ["Cluster cannot proceed to reconciliation due to an unknown plugin being required"] = "Suspended",
    23      ["Cluster has incomplete or invalid image catalog"] = "Suspended",
    24      ["Cluster is unrecoverable and needs manual intervention"] = "Suspended",
    25  }
    26  
    27  function hibernating(obj)
    28      for i, condition in pairs(obj.status.conditions) do
    29          if condition.type == "cnpg.io/hibernation" then
    30              return condition
    31          end
    32      end
    33      return nil
    34  end
    35  
    36  if obj.status ~= nil and obj.status.conditions ~= nil then
    37      local hibernation = hibernating(obj)
    38      if hibernation ~= nil then
    39          if hibernation.status == "True" then
    40              hs.status = "Suspended"
    41              hs.message = hibernation.message
    42              return hs
    43          else
    44              hs.status = "Degraded"
    45              hs.message = hibernation.message
    46              return hs
    47          end
    48      end
    49      statusState = cnpgStatus[obj.status.phase]
    50      if statusState ~= nil then
    51          hs.status = statusState
    52          hs.message = obj.status.phaseReason
    53          return hs
    54      else
    55          hs.status = "Unknown"
    56          hs.message = obj.status.phaseReason
    57          return hs
    58      end
    59  end
    60  
    61  hs.status = "Progressing"
    62  hs.message = obj.status.phaseReason
    63  return hs