From b6ac9ba9f642015b6df2bf3c522e678d889e1164 Mon Sep 17 00:00:00 2001 From: Jonah Back Date: Thu, 3 Feb 2022 16:01:16 -0800 Subject: [PATCH] fix: check for issuing condition on Certificate (#7217) Signed-off-by: Jonah Back Co-authored-by: Alexander Matyushentsev --- .../cert-manager.io/Certificate/health.lua | 5 +++ .../Certificate/health_test.yaml | 4 ++ .../testdata/progressing_issuing.yaml | 37 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 resource_customizations/cert-manager.io/Certificate/testdata/progressing_issuing.yaml diff --git a/resource_customizations/cert-manager.io/Certificate/health.lua b/resource_customizations/cert-manager.io/Certificate/health.lua index 61b28c84b86ee..209ebb596e149 100644 --- a/resource_customizations/cert-manager.io/Certificate/health.lua +++ b/resource_customizations/cert-manager.io/Certificate/health.lua @@ -2,6 +2,11 @@ hs = {} if obj.status ~= nil then if obj.status.conditions ~= nil then for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Issuing" and condition.status == "True" then + hs.status = "Progressing" + hs.message = condition.message + return hs + end if condition.type == "Ready" and condition.status == "False" then hs.status = "Degraded" hs.message = condition.message diff --git a/resource_customizations/cert-manager.io/Certificate/health_test.yaml b/resource_customizations/cert-manager.io/Certificate/health_test.yaml index 9b00429539cf6..ebf8e75e89064 100644 --- a/resource_customizations/cert-manager.io/Certificate/health_test.yaml +++ b/resource_customizations/cert-manager.io/Certificate/health_test.yaml @@ -3,6 +3,10 @@ tests: status: Progressing message: Waiting for certificate inputPath: testdata/progressing_noStatus.yaml +- healthStatus: + status: Progressing + message: Issuing certificate as Secret does not exist + inputPath: testdata/progressing_issuing.yaml - healthStatus: status: Degraded message: 'Resource validation failed: spec.acme.config: Required value: no ACME diff --git a/resource_customizations/cert-manager.io/Certificate/testdata/progressing_issuing.yaml b/resource_customizations/cert-manager.io/Certificate/testdata/progressing_issuing.yaml new file mode 100644 index 0000000000000..acde21e3dc905 --- /dev/null +++ b/resource_customizations/cert-manager.io/Certificate/testdata/progressing_issuing.yaml @@ -0,0 +1,37 @@ +apiVersion: cert-manager.io/v1alpha2 +kind: Certificate +metadata: + creationTimestamp: '2018-11-07T00:06:12Z' + generation: 1 + name: test-cert + namespace: argocd + resourceVersion: '64763033' + selfLink: /apis/cert-manager.io/v1alpha2/namespaces/argocd/certificates/test-cert + uid: e6cfba50-314d-11e9-be3f-42010a800011 +spec: + acme: + config: + - domains: + - cd.apps.argoproj.io + http01: + ingress: http01 + commonName: cd.apps.argoproj.io + dnsNames: + - cd.apps.argoproj.io + issuerRef: + kind: Issuer + name: argo-cd-issuer + secretName: test-secret +status: + conditions: + - lastTransitionTime: '2021-09-15T02:10:00Z' + message: Issuing certificate as Secret does not exist + reason: DoesNotExist + status: 'True' + type: Issuing + - lastTransitionTime: '2021-09-15T02:10:00Z' + message: Issuing certificate as Secret does not exist + reason: DoesNotExist + status: 'False' + type: Ready +