Skip to content

Commit

Permalink
[DPE-3050] Template config (#159)
Browse files Browse the repository at this point in the history
* Template config

* Update rel info leader guards

* Cleanup

* Regenerate peer database mapping during upgrade

* Order read only endpoints

* Bump libs

* Reenable unit tests

* Converge on k8s rels implementation

* Converge on k8s check status implementation

* Don't set active status directly

* Conditionally update the readonly endpoints

* Try to maintain status

* Reset prometheus service on start

* Check for peer relation when departing backend database

* Update unstable user removal test

* Fix ports

* Redundant client update

* Try to fix upgrades

* Check that secret is up to date (#192)

* Check that secret is up to date

* Check for stale secret in backend ready

* Check for stale secret in on start

* Always regenerate dbs and reuse backend if available

* Str keys for db mapping

* Try to test all units connection

* Fix expose flag checking

* Update userlist on peer change

* exit backend broken on missing peer rel
  • Loading branch information
dragomirp authored Apr 2, 2024
1 parent d3b61ba commit 0791812
Show file tree
Hide file tree
Showing 22 changed files with 1,043 additions and 1,470 deletions.
385 changes: 2 additions & 383 deletions lib/charms/pgbouncer_k8s/v0/pgb.py

Large diffs are not rendered by default.

33 changes: 15 additions & 18 deletions lib/charms/postgresql_k8s/v0/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Any charm using this library should import the `psycopg2` or `psycopg2-binary` dependency.
"""

import logging
from collections import OrderedDict
from typing import Dict, List, Optional, Set, Tuple
Expand All @@ -35,7 +36,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 24
LIBPATCH = 25

INVALID_EXTRA_USER_ROLE_BLOCKING_MESSAGE = "invalid role(s) for extra user roles"

Expand Down Expand Up @@ -358,9 +359,7 @@ def _generate_database_privileges_statements(
statements.append(
"""UPDATE pg_catalog.pg_largeobject_metadata
SET lomowner = (SELECT oid FROM pg_roles WHERE rolname = '{}')
WHERE lomowner = (SELECT oid FROM pg_roles WHERE rolname = '{}');""".format(
user, self.user
)
WHERE lomowner = (SELECT oid FROM pg_roles WHERE rolname = '{}');""".format(user, self.user)
)
else:
for schema in schemas:
Expand Down Expand Up @@ -562,18 +561,16 @@ def build_postgresql_parameters(
parameters = {}
for config, value in config_options.items():
# Filter config option not related to PostgreSQL parameters.
if not config.startswith(
(
"durability",
"instance",
"logging",
"memory",
"optimizer",
"request",
"response",
"vacuum",
)
):
if not config.startswith((
"durability",
"instance",
"logging",
"memory",
"optimizer",
"request",
"response",
"vacuum",
)):
continue
parameter = "_".join(config.split("_")[1:])
if parameter in ["date_style", "time_zone"]:
Expand All @@ -594,8 +591,8 @@ def build_postgresql_parameters(
# and the remaining as cache memory.
shared_buffers = int(available_memory * 0.25)
effective_cache_size = int(available_memory - shared_buffers)
parameters.setdefault("shared_buffers", f"{int(shared_buffers/10**6)}MB")
parameters.update({"effective_cache_size": f"{int(effective_cache_size/10**6)}MB"})
parameters.setdefault("shared_buffers", f"{int(shared_buffers / 10**6)}MB")
parameters.update({"effective_cache_size": f"{int(effective_cache_size / 10**6)}MB"})
else:
# Return default
parameters.setdefault("shared_buffers", "128MB")
Expand Down
Loading

0 comments on commit 0791812

Please sign in to comment.