From 61e0d34e8bedb447bd3e59e6aee580e9a14c190d Mon Sep 17 00:00:00 2001 From: Vitor Rodrigo Vezani Date: Thu, 27 Jun 2024 17:10:21 -0300 Subject: [PATCH] INSIGHTS-156 - Fix typo and improve failure message (#1055) * fix typo * fix failure message * fix changelog * fix missingPodDisruptionBudget validation * Update failure.empty-labels.yaml * Update failure.no-metadata.yaml * INSIGHTS-159 - use go templating instead of custom function validation (#1056) * use go templating instead of custom function validation * fix changelog --- docs/changelog.md | 4 +++- pkg/config/checks/hpaMinAvailability.yaml | 2 +- .../checks/missingPodDisruptionBudget.yaml | 14 +++++++++--- .../failure.empty-labels.yaml | 22 +++++++++++++++++++ .../failure.no-labels.yaml | 21 ++++++++++++++++++ .../failure.no-metadata.yaml | 20 +++++++++++++++++ 6 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 test/checks/missingPodDisruptionBudget/failure.empty-labels.yaml create mode 100644 test/checks/missingPodDisruptionBudget/failure.no-labels.yaml create mode 100644 test/checks/missingPodDisruptionBudget/failure.no-metadata.yaml diff --git a/docs/changelog.md b/docs/changelog.md index 12c75575d..69c9ce000 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -6,7 +6,9 @@ meta: --- -## unreleased +## 9.1.1 +* Fix `hpaMinAvailability` failure message +* Fix `missingPodDisruptionBudget` typo * Rewrite `hpaMaxAvailability` check to use go-template ## 9.1.0 diff --git a/pkg/config/checks/hpaMinAvailability.yaml b/pkg/config/checks/hpaMinAvailability.yaml index 5bc00104e..b57eecc9a 100644 --- a/pkg/config/checks/hpaMinAvailability.yaml +++ b/pkg/config/checks/hpaMinAvailability.yaml @@ -1,5 +1,5 @@ successMessage: HPA has a valid min replica configuration -failureMessage: HPA maxReplicas should be greater than minReplicas +failureMessage: HPA minReplicas should be 2 or more category: Reliability target: autoscaling/HorizontalPodAutoscaler schema: diff --git a/pkg/config/checks/missingPodDisruptionBudget.yaml b/pkg/config/checks/missingPodDisruptionBudget.yaml index 9741544c8..1ff42ad85 100644 --- a/pkg/config/checks/missingPodDisruptionBudget.yaml +++ b/pkg/config/checks/missingPodDisruptionBudget.yaml @@ -4,9 +4,9 @@ category: Reliability target: Controller controllers: include: - - Deployment + - Deployment schema: - '$schema': http://json-schema.org/draft-07/schema + "$schema": http://json-schema.org/draft-07/schema# type: object properties: spec: @@ -14,13 +14,21 @@ schema: properties: template: type: object - properites: + properties: metadata: type: object properties: labels: type: object minProperties: 1 + required: + - labels + required: + - metadata + required: + - template + required: + - spec additionalSchemaStrings: policy/PodDisruptionBudget: | type: object diff --git a/test/checks/missingPodDisruptionBudget/failure.empty-labels.yaml b/test/checks/missingPodDisruptionBudget/failure.empty-labels.yaml new file mode 100644 index 000000000..338e962f0 --- /dev/null +++ b/test/checks/missingPodDisruptionBudget/failure.empty-labels.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: zookeeper +spec: + template: + metadata: + labels: {} # empty labels + spec: + containers: + - name: zookeeper + image: zookeeper +--- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: zookeeper-pdb +spec: + minAvailable: 2 + selector: + matchLabels: + app.kubernetes.io/name: zookeeper diff --git a/test/checks/missingPodDisruptionBudget/failure.no-labels.yaml b/test/checks/missingPodDisruptionBudget/failure.no-labels.yaml new file mode 100644 index 000000000..c65d6924f --- /dev/null +++ b/test/checks/missingPodDisruptionBudget/failure.no-labels.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: zookeeper +spec: + template: + metadata: {} # missing labels + spec: + containers: + - name: zookeeper + image: zookeeper +--- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: zookeeper-pdb +spec: + minAvailable: 2 + selector: + matchLabels: + app.kubernetes.io/name: zookeeper diff --git a/test/checks/missingPodDisruptionBudget/failure.no-metadata.yaml b/test/checks/missingPodDisruptionBudget/failure.no-metadata.yaml new file mode 100644 index 000000000..e4803b03b --- /dev/null +++ b/test/checks/missingPodDisruptionBudget/failure.no-metadata.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: zookeeper +spec: + template: # missing metadata + spec: + containers: + - name: zookeeper + image: zookeeper +--- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: zookeeper-pdb +spec: + minAvailable: 2 + selector: + matchLabels: + app.kubernetes.io/name: zookeeper