From 3be957ac74da4c5770dab2a27a5345808b83529b Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Thu, 8 Aug 2024 15:04:53 +0545 Subject: [PATCH] feat: reconciliation failed kustomization health check --- pkg/health/health_test.go | 4 ++ pkg/health/statusMap.yaml | 3 ++ .../kustomization-reconciliation-failed.yaml | 37 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 pkg/health/testdata/kustomization-reconciliation-failed.yaml diff --git a/pkg/health/health_test.go b/pkg/health/health_test.go index 0c971ea..3566b8b 100644 --- a/pkg/health/health_test.go +++ b/pkg/health/health_test.go @@ -163,6 +163,10 @@ func TestHPA(t *testing.T) { assertAppHealth(t, "./testdata/hpa-v1-progressing-with-no-annotations.yaml", health.HealthStatusProgressing, health.HealthHealthy, false) } +func TestKustomization(t *testing.T) { + assertAppHealthMsg(t, "./testdata/kustomization-reconciliation-failed.yaml", "ReconciliationFailed", health.HealthUnhealthy, false, "CronJob/scale-dev-up namespace not specified: the server could not find the requested resource\n") +} + func TestPod(t *testing.T) { assertAppHealthWithOverwriteMsg(t, "./testdata/pod-not-ready-container-not-ready.yaml", map[string]string{ "2024-07-29T06:32:56Z": time.Now().Add(time.Minute * 10).Format(time.RFC3339), diff --git a/pkg/health/statusMap.yaml b/pkg/health/statusMap.yaml index 7d5e464..9760326 100644 --- a/pkg/health/statusMap.yaml +++ b/pkg/health/statusMap.yaml @@ -82,6 +82,9 @@ Deployment: Kustomization: conditions: Ready: + onFalse: + message: true + health: unhealthy ready: true message: true reasons: diff --git a/pkg/health/testdata/kustomization-reconciliation-failed.yaml b/pkg/health/testdata/kustomization-reconciliation-failed.yaml new file mode 100644 index 0000000..5f55c84 --- /dev/null +++ b/pkg/health/testdata/kustomization-reconciliation-failed.yaml @@ -0,0 +1,37 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + uid: 73ffa0f4-2eb1-4d1b-8367-1c47128e3339 + name: cronjobs + labels: + kustomize.toolkit.fluxcd.io/name: flux-objects + kustomize.toolkit.fluxcd.io/namespace: flux-system + namespace: flux-system + finalizers: + - finalizers.fluxcd.io + creationTimestamp: 2024-08-01T06:52:47Z +spec: + path: ./production/ifs-mgmt-mon-eks/cronjobs + force: false + prune: false + interval: 10m0s + sourceRef: + kind: GitRepository + name: infrastructure + decryption: + provider: sops +status: + conditions: + - type: Reconciling + reason: ProgressingWithRetry + status: 'True' + message: Detecting drift for revision + v1.34.0@sha1:bdbb399739638a189b76197d5112968827b6ecd7 with a timeout of + 9m30s + - type: Ready + reason: ReconciliationFailed + status: 'False' + message: > + CronJob/scale-dev-up namespace not specified: the server could not find + the requested resource + lastAttemptedRevision: v1.34.0@sha1:bdbb399739638a189b76197d5112968827b6ecd7