From d1cdcf47f42952b4ce3f2ff62a201b265c78d8e6 Mon Sep 17 00:00:00 2001 From: Drew Sessler Date: Wed, 23 Apr 2025 17:00:11 -0700 Subject: [PATCH 1/2] Fix for PGO-2380: Only add logrotate volume mounts to instance pod when backups are enabled. Add kuttl tests to ensure that collector will run on postgres instance when backups are disabled. --- .../controller/postgrescluster/instance.go | 7 +- .../12--cluster-no-backups.yaml | 6 ++ .../13-assert-instance.yaml | 55 ++++++++++++++ .../14--cluster-add-backups.yaml | 6 ++ .../15--remove-backups.yaml | 6 ++ .../16--annotate-cluster.yaml | 7 ++ .../e2e/otel-logging-and-metrics/README.md | 6 ++ .../files/01-instrumentation-added.yaml | 1 + .../files/08-custom-queries-added.yaml | 1 + .../files/10-logs-exporter-added.yaml | 1 + .../files/12--create-cluster.yaml | 16 +++++ .../files/12-cluster-created.yaml | 36 ++++++++++ .../files/14--add-backups.yaml | 31 ++++++++ .../files/14-backups-added.yaml | 71 +++++++++++++++++++ .../files/16-backups-removed.yaml | 36 ++++++++++ 15 files changed, 283 insertions(+), 3 deletions(-) create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/12--cluster-no-backups.yaml create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/13-assert-instance.yaml create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/14--cluster-add-backups.yaml create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/15--remove-backups.yaml create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/16--annotate-cluster.yaml create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/files/12--create-cluster.yaml create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/files/12-cluster-created.yaml create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/files/14--add-backups.yaml create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/files/14-backups-added.yaml create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/files/16-backups-removed.yaml diff --git a/internal/controller/postgrescluster/instance.go b/internal/controller/postgrescluster/instance.go index 85f23d960b..e24c0aca7b 100644 --- a/internal/controller/postgrescluster/instance.go +++ b/internal/controller/postgrescluster/instance.go @@ -1218,11 +1218,12 @@ func (r *Reconciler) reconcileInstance( } } - // For now, we are not using logrotate to rotate postgres or patroni logs - // but we are using it for pgbackrest logs in the postgres pod + // For now, we are not using logrotate to rotate postgres or patroni logs, + // but we are using it for pgbackrest logs in the postgres pod, so we will + // set includeLogrotate to true, but only if backups are enabled. collector.AddToPod(ctx, cluster.Spec.Instrumentation, cluster.Spec.ImagePullPolicy, instanceConfigMap, &instance.Spec.Template, []corev1.VolumeMount{postgres.DataVolumeMount()}, pgPassword, - []string{naming.PGBackRestPGDataLogPath}, true, true) + []string{naming.PGBackRestPGDataLogPath}, backupsSpecFound, true) } // Add postgres-exporter to the instance Pod spec diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/12--cluster-no-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/12--cluster-no-backups.yaml new file mode 100644 index 0000000000..9798566140 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/12--cluster-no-backups.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/12--create-cluster.yaml +assert: +- files/12-cluster-created.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/13-assert-instance.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/13-assert-instance.yaml new file mode 100644 index 0000000000..411c910486 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/13-assert-instance.yaml @@ -0,0 +1,55 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: +# First, check that all containers in the instance pod are ready. +# Then, grab the collector metrics output and check that a postgres +# metric is present, as well as a patroni metric. +# Then, check the collector logs for patroni, and postgres logs. +# Finally, ensure the monitoring user exists and is configured. +- script: | + retry() { bash -ceu 'printf "$1\nSleeping...\n" && sleep 5' - "$@"; } + check_containers_ready() { bash -ceu 'echo "$1" | jq -e ".[] | select(.type==\"ContainersReady\") | .status==\"True\""' - "$@"; } + contains() { bash -ceu '[[ "$1" == *"$2"* ]]' - "$@"; } + + pod=$(kubectl get pods -o name -n "${NAMESPACE}" \ + -l postgres-operator.crunchydata.com/cluster=otel-cluster-no-backups,postgres-operator.crunchydata.com/data=postgres) + [ "$pod" = "" ] && retry "Pod not found" && exit 1 + + condition_json=$(kubectl get "${pod}" -n "${NAMESPACE}" -o jsonpath="{.status.conditions}") + [ "$condition_json" = "" ] && retry "conditions not found" && exit 1 + { check_containers_ready "$condition_json"; } || { + retry "containers not ready" + exit 1 + } + + scrape_metrics=$(kubectl exec "${pod}" -c collector -n "${NAMESPACE}" -- \ + curl --insecure --silent http://localhost:9187/metrics) + { contains "${scrape_metrics}" 'ccp_connection_stats_active'; } || { + retry "5 second metric not found" + exit 1 + } + { contains "${scrape_metrics}" 'patroni_postgres_running'; } || { + retry "patroni metric not found" + exit 1 + } + + logs=$(kubectl logs "${pod}" --namespace "${NAMESPACE}" -c collector | grep InstrumentationScope) + { contains "${logs}" 'InstrumentationScope patroni'; } || { + retry "patroni logs not found" + exit 1 + } + { contains "${logs}" 'InstrumentationScope postgres'; } || { + retry "postgres logs not found" + exit 1 + } + + kubectl exec --stdin "${pod}" --namespace "${NAMESPACE}" -c database \ + -- psql -qb --set ON_ERROR_STOP=1 --file=- <<'SQL' + DO $$ + DECLARE + result record; + BEGIN + SELECT * INTO result FROM pg_catalog.pg_roles WHERE rolname = 'ccp_monitoring'; + ASSERT FOUND, 'user not found'; + END $$ + SQL diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/14--cluster-add-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/14--cluster-add-backups.yaml new file mode 100644 index 0000000000..f063eeda7b --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/14--cluster-add-backups.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/14--add-backups.yaml +assert: +- files/14-backups-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/15--remove-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/15--remove-backups.yaml new file mode 100644 index 0000000000..abd64d40a9 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/15--remove-backups.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- command: |- + kubectl patch postgrescluster otel-cluster-no-backups --type 'merge' -p '{"spec":{"backups": null}}' + namespaced: true diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/16--annotate-cluster.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/16--annotate-cluster.yaml new file mode 100644 index 0000000000..f37696ecf2 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/16--annotate-cluster.yaml @@ -0,0 +1,7 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- command: kubectl annotate postgrescluster otel-cluster-no-backups postgres-operator.crunchydata.com/authorizeBackupRemoval="true" + namespaced: true +assert: +- files/16-backups-removed.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/README.md b/testing/kuttl/e2e/otel-logging-and-metrics/README.md index 069a17f089..e14bdd899c 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/README.md +++ b/testing/kuttl/e2e/otel-logging-and-metrics/README.md @@ -23,6 +23,12 @@ This test assumes that the operator has both OpenTelemetryLogs and OpenTelemetry 4. Add an `otlp` exporter to both PostgresCluster and PGAdmin `instrumentation` specs and create a standalone OTel collector to receive data from our sidecar collectors. 1. Ensure that the ConfigMap, Service, and Deployment for the standalone OTel collector come up and that the collector container is running and ready. 2. Assert that the standalone collector is receiving logs from all of our components (i.e. the standalone collector is getting logs for postgres, patroni, pgbackrest, pgbouncer, pgadmin, and gunicorn). +5. Create a new cluster with `instrumentation` spec in place, but no `backups` spec to test the OTel features with optional backups. + 1. Ensure that the cluster comes up and the database and collector containers are running and ready. + 2. Add a backups spec to the new cluster and ensure that pgbackrest is added to the instance pod, a repo-host pod is created, and the collector runs on both pods. + 3. Remove the backups spec from the new cluster. + 4. Annotate the cluster to allow backups to be removed. + 5. Ensure that the repo-host pod is destroyed, pgbackrest is removed from the instance pod, and the collector continues to run on the instance pod. ### NOTES diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/01-instrumentation-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/01-instrumentation-added.yaml index b9bbe130bd..858b78ff83 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/files/01-instrumentation-added.yaml +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/01-instrumentation-added.yaml @@ -46,6 +46,7 @@ metadata: labels: postgres-operator.crunchydata.com/data: pgbackrest postgres-operator.crunchydata.com/cluster: otel-cluster + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" status: containerStatuses: - name: collector diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/08-custom-queries-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/08-custom-queries-added.yaml index 344d52158e..1a756b7a73 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/files/08-custom-queries-added.yaml +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/08-custom-queries-added.yaml @@ -46,6 +46,7 @@ metadata: labels: postgres-operator.crunchydata.com/data: pgbackrest postgres-operator.crunchydata.com/cluster: otel-cluster + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" status: containerStatuses: - name: collector diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/10-logs-exporter-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/10-logs-exporter-added.yaml index 47a28ee418..f730898692 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/files/10-logs-exporter-added.yaml +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/10-logs-exporter-added.yaml @@ -46,6 +46,7 @@ metadata: labels: postgres-operator.crunchydata.com/data: pgbackrest postgres-operator.crunchydata.com/cluster: otel-cluster + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" status: containerStatuses: - name: collector diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/12--create-cluster.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/12--create-cluster.yaml new file mode 100644 index 0000000000..3983405b34 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/12--create-cluster.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster-no-backups +spec: + postgresVersion: ${KUTTL_PG_VERSION} + instances: + - name: instance1 + dataVolumeClaimSpec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: 1Gi + instrumentation: {} diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/12-cluster-created.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/12-cluster-created.yaml new file mode 100644 index 0000000000..c9aad7ec25 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/12-cluster-created.yaml @@ -0,0 +1,36 @@ +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster-no-backups +status: + instances: + - name: instance1 + readyReplicas: 1 + replicas: 1 + updatedReplicas: 1 +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/data: postgres + postgres-operator.crunchydata.com/role: master + postgres-operator.crunchydata.com/cluster: otel-cluster-no-backups + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: database + ready: true + started: true + - name: replication-cert-copy + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Service +metadata: + name: otel-cluster-no-backups-primary diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/14--add-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/14--add-backups.yaml new file mode 100644 index 0000000000..bb7c70ea37 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/14--add-backups.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster-no-backups +spec: + postgresVersion: ${KUTTL_PG_VERSION} + instances: + - name: instance1 + dataVolumeClaimSpec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: 1Gi + backups: + pgbackrest: + manual: + repoName: repo1 + options: + - --type=diff + repos: + - name: repo1 + volume: + volumeClaimSpec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: 1Gi + instrumentation: {} diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/14-backups-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/14-backups-added.yaml new file mode 100644 index 0000000000..52221d2349 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/14-backups-added.yaml @@ -0,0 +1,71 @@ +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster-no-backups +status: + instances: + - name: instance1 + readyReplicas: 1 + replicas: 1 + updatedReplicas: 1 +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/data: postgres + postgres-operator.crunchydata.com/role: master + postgres-operator.crunchydata.com/cluster: otel-cluster-no-backups + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: database + ready: true + started: true + - name: pgbackrest + ready: true + started: true + - name: pgbackrest-config + ready: true + started: true + - name: replication-cert-copy + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/data: pgbackrest + postgres-operator.crunchydata.com/cluster: otel-cluster-no-backups + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: pgbackrest + ready: true + started: true + - name: pgbackrest-config + ready: true + started: true + phase: Running +--- +apiVersion: batch/v1 +kind: Job +metadata: + labels: + postgres-operator.crunchydata.com/cluster: otel-cluster-no-backups + postgres-operator.crunchydata.com/pgbackrest-backup: replica-create +status: + succeeded: 1 +--- +apiVersion: v1 +kind: Service +metadata: + name: otel-cluster-no-backups-primary diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/16-backups-removed.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/16-backups-removed.yaml new file mode 100644 index 0000000000..c9aad7ec25 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/16-backups-removed.yaml @@ -0,0 +1,36 @@ +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster-no-backups +status: + instances: + - name: instance1 + readyReplicas: 1 + replicas: 1 + updatedReplicas: 1 +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/data: postgres + postgres-operator.crunchydata.com/role: master + postgres-operator.crunchydata.com/cluster: otel-cluster-no-backups + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: database + ready: true + started: true + - name: replication-cert-copy + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Service +metadata: + name: otel-cluster-no-backups-primary From 75d836cf72ced8f2238331ad63d1b4a19bde2ec4 Mon Sep 17 00:00:00 2001 From: Drew Sessler Date: Fri, 25 Apr 2025 11:42:26 -0700 Subject: [PATCH 2/2] Reorder otel kuttl test so that we check pgadmin logs right after we add the instrumentation spec to PGAdmin. --- ...d-instrumentation-to-postgrescluster.yaml} | 0 ...=> 04-assert-repo-host-does-not-logs.yaml} | 0 .../otel-logging-and-metrics/05--backup.yaml | 6 + .../otel-logging-and-metrics/06--backup.yaml | 6 - ...=> 06-assert-repo-host-contains-logs.yaml} | 0 .../07--add-instrumentation-to-pgadmin.yaml | 6 + .../08--add-custom-queries.yaml | 6 - ...rt-pgadmin.yaml => 08-assert-pgadmin.yaml} | 0 .../09--add-custom-queries.yaml | 6 + .../10--add-logs-exporter.yaml | 6 - ...ies.yaml => 10-assert-custom-queries.yaml} | 0 .../11--add-logs-exporter.yaml | 6 + .../12--cluster-no-backups.yaml | 6 - ...rted.yaml => 12-assert-logs-exported.yaml} | 0 .../13--cluster-no-backups.yaml | 6 + ...-instance.yaml => 14-assert-instance.yaml} | 0 ...kups.yaml => 15--cluster-add-backups.yaml} | 4 +- ...e-backups.yaml => 16--remove-backups.yaml} | 0 ...cluster.yaml => 17--annotate-cluster.yaml} | 2 +- .../files/01--add-instrumentation.yaml | 26 ---- .../files/01-instrumentation-added.yaml | 4 - ...cluster.yaml => 05--annotate-cluster.yaml} | 0 ...ompleted.yaml => 05-backup-completed.yaml} | 0 .../files/07--add-instrumentation.yaml | 26 ++++ .../files/07-instrumentation-added.yaml | 120 ++++++++++++++++++ ...eries.yaml => 09--add-custom-queries.yaml} | 0 ...dded.yaml => 09-custom-queries-added.yaml} | 0 ...porter.yaml => 11--add-logs-exporter.yaml} | 0 ...added.yaml => 11-logs-exporter-added.yaml} | 0 ...e-cluster.yaml => 13--create-cluster.yaml} | 0 ...r-created.yaml => 13-cluster-created.yaml} | 0 ...-add-backups.yaml => 15--add-backups.yaml} | 0 ...ckups-added.yaml => 15-backups-added.yaml} | 0 ...s-removed.yaml => 17-backups-removed.yaml} | 0 34 files changed, 179 insertions(+), 57 deletions(-) rename testing/kuttl/e2e/otel-logging-and-metrics/{01--add-instrumentation.yaml => 01--add-instrumentation-to-postgrescluster.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/{05-assert-repo-host-does-not-logs.yaml => 04-assert-repo-host-does-not-logs.yaml} (100%) create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/05--backup.yaml delete mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/06--backup.yaml rename testing/kuttl/e2e/otel-logging-and-metrics/{07-assert-repo-host-contains-logs.yaml => 06-assert-repo-host-contains-logs.yaml} (100%) create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/07--add-instrumentation-to-pgadmin.yaml delete mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/08--add-custom-queries.yaml rename testing/kuttl/e2e/otel-logging-and-metrics/{04-assert-pgadmin.yaml => 08-assert-pgadmin.yaml} (100%) create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/09--add-custom-queries.yaml delete mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/10--add-logs-exporter.yaml rename testing/kuttl/e2e/otel-logging-and-metrics/{09-assert-custom-queries.yaml => 10-assert-custom-queries.yaml} (100%) create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/11--add-logs-exporter.yaml delete mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/12--cluster-no-backups.yaml rename testing/kuttl/e2e/otel-logging-and-metrics/{11-assert-logs-exported.yaml => 12-assert-logs-exported.yaml} (100%) create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/13--cluster-no-backups.yaml rename testing/kuttl/e2e/otel-logging-and-metrics/{13-assert-instance.yaml => 14-assert-instance.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/{14--cluster-add-backups.yaml => 15--cluster-add-backups.yaml} (50%) rename testing/kuttl/e2e/otel-logging-and-metrics/{15--remove-backups.yaml => 16--remove-backups.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/{16--annotate-cluster.yaml => 17--annotate-cluster.yaml} (86%) rename testing/kuttl/e2e/otel-logging-and-metrics/files/{06--annotate-cluster.yaml => 05--annotate-cluster.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/files/{06-backup-completed.yaml => 05-backup-completed.yaml} (100%) create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/files/07--add-instrumentation.yaml create mode 100644 testing/kuttl/e2e/otel-logging-and-metrics/files/07-instrumentation-added.yaml rename testing/kuttl/e2e/otel-logging-and-metrics/files/{08--add-custom-queries.yaml => 09--add-custom-queries.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/files/{08-custom-queries-added.yaml => 09-custom-queries-added.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/files/{10--add-logs-exporter.yaml => 11--add-logs-exporter.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/files/{10-logs-exporter-added.yaml => 11-logs-exporter-added.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/files/{12--create-cluster.yaml => 13--create-cluster.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/files/{12-cluster-created.yaml => 13-cluster-created.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/files/{14--add-backups.yaml => 15--add-backups.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/files/{14-backups-added.yaml => 15-backups-added.yaml} (100%) rename testing/kuttl/e2e/otel-logging-and-metrics/files/{16-backups-removed.yaml => 17-backups-removed.yaml} (100%) diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/01--add-instrumentation.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/01--add-instrumentation-to-postgrescluster.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/01--add-instrumentation.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/01--add-instrumentation-to-postgrescluster.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/05-assert-repo-host-does-not-logs.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/04-assert-repo-host-does-not-logs.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/05-assert-repo-host-does-not-logs.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/04-assert-repo-host-does-not-logs.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/05--backup.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/05--backup.yaml new file mode 100644 index 0000000000..166ef662a5 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/05--backup.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/05--annotate-cluster.yaml +assert: +- files/05-backup-completed.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/06--backup.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/06--backup.yaml deleted file mode 100644 index cd4e92f32c..0000000000 --- a/testing/kuttl/e2e/otel-logging-and-metrics/06--backup.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -apply: -- files/06--annotate-cluster.yaml -assert: -- files/06-backup-completed.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/07-assert-repo-host-contains-logs.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/06-assert-repo-host-contains-logs.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/07-assert-repo-host-contains-logs.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/06-assert-repo-host-contains-logs.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/07--add-instrumentation-to-pgadmin.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/07--add-instrumentation-to-pgadmin.yaml new file mode 100644 index 0000000000..55f2179939 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/07--add-instrumentation-to-pgadmin.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/07--add-instrumentation.yaml +assert: +- files/07-instrumentation-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/08--add-custom-queries.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/08--add-custom-queries.yaml deleted file mode 100644 index 290090e129..0000000000 --- a/testing/kuttl/e2e/otel-logging-and-metrics/08--add-custom-queries.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -apply: -- files/08--add-custom-queries.yaml -assert: -- files/08-custom-queries-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/04-assert-pgadmin.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/08-assert-pgadmin.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/04-assert-pgadmin.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/08-assert-pgadmin.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/09--add-custom-queries.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/09--add-custom-queries.yaml new file mode 100644 index 0000000000..223b1d71a8 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/09--add-custom-queries.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/09--add-custom-queries.yaml +assert: +- files/09-custom-queries-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/10--add-logs-exporter.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/10--add-logs-exporter.yaml deleted file mode 100644 index 55f43815dd..0000000000 --- a/testing/kuttl/e2e/otel-logging-and-metrics/10--add-logs-exporter.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -apply: -- files/10--add-logs-exporter.yaml -assert: -- files/10-logs-exporter-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/09-assert-custom-queries.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/10-assert-custom-queries.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/09-assert-custom-queries.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/10-assert-custom-queries.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/11--add-logs-exporter.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/11--add-logs-exporter.yaml new file mode 100644 index 0000000000..298adb06b4 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/11--add-logs-exporter.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/11--add-logs-exporter.yaml +assert: +- files/11-logs-exporter-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/12--cluster-no-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/12--cluster-no-backups.yaml deleted file mode 100644 index 9798566140..0000000000 --- a/testing/kuttl/e2e/otel-logging-and-metrics/12--cluster-no-backups.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -apply: -- files/12--create-cluster.yaml -assert: -- files/12-cluster-created.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/11-assert-logs-exported.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/12-assert-logs-exported.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/11-assert-logs-exported.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/12-assert-logs-exported.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/13--cluster-no-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/13--cluster-no-backups.yaml new file mode 100644 index 0000000000..b4c6f272f6 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/13--cluster-no-backups.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/13--create-cluster.yaml +assert: +- files/13-cluster-created.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/13-assert-instance.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/14-assert-instance.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/13-assert-instance.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/14-assert-instance.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/14--cluster-add-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/15--cluster-add-backups.yaml similarity index 50% rename from testing/kuttl/e2e/otel-logging-and-metrics/14--cluster-add-backups.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/15--cluster-add-backups.yaml index f063eeda7b..3bdd0b37e8 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/14--cluster-add-backups.yaml +++ b/testing/kuttl/e2e/otel-logging-and-metrics/15--cluster-add-backups.yaml @@ -1,6 +1,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep apply: -- files/14--add-backups.yaml +- files/15--add-backups.yaml assert: -- files/14-backups-added.yaml +- files/15-backups-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/15--remove-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/16--remove-backups.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/15--remove-backups.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/16--remove-backups.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/16--annotate-cluster.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/17--annotate-cluster.yaml similarity index 86% rename from testing/kuttl/e2e/otel-logging-and-metrics/16--annotate-cluster.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/17--annotate-cluster.yaml index f37696ecf2..2da3da58a3 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/16--annotate-cluster.yaml +++ b/testing/kuttl/e2e/otel-logging-and-metrics/17--annotate-cluster.yaml @@ -4,4 +4,4 @@ commands: - command: kubectl annotate postgrescluster otel-cluster-no-backups postgres-operator.crunchydata.com/authorizeBackupRemoval="true" namespaced: true assert: -- files/16-backups-removed.yaml +- files/17-backups-removed.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/01--add-instrumentation.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/01--add-instrumentation.yaml index f02c09d380..ebde9f7caa 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/files/01--add-instrumentation.yaml +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/01--add-instrumentation.yaml @@ -34,29 +34,3 @@ spec: proxy: pgBouncer: {} instrumentation: {} ---- -apiVersion: postgres-operator.crunchydata.com/v1beta1 -kind: PGAdmin -metadata: - name: otel-pgadmin -spec: - users: - - username: otel@example.com - role: Administrator - passwordRef: - name: pgadmin-password-secret - key: otel-password - dataVolumeClaimSpec: - accessModes: - - "ReadWriteOnce" - resources: - requests: - storage: 1Gi - serverGroups: - - name: supply - # An empty selector selects all postgresclusters in the Namespace - postgresClusterSelector: {} - config: - settings: - AUTHENTICATION_SOURCES: ['internal'] - instrumentation: {} diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/01-instrumentation-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/01-instrumentation-added.yaml index 858b78ff83..672bdd2d1d 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/files/01-instrumentation-added.yaml +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/01-instrumentation-added.yaml @@ -99,12 +99,8 @@ metadata: postgres-operator.crunchydata.com/data: pgadmin postgres-operator.crunchydata.com/role: pgadmin postgres-operator.crunchydata.com/pgadmin: otel-pgadmin - postgres-operator.crunchydata.com/crunchy-otel-collector: "true" status: containerStatuses: - - name: collector - ready: true - started: true - name: pgadmin ready: true started: true diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/06--annotate-cluster.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/05--annotate-cluster.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/06--annotate-cluster.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/05--annotate-cluster.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/06-backup-completed.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/05-backup-completed.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/06-backup-completed.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/05-backup-completed.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/07--add-instrumentation.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/07--add-instrumentation.yaml new file mode 100644 index 0000000000..166f0d3347 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/07--add-instrumentation.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PGAdmin +metadata: + name: otel-pgadmin +spec: + users: + - username: otel@example.com + role: Administrator + passwordRef: + name: pgadmin-password-secret + key: otel-password + dataVolumeClaimSpec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: 1Gi + serverGroups: + - name: supply + # An empty selector selects all postgresclusters in the Namespace + postgresClusterSelector: {} + config: + settings: + AUTHENTICATION_SOURCES: ['internal'] + instrumentation: {} diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/07-instrumentation-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/07-instrumentation-added.yaml new file mode 100644 index 0000000000..858b78ff83 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/07-instrumentation-added.yaml @@ -0,0 +1,120 @@ +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster +status: + instances: + - name: instance1 + readyReplicas: 1 + replicas: 1 + updatedReplicas: 1 + proxy: + pgBouncer: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/data: postgres + postgres-operator.crunchydata.com/role: master + postgres-operator.crunchydata.com/cluster: otel-cluster + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: database + ready: true + started: true + - name: pgbackrest + ready: true + started: true + - name: pgbackrest-config + ready: true + started: true + - name: replication-cert-copy + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/data: pgbackrest + postgres-operator.crunchydata.com/cluster: otel-cluster + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: pgbackrest + ready: true + started: true + - name: pgbackrest-config + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/role: pgbouncer + postgres-operator.crunchydata.com/cluster: otel-cluster + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: pgbouncer + ready: true + started: true + - name: pgbouncer-config + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Service +metadata: + name: otel-cluster-primary +--- +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + postgres-operator.crunchydata.com/role: pgadmin + postgres-operator.crunchydata.com/pgadmin: otel-pgadmin +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/data: pgadmin + postgres-operator.crunchydata.com/role: pgadmin + postgres-operator.crunchydata.com/pgadmin: otel-pgadmin + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: pgadmin + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Secret +metadata: + labels: + postgres-operator.crunchydata.com/role: pgadmin + postgres-operator.crunchydata.com/pgadmin: otel-pgadmin +type: Opaque +--- diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/08--add-custom-queries.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/09--add-custom-queries.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/08--add-custom-queries.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/09--add-custom-queries.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/08-custom-queries-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/09-custom-queries-added.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/08-custom-queries-added.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/09-custom-queries-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/10--add-logs-exporter.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/11--add-logs-exporter.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/10--add-logs-exporter.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/11--add-logs-exporter.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/10-logs-exporter-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/11-logs-exporter-added.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/10-logs-exporter-added.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/11-logs-exporter-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/12--create-cluster.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/13--create-cluster.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/12--create-cluster.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/13--create-cluster.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/12-cluster-created.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/13-cluster-created.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/12-cluster-created.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/13-cluster-created.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/14--add-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/15--add-backups.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/14--add-backups.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/15--add-backups.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/14-backups-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/15-backups-added.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/14-backups-added.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/15-backups-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/16-backups-removed.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/17-backups-removed.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/16-backups-removed.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/17-backups-removed.yaml