From 7663eadd9aae7ea45a7e9a60eb4775195fbe0e26 Mon Sep 17 00:00:00 2001 From: Dimitri GRISARD Date: Sat, 18 Mar 2023 07:41:42 +0100 Subject: [PATCH 1/9] feat: add extra annotations pgbouncer --- chart/templates/pgbouncer/pgbouncer-deployment.yaml | 3 +++ chart/values.schema.json | 8 ++++++++ chart/values.yaml | 2 ++ tests/charts/test_pgbouncer.py | 11 +++++++++++ 4 files changed, 24 insertions(+) diff --git a/chart/templates/pgbouncer/pgbouncer-deployment.yaml b/chart/templates/pgbouncer/pgbouncer-deployment.yaml index 1d2601a945f19..09b13435b5cb1 100644 --- a/chart/templates/pgbouncer/pgbouncer-deployment.yaml +++ b/chart/templates/pgbouncer/pgbouncer-deployment.yaml @@ -66,6 +66,9 @@ spec: annotations: checksum/pgbouncer-config-secret: {{ include (print $.Template.BasePath "/secrets/pgbouncer-config-secret.yaml") . | sha256sum }} checksum/pgbouncer-certificates-secret: {{ include (print $.Template.BasePath "/secrets/pgbouncer-certificates-secret.yaml") . | sha256sum }} +{{- if .Values.pgbouncer.extraAnnotations }} +{{- toYaml .Values.pgbouncer.extraAnnotations | nindent 8 }} +{{- end }} spec: {{- if .Values.pgbouncer.priorityClassName }} priorityClassName: {{ .Values.pgbouncer.priorityClassName }} diff --git a/chart/values.schema.json b/chart/values.schema.json index e0d5b1cab8344..766d9b67b05bf 100644 --- a/chart/values.schema.json +++ b/chart/values.schema.json @@ -4385,6 +4385,14 @@ ], "default": null }, + "extraAnnotations": { + "description": "Extra annotations for the PgBouncer Pod.", + "type": "object", + "default": {}, + "additionalProperties": { + "type": "string" + } + }, "podDisruptionBudget": { "description": "PgBouncer PodDisruptionBudget.", "type": "object", diff --git a/chart/values.yaml b/chart/values.yaml index afad5f94b6f76..d61a2cfa853f4 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -1542,6 +1542,8 @@ pgbouncer: # annotations to be added to the PgBouncer deployment annotations: {} + extraAnnotations: {} + # Create ServiceAccount serviceAccount: # Specifies whether a ServiceAccount should be created diff --git a/tests/charts/test_pgbouncer.py b/tests/charts/test_pgbouncer.py index 901ea71d48710..8e214aa918cec 100644 --- a/tests/charts/test_pgbouncer.py +++ b/tests/charts/test_pgbouncer.py @@ -518,6 +518,17 @@ def test_extra_ini_configs(self): assert "server_round_robin = 1" in ini assert "stats_period = 30" in ini + def test_pgbouncer_deployment_extra_annotations(self): + docs = render_chart( + values={"pgbouncer": {"enabled": True, "extraAnnotations":{"foo": "bar"}}}, + show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"], + ) + + assert { + "checksum/pgbouncer-certificates-secret": "ce3e24dbf7b695a6cc5be7270ab37c50011f8d35898e1d023165106f6248ce0b", + "checksum/pgbouncer-config-secret": "f2aee4e66cd282693ffe89963baf0604ee80bef16da1a570e4cf2749f6cc0438", + "foo": "bar", + } == jmespath.search("spec.template.metadata.annotations", docs[0]) class TestPgbouncerExporter: def test_secret_not_created_by_default(self): From 10f6f1dbf1f8b0b116b2f4430b81fcfcf35039be Mon Sep 17 00:00:00 2001 From: Dimitri GRISARD Date: Mon, 20 Mar 2023 21:34:34 +0100 Subject: [PATCH 2/9] fix(ci): Static checks E501 Line too long --- tests/charts/test_pgbouncer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/charts/test_pgbouncer.py b/tests/charts/test_pgbouncer.py index 8e214aa918cec..01e049bcdd3bc 100644 --- a/tests/charts/test_pgbouncer.py +++ b/tests/charts/test_pgbouncer.py @@ -525,8 +525,10 @@ def test_pgbouncer_deployment_extra_annotations(self): ) assert { - "checksum/pgbouncer-certificates-secret": "ce3e24dbf7b695a6cc5be7270ab37c50011f8d35898e1d023165106f6248ce0b", - "checksum/pgbouncer-config-secret": "f2aee4e66cd282693ffe89963baf0604ee80bef16da1a570e4cf2749f6cc0438", + "checksum/pgbouncer-certificates-secret": + "ce3e24dbf7b695a6cc5be7270ab37c50011f8d35898e1d023165106f6248ce0b", + "checksum/pgbouncer-config-secret": + "f2aee4e66cd282693ffe89963baf0604ee80bef16da1a570e4cf2749f6cc0438", "foo": "bar", } == jmespath.search("spec.template.metadata.annotations", docs[0]) From dbfbe94834adb76b93b306b03726f76b34645d63 Mon Sep 17 00:00:00 2001 From: Dimitri GRISARD Date: Tue, 21 Mar 2023 21:44:16 +0100 Subject: [PATCH 3/9] fix(ci): Static checks E501 Line too long --- tests/charts/test_pgbouncer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/charts/test_pgbouncer.py b/tests/charts/test_pgbouncer.py index 01e049bcdd3bc..dbe126f002fed 100644 --- a/tests/charts/test_pgbouncer.py +++ b/tests/charts/test_pgbouncer.py @@ -525,9 +525,11 @@ def test_pgbouncer_deployment_extra_annotations(self): ) assert { - "checksum/pgbouncer-certificates-secret": + # Forward slash fix 'E501 Line too long (121 > 110 characters)' in Static checks job + "checksum/pgbouncer-certificates-secret": \ "ce3e24dbf7b695a6cc5be7270ab37c50011f8d35898e1d023165106f6248ce0b", - "checksum/pgbouncer-config-secret": + # Forward slash fix 'E501 Line too long (115 > 110 characters)' in Static checks job + "checksum/pgbouncer-config-secret": \ "f2aee4e66cd282693ffe89963baf0604ee80bef16da1a570e4cf2749f6cc0438", "foo": "bar", } == jmespath.search("spec.template.metadata.annotations", docs[0]) From 99e1cb7a2b9b65e674cab95ca9540f1636ff9a95 Mon Sep 17 00:00:00 2001 From: Dimitri GRISARD Date: Wed, 22 Mar 2023 21:56:50 +0100 Subject: [PATCH 4/9] fix(ci): Static checks E501 Line too long --- tests/charts/test_pgbouncer.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/charts/test_pgbouncer.py b/tests/charts/test_pgbouncer.py index dbe126f002fed..63bf27c49af35 100644 --- a/tests/charts/test_pgbouncer.py +++ b/tests/charts/test_pgbouncer.py @@ -520,20 +520,17 @@ def test_extra_ini_configs(self): def test_pgbouncer_deployment_extra_annotations(self): docs = render_chart( - values={"pgbouncer": {"enabled": True, "extraAnnotations":{"foo": "bar"}}}, + values={"pgbouncer": {"enabled": True, "extraAnnotations": {"foo": "bar"}}}, show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"], ) assert { - # Forward slash fix 'E501 Line too long (121 > 110 characters)' in Static checks job - "checksum/pgbouncer-certificates-secret": \ - "ce3e24dbf7b695a6cc5be7270ab37c50011f8d35898e1d023165106f6248ce0b", - # Forward slash fix 'E501 Line too long (115 > 110 characters)' in Static checks job - "checksum/pgbouncer-config-secret": \ - "f2aee4e66cd282693ffe89963baf0604ee80bef16da1a570e4cf2749f6cc0438", + "checksum/pgbouncer-certificates-secret": "ce3e24dbf7b695a6cc5be7270ab37c50011f8d35898e1d023165106f6248ce0b", # noqa: E501 + "checksum/pgbouncer-config-secret": "f2aee4e66cd282693ffe89963baf0604ee80bef16da1a570e4cf2749f6cc0438", # noqa: E501 "foo": "bar", } == jmespath.search("spec.template.metadata.annotations", docs[0]) + class TestPgbouncerExporter: def test_secret_not_created_by_default(self): docs = render_chart( From 2f690ba1618e066c139ee615e83d18a252eb8719 Mon Sep 17 00:00:00 2001 From: Dimitri GRISARD Date: Sun, 9 Apr 2023 10:46:56 +0200 Subject: [PATCH 5/9] chore(helm): fmt --- chart/templates/pgbouncer/pgbouncer-deployment.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chart/templates/pgbouncer/pgbouncer-deployment.yaml b/chart/templates/pgbouncer/pgbouncer-deployment.yaml index 09b13435b5cb1..63c361dc828b5 100644 --- a/chart/templates/pgbouncer/pgbouncer-deployment.yaml +++ b/chart/templates/pgbouncer/pgbouncer-deployment.yaml @@ -66,9 +66,9 @@ spec: annotations: checksum/pgbouncer-config-secret: {{ include (print $.Template.BasePath "/secrets/pgbouncer-config-secret.yaml") . | sha256sum }} checksum/pgbouncer-certificates-secret: {{ include (print $.Template.BasePath "/secrets/pgbouncer-certificates-secret.yaml") . | sha256sum }} -{{- if .Values.pgbouncer.extraAnnotations }} -{{- toYaml .Values.pgbouncer.extraAnnotations | nindent 8 }} -{{- end }} + {{- if .Values.pgbouncer.podAnnotations }} + {{- toYaml .Values.pgbouncer.podAnnotations | nindent 8 }} + {{- end }} spec: {{- if .Values.pgbouncer.priorityClassName }} priorityClassName: {{ .Values.pgbouncer.priorityClassName }} From be7dbbade2b23b67e74bc3661c6ebfe6c221a061 Mon Sep 17 00:00:00 2001 From: Dimitri GRISARD Date: Sun, 9 Apr 2023 10:52:11 +0200 Subject: [PATCH 6/9] chore(helm): rename pgbouncer annotations --- chart/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chart/values.yaml b/chart/values.yaml index d61a2cfa853f4..5477d2bcd817d 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -1542,7 +1542,7 @@ pgbouncer: # annotations to be added to the PgBouncer deployment annotations: {} - extraAnnotations: {} + podAnnotations: {} # Create ServiceAccount serviceAccount: From 4dea5de1dbe675510faa067576cb56cacecee22a Mon Sep 17 00:00:00 2001 From: Dimitri GRISARD Date: Sun, 9 Apr 2023 10:52:35 +0200 Subject: [PATCH 7/9] chore(test): modify coverage --- tests/charts/test_annotations.py | 13 +++++++++++++ tests/charts/test_pgbouncer.py | 12 ------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/charts/test_annotations.py b/tests/charts/test_annotations.py index 841dd5d3010ba..1da34ad20a168 100644 --- a/tests/charts/test_annotations.py +++ b/tests/charts/test_annotations.py @@ -366,6 +366,19 @@ def test_annotations_are_added(self, values, show_only, expected_annotations): "example": "statsd", }, ), + ( + { + "pgbouncer": { + "podAnnotations": { + "example": "pgbouncer", + }, + }, + }, + "templates/pgbouncer/pgbouncer-deployment.yaml", + { + "example": "pgbouncer", + }, + ), ], ) class TestPerComponentPodAnnotations: diff --git a/tests/charts/test_pgbouncer.py b/tests/charts/test_pgbouncer.py index 63bf27c49af35..901ea71d48710 100644 --- a/tests/charts/test_pgbouncer.py +++ b/tests/charts/test_pgbouncer.py @@ -518,18 +518,6 @@ def test_extra_ini_configs(self): assert "server_round_robin = 1" in ini assert "stats_period = 30" in ini - def test_pgbouncer_deployment_extra_annotations(self): - docs = render_chart( - values={"pgbouncer": {"enabled": True, "extraAnnotations": {"foo": "bar"}}}, - show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"], - ) - - assert { - "checksum/pgbouncer-certificates-secret": "ce3e24dbf7b695a6cc5be7270ab37c50011f8d35898e1d023165106f6248ce0b", # noqa: E501 - "checksum/pgbouncer-config-secret": "f2aee4e66cd282693ffe89963baf0604ee80bef16da1a570e4cf2749f6cc0438", # noqa: E501 - "foo": "bar", - } == jmespath.search("spec.template.metadata.annotations", docs[0]) - class TestPgbouncerExporter: def test_secret_not_created_by_default(self): From b685ac0a2f4c79c288527f132be16f41f40debf5 Mon Sep 17 00:00:00 2001 From: Dimitri GRISARD Date: Sun, 9 Apr 2023 10:55:35 +0200 Subject: [PATCH 8/9] chore(helm): rename pgbouncer annotations --- chart/values.schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chart/values.schema.json b/chart/values.schema.json index 766d9b67b05bf..11a61d3e577e0 100644 --- a/chart/values.schema.json +++ b/chart/values.schema.json @@ -4385,8 +4385,8 @@ ], "default": null }, - "extraAnnotations": { - "description": "Extra annotations for the PgBouncer Pod.", + "podAnnotations": { + "description": "Add annotations for the PgBouncer Pod.", "type": "object", "default": {}, "additionalProperties": { From 113d127e184fb61e7692bdfc4dfadbab7810b720 Mon Sep 17 00:00:00 2001 From: Dimitri GRISARD Date: Sun, 9 Apr 2023 20:49:30 +0200 Subject: [PATCH 9/9] fix: add enable pgbouncer UT --- tests/charts/test_annotations.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/charts/test_annotations.py b/tests/charts/test_annotations.py index 1da34ad20a168..a4392c20f4d06 100644 --- a/tests/charts/test_annotations.py +++ b/tests/charts/test_annotations.py @@ -369,6 +369,7 @@ def test_annotations_are_added(self, values, show_only, expected_annotations): ( { "pgbouncer": { + "enabled": True, "podAnnotations": { "example": "pgbouncer", },