github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/apiextensions.k8s.io/CustomResourceDefinition/health.lua (about)

     1  local hs = {}
     2  
     3  -- Check if CRD is terminating
     4  if obj.metadata.deletionTimestamp ~= nil then
     5      hs.status = "Progressing"
     6      hs.message = "CRD is terminating"
     7      return hs
     8  end
     9  
    10  if obj.status.conditions == nil then
    11      hs.status = "Progressing"
    12      hs.message = "Status conditions not found"
    13      return hs
    14  end
    15  
    16  if #obj.status.conditions == 0 then
    17      hs.status = "Progressing"
    18      hs.message = "Status conditions not found"
    19      return hs
    20  end
    21  
    22  local isEstablished
    23  local conditionMsg = ""
    24  
    25  for _, condition in pairs(obj.status.conditions) do
    26  
    27      -- Check if CRD is terminating
    28      if condition.type == "Terminating" and condition.status == "True" then
    29          hs.status = "Progressing"
    30          hs.message = "CRD is terminating: " .. condition.message
    31          return hs
    32      end
    33  
    34      -- Check if K8s has accepted names for this CRD
    35      if condition.type == "NamesAccepted" and condition.status == "False" then
    36          hs.status = "Degraded"
    37          hs.message = "CRD names have not been accepted: " .. condition.message
    38          return hs
    39      end
    40  
    41      -- Checking if CRD has violations
    42      if condition.type == "NonStructuralSchema" and condition.status == "True" then
    43          hs.status = "Degraded"
    44          hs.message = "Schema violations found: " .. condition.message
    45          return hs
    46      end
    47  
    48      -- Checking if CRD is established
    49      if condition.type == "Established" and condition.status == "True" then
    50          isEstablished = true
    51          conditionMsg = condition.message
    52      end
    53  end
    54  
    55  if not isEstablished then
    56      hs.status = "Degraded"
    57      hs.message = "CRD is not established"
    58      return hs
    59  end
    60  
    61  hs.status = "Healthy"
    62  hs.message = "CRD is healthy"
    63  return hs