Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Jan 23, 2024
1 parent a58f334 commit 10b6f86
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 44 deletions.
15 changes: 7 additions & 8 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,23 +794,22 @@ def _get_relation_config(self) -> Tuple[Dict[str, Dict[str, str]], List[str]]:
pgb_dbs = {}
pgb_admins = []
for database in databases:
pgb_dbs[database["name"]] = {
name = database["name"]
pgb_dbs[name] = {
"host": host,
"dbname": database,
"dbname": name,
"port": port,
"auth_user": self.backend.auth_user,
}
if r_hosts:
pgb_dbs[f"{database['name']}_readonly"] = {
pgb_dbs[f"{name}_readonly"] = {
"host": r_hosts,
"dbname": database,
"dbname": name,
"port": r_port,
"auth_user": self.backend.auth_user,
}
if database["legacy"]:
pgb_dbs[f"{database['name']}_standby"] = pgb_dbs[
f"{database['name']}_readonly"
]
pgb_dbs[f"{name}_standby"] = pgb_dbs[f"{name}_readonly"]
if "admin" in database:
pgb_admins.append(pgb_admins)
return (pgb_dbs, pgb_admins)
Expand All @@ -834,7 +833,7 @@ def render_pgb_config(self, reload_pgbouncer=False) -> None:
perm = 0o400
with open("templates/pgb_config.j2", "r") as file:
template = Template(file.read())
databases, admins = self._generate_username()
databases, admins = self._get_relation_config()
enable_tls = all(self.tls.get_tls_files())
for service in self._services:
self.push_file(
Expand Down
1 change: 0 additions & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
UNIT_SCOPE = "unit"

SECRET_KEY_OVERRIDES = {
"cfg_file": "cfg-file",
"ca": "cauth",
"monitoring_password": "monitoring-password",
"auth_file": "auth-file",
Expand Down
35 changes: 0 additions & 35 deletions src/relations/peers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,6 @@
│ application data │ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ │ │ │
│ │ │ auth_file "pgbouncer_auth_relation_id_3" "md5aad46d9afbcc8c8248d254d567b577c1" │ │
│ │ │ cfg_file │ │
│ │ │ application_first_database = │ │
│ │ │ host=postgresql-k8s-primary.test-pgbouncer-provider-gnrj.svc.cluster.loc… │ │
│ │ │ dbname=application_first_database port=5432 │ │
│ │ │ auth_user=pgbouncer_auth_relation_id_3 │ │
│ │ │ application_first_database_readonly = │ │
│ │ │ host=postgresql-k8s-replicas.test-pgbouncer-provider-gnrj.svc.cluster.lo… │ │
│ │ │ dbname=application_first_database port=5432 │ │
│ │ │ auth_user=pgbouncer_auth_relation_id_3 │ │
│ │ │ │ │
│ │ │ │ │
│ │ │ listen_addr = * │ │
│ │ │ listen_port = 6432 │ │
│ │ │ logfile = /var/lib/postgresql/pgbouncer/pgbouncer.log │ │
│ │ │ pidfile = /var/lib/postgresql/pgbouncer/pgbouncer.pid │ │
│ │ │ admin_users = relation_id_3 │ │
│ │ │ stats_users = │ │
│ │ │ auth_type = md5 │ │
│ │ │ user = postgres │ │
│ │ │ max_client_conn = 10000 │ │
│ │ │ ignore_startup_parameters = extra_float_digits │ │
│ │ │ server_tls_sslmode = prefer │ │
│ │ │ so_reuseport = 1 │ │
│ │ │ unix_socket_dir = /var/lib/postgresql/pgbouncer │ │
│ │ │ pool_mode = session │ │
│ │ │ max_db_connections = 100 │ │
│ │ │ default_pool_size = 13 │ │
│ │ │ min_pool_size = 7 │ │
│ │ │ reserve_pool_size = 7 │ │
│ │ │ auth_query = SELECT username, password FROM │ │
│ │ │ pgbouncer_auth_relation_id_3.get_auth($1) │ │
│ │ │ auth_file = /var/lib/postgresql/pgbouncer/userlist.txt │ │
│ │ │ │ │
│ │ │ │ │
│ │ │ leader_hostname pgbouncer-k8s-0.pgbouncer-k8s-endpoints.test-pgbouncer-provider-gnrj.svc… │ │
│ │ │ relation_id_4 Z4OtFCe6r5HG6mk1XuR6LkwZ │ │
│ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
Expand All @@ -72,7 +38,6 @@

from constants import APP_SCOPE, AUTH_FILE_DATABAG_KEY, PEER_RELATION_NAME

CFG_FILE_DATABAG_KEY = "cfg_file"
ADDRESS_KEY = "private-address"
LEADER_ADDRESS_KEY = "leader_hostname"

Expand Down

0 comments on commit 10b6f86

Please sign in to comment.