argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.83k stars 5.44k forks source link

Outdated documentation for argocd custom health check defintion #6719

Open MattFanto opened 3 years ago

MattFanto commented 3 years ago

Checklist:

Describe the bug

I tried to implement an health check for a custom resource, as part of the argo-cm as decribed here https://argoproj.github.io/argo-cd/operator-manual/health/#way-1-define-a-custom-health-check-in-argocd-cm-configmap

data:
  resource.customizations.health.cert-manager.io_Certificate: |
    hs = {}
    if obj.status ~= nil then
      if obj.status.conditions ~= nil then
        for i, condition in ipairs(obj.status.conditions) do
          if condition.type == "Ready" and condition.status == "False" then
            hs.status = "Degraded"
            hs.message = condition.message
            return hs
          end
          if condition.type == "Ready" and condition.status == "True" then
            hs.status = "Healthy"
            hs.message = condition.message
            return hs
          end
        end
      end
    end

    hs.status = "Progressing"
    hs.message = "Waiting for certificate"
    return hs

unfortuntately this approach didn't work and the Lua code was completely ignored by argo controller.

After few hours of troubleshooting I found this issue here https://github.com/argoproj/argo-cd/issues/3744 and I realized the documentation may be outdated, a working example for me is:

data:
      resource.customizations: |-
        cert-manager.io/Certificate:
          health.lua: |
            hs = {}
            if obj.status ~= nil then
              if obj.status.conditions ~= nil then
                for i, condition in ipairs(obj.status.conditions) do
                  if condition.type == "Ready" and condition.status == "False" then
                    hs.status = "Degraded"
                    hs.message = condition.message
                    return hs
                  end
                  if condition.type == "Ready" and condition.status == "True" then
                    hs.status = "Healthy"
                    hs.message = condition.message
                    return hs
                  end
                end
              end
            end

            hs.status = "Progressing"
            hs.message = "Waiting for certificate"
            return hs

Using this format

      resource.customizations: |-
        <group_kind>/<CustomResource>:
          health.lua: |

Instead of

      resource.customizations.health.<group_kind>_<CustomResource>: |

Solved my issue

To Reproduce

N.A.

Expected behavior

N.A.

Screenshots

N.A.

Version

2.0.4

Logs

N.A.

mkasinat commented 3 years ago

@MattFanto I have replaced my custom cert health as you defined but still cert health is not executing at all . Please see my config which is used . cert-manager.io/Certificate: health.lua: | print ("LUA:CERT") hs = {} if obj.status ~= nil then if obj.status.conditions ~= nil then for i, condition in ipairs(obj.status.conditions) do if condition.type == "Ready" and condition.status == "False" then hs.status = "Degraded" hs.message = condition.message return hs end if condition.type == "Ready" and condition.status == "True" then hs.status = "Healthy" hs.message = condition.message return hs end end end end

    hs.status = "Progressing"
    hs.message = "Waiting for certificate"
    return hs

bitnami.com/SealedSecret: health.lua: | hs = {} hs.status = "Healthy" hs.message = "Controller doesn't report resource status" return hs

argocd cm config: resource.customizations: |2- cert-manager.io/Certificate: health.lua: | print ("LUA:CERT") hs = {} if obj.status ~= nil then if obj.status.conditions ~= nil then for i, condition in ipairs(obj.status.conditions) do if condition.type == "Ready" and condition.status == "False" then hs.status = "Degraded" hs.message = condition.message return hs end if condition.type == "Ready" and condition.status == "True" then hs.status = "Healthy" hs.message = condition.message return hs end end end end

        hs.status = "Progressing"
        hs.message = "Waiting for certificate"
        return hs
 bitnami.com/SealedSecret:
    health.lua: |
      hs = {}
      hs.status = "Healthy"
      hs.message = "Controller doesn't report resource status"
      return hs

do you any idea or anything wrong in my config?

ThoTischner commented 3 years ago

@MattFanto I have replaced my custom cert health as you defined but still cert health is not executing at all . Please see my config which is used . cert-manager.io/Certificate: health.lua: | print ("LUA:CERT") hs = {} if obj.status ~= nil then if obj.status.conditions ~= nil then for i, condition in ipairs(obj.status.conditions) do if condition.type == "Ready" and condition.status == "False" then hs.status = "Degraded" hs.message = condition.message return hs end if condition.type == "Ready" and condition.status == "True" then hs.status = "Healthy" hs.message = condition.message return hs end end end end

    hs.status = "Progressing"
    hs.message = "Waiting for certificate"
    return hs

bitnami.com/SealedSecret: health.lua: | hs = {} hs.status = "Healthy" hs.message = "Controller doesn't report resource status" return hs

argocd cm config: resource.customizations: |2- cert-manager.io/Certificate: health.lua: | print ("LUA:CERT") hs = {} if obj.status ~= nil then if obj.status.conditions ~= nil then for i, condition in ipairs(obj.status.conditions) do if condition.type == "Ready" and condition.status == "False" then hs.status = "Degraded" hs.message = condition.message return hs end if condition.type == "Ready" and condition.status == "True" then hs.status = "Healthy" hs.message = condition.message return hs end end end end

        hs.status = "Progressing"
        hs.message = "Waiting for certificate"
        return hs
 bitnami.com/SealedSecret:
    health.lua: |
      hs = {}
      hs.status = "Healthy"
      hs.message = "Controller doesn't report resource status"
      return hs

do you any idea or anything wrong in my config?

Can you fix your code block please ? Why the print ("LUA:CERT") ? Try to remove this line.

mkasinat commented 3 years ago

Yes I have removed the print statement and executed the code is it not at all considering even my certificate is unhealthy but still instance is showing as helathy only.i want the custom cert health suppose certificate is unhealthy I want my instance as unhealthy

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: ThoTischner @.> Sent: Wednesday, August 11, 2021 12:40:19 PM To: argoproj/argo-cd @.> Cc: Kasinathan, Makeshkumar @.>; Comment @.> Subject: Re: [argoproj/argo-cd] Outdated documentation for argocd custom health check defintion (#6719)

@MattFantohttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMattFanto&data=04%7C01%7Cmakeshkumar.kasinathan%40volvocars.com%7C0ee3af004eda4ef5559f08d95cb46aaf%7C81fa766ea34948678bf4ab35e250a08f%7C0%7C0%7C637642752222582415%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=iRhSuQdX%2BoZ7Nkp84o%2B1KIkrpP0%2BLbQkkDSGOdZ%2FbDo%3D&reserved=0 I have replaced my custom cert health as you defined but still cert health is not executing at all . Please see my config which is used . cert-manager.io/Certificate: health.lua: | print ("LUA:CERT") hs = {} if obj.status ~= nil then if obj.status.conditions ~= nil then for i, condition in ipairs(obj.status.conditions) do if condition.type == "Ready" and condition.status == "False" then hs.status = "Degraded" hs.message = condition.message return hs end if condition.type == "Ready" and condition.status == "True" then hs.status = "Healthy" hs.message = condition.message return hs end end end end

hs.status = "Progressing"
hs.message = "Waiting for certificate"
return hs

bitnami.com/SealedSecret: health.lua: | hs = {} hs.status = "Healthy" hs.message = "Controller doesn't report resource status" return hs

argocd cm config: resource.customizations: |2- cert-manager.io/Certificate: health.lua: | print ("LUA:CERT") hs = {} if obj.status ~= nil then if obj.status.conditions ~= nil then for i, condition in ipairs(obj.status.conditions) do if condition.type == "Ready" and condition.status == "False" then hs.status = "Degraded" hs.message = condition.message return hs end if condition.type == "Ready" and condition.status == "True" then hs.status = "Healthy" hs.message = condition.message return hs end end end end

    hs.status = "Progressing"
    hs.message = "Waiting for certificate"
    return hs

bitnami.com/SealedSecret: health.lua: | hs = {} hs.status = "Healthy" hs.message = "Controller doesn't report resource status" return hs

do you any idea or anything wrong in my config?

Can you fix your code block please ? Why the print ("LUA:CERT") ? Try to remove this line.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fargoproj%2Fargo-cd%2Fissues%2F6719%23issuecomment-896712387&data=04%7C01%7Cmakeshkumar.kasinathan%40volvocars.com%7C0ee3af004eda4ef5559f08d95cb46aaf%7C81fa766ea34948678bf4ab35e250a08f%7C0%7C0%7C637642752222592402%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=aXVQo8ZT%2FCQEBG0DMcILjs7rWqUA8aVPRP%2B7zWQzTCw%3D&reserved=0, or unsubscribehttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FASOTWIRVYKBKRKZLW42LHDDT4JHRHANCNFSM5AMGN5TQ&data=04%7C01%7Cmakeshkumar.kasinathan%40volvocars.com%7C0ee3af004eda4ef5559f08d95cb46aaf%7C81fa766ea34948678bf4ab35e250a08f%7C0%7C0%7C637642752222592402%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=5Ec1E4u%2BMxcCqGsuzohkL4Oz1a7XlGyj144fvt0omMM%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7Cmakeshkumar.kasinathan%40volvocars.com%7C0ee3af004eda4ef5559f08d95cb46aaf%7C81fa766ea34948678bf4ab35e250a08f%7C0%7C0%7C637642752222602393%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=btss5aHZ%2FPZaq4dT1lFKmRiTEHXI5L9A7vUXqExWpaI%3D&reserved=0 or Androidhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26utm_campaign%3Dnotification-email&data=04%7C01%7Cmakeshkumar.kasinathan%40volvocars.com%7C0ee3af004eda4ef5559f08d95cb46aaf%7C81fa766ea34948678bf4ab35e250a08f%7C0%7C0%7C637642752222602393%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Qjmw4syLdMWnHgvGvs2KifP0CGaEUtx4knMOAAgy3lk%3D&reserved=0.

alexmt commented 3 years ago

The https://argoproj.github.io/argo-cd/operator-manual/health/#way-1-define-a-custom-health-check-in-argocd-cm-configmap has lastest/not-released Argo CD documentation. Please use https://argo-cd.readthedocs.io/en/stable/operator-manual/health/#way-1-define-a-custom-health-check-in-argocd-cm-configmap instead.

ThoTischner commented 3 years ago

Yes I have removed the print statement and executed the code is it not at all considering even my certificate is unhealthy but still instance is showing as helathy only.i want the custom cert health suppose certificate is unhealthy I want my instance as unhealthy

Try to enable the openlibs: resource.customizations.useOpenLibs.cert-manager.io_Certificate: "true"

mkasinat commented 3 years ago

Yes I have removed the print statement and executed the code is it not at all considering even my certificate is unhealthy but still instance is showing as helathy only.i want the custom cert health suppose certificate is unhealthy I want my instance as unhealthy

Try to enable the openlibs: resource.customizations.useOpenLibs.cert-manager.io_Certificate: "true"

We are not able to enable the openlibs .

caerulescens commented 1 year ago

For anyone wondering the status of this ticket, the stable documentation is still wrong here. I was having the same issue trying to get the certificates as healthy, and the stable documentation answer doesn't work. The search engines don't surface this GitHub ticket, so I had to sift through the issues to find this. I think a lot of people are having the same experience.