canonical / pgbouncer-k8s-operator

A charmed operator for running PGbouncer on Kubernetes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug prevents access to PostgreSQL database through PgBouncer in charmhub tutorial.

a-velasco opened this issue · comments

Summary

In the PgBouncer K8s tutorial, there is a step where the user is told to access a PostgreSQL database via PgBouncer with a psql command:

psql -h 10.152.183.84 -p 6432 -U relation_id_7 -W -d test123

This command fails when using pgbouncer-k8s from Revision 76 (the current 1/stable), but it works when using Revision 80.

Steps to reproduce

  1. Follow instructions in PgBouncer K8s Tutorial: 2. Environment Setup
  2. Follow instructions in PgBouncer K8s Tutorial: 3. Deploy PgBouncer up until this step.

Expected behavior

The expected behavior is that we then enter the psql interface of database test123, as shown in the next step of the tutorial.

Actual behavior

ubuntu@my-vm:~$ psql -h 10.152.183.84 -p 6432 -U relation_id_7 -W -d test123
Password: 
psql: error: connection to server at "10.152.183.84", port 6432 failed: Connection timed out
	Is the server running on that host and accepting TCP/IP connections?

Versions

Operating system: Ubuntu 22.04.3 LTS

Juju CLI: 3.1.6-genericlinux-amd64

Juju agent: 3.1.6

postgresql-k8s charm revision: 158
pgbouncer-k8s charm revision: 76

microk8s: MicroK8s v1.27.7 revision 6101

Log output

Juju debug log:

unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log ops 2.7.0 up and running.
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log No value found for secret unit:cauth
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log No value found for secret unit:chain
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log No value found for secret unit:key
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log No value found for secret unit:cert
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log Emitting Juju event update_status.
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log Secret secret://2d108cf3-d83b-4e00-8c14-89af8ea6dd53/clnhhgvmp25c7420hm30 downloaded
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log Getting secret app:operator-password
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log Getting secret app:replication-password
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log Getting secret app:rewind-password
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log Starting new HTTP connection (1): postgresql-k8s-0.postgresql-k8s-endpoints:8008
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log http://postgresql-k8s-0.postgresql-k8s-endpoints:8008 "GET /health HTTP/1.1" 200 None
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log Getting secret app:operator-password
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log Getting secret app:replication-password
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log Getting secret app:rewind-password
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log Starting new HTTP connection (1): postgresql-k8s-0.postgresql-k8s-endpoints:8008
unit-postgresql-k8s-0: 18:27:52 DEBUG unit.postgresql-k8s/0.juju-log http://postgresql-k8s-0.postgresql-k8s-endpoints:8008 "GET /cluster HTTP/1.1" 200 None
unit-postgresql-k8s-0: 18:27:52 WARNING unit.postgresql-k8s/0.juju-log No relation: certificates
unit-postgresql-k8s-0: 18:27:52 INFO unit.postgresql-k8s/0.juju-log Kubernetes service 'postgresql-k8s' patched successfully
unit-postgresql-k8s-0: 18:27:52 INFO juju.worker.uniter.operation ran "update-status" hook (via hook dispatching script: dispatch)
unit-pgbouncer-k8s-0: 18:27:56 DEBUG unit.pgbouncer-k8s/0.juju-log ops 2.7.0 up and running.
unit-pgbouncer-k8s-0: 18:27:56 DEBUG unit.pgbouncer-k8s/0.juju-log Invalid Prometheus alert rules folder at /var/lib/juju/agents/unit-pgbouncer-k8s-0/charm/src/prometheus_alert_rules: directory does not exist
unit-pgbouncer-k8s-0: 18:27:56 DEBUG unit.pgbouncer-k8s/0.juju-log Invalid Loki alert rules folder at /var/lib/juju/agents/unit-pgbouncer-k8s-0/charm/src/loki_alert_rules: directory does not exist
unit-pgbouncer-k8s-0: 18:27:56 DEBUG unit.pgbouncer-k8s/0.juju-log Emitting Juju event update_status.
unit-pgbouncer-k8s-0: 18:27:56 WARNING unit.pgbouncer-k8s/0.juju-log No relation: certificates
unit-pgbouncer-k8s-0: 18:27:57 INFO juju.worker.uniter.operation ran "update-status" hook (via hook dispatching script: dispatch)
unit-data-integrator-0: 18:29:11 DEBUG unit.data-integrator/0.juju-log ops 2.4.1 up and running.
unit-data-integrator-0: 18:29:11 DEBUG unit.data-integrator/0.juju-log Emitting Juju event update_status.

Additional context

juju status --integrations:

image

Thank you for the bugreport!

The new pgbouncer-k8s revision 81 has been released with a new pgbouncer version 1.21 + Juju Secrets fixes.
Release notes: https://charmhub.io/pgbouncer-k8s/docs/r-releases-rev81

The issue is no longer reproducible there. Resolved.