Skip to content

Commit

Permalink
[DPE-4816] Add jinja2 as a dependency (#276)
Browse files Browse the repository at this point in the history
* Add jinja2 as a dependency

* Bump libs

* Increate connections for landscape test
  • Loading branch information
dragomirp authored Jul 5, 2024
1 parent 3036339 commit bd56ca9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
16 changes: 15 additions & 1 deletion lib/charms/postgresql_k8s/v0/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,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 = 29
LIBPATCH = 30

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

Expand Down Expand Up @@ -79,6 +79,10 @@ class PostgreSQLEnableDisableExtensionError(Exception):
"""Exception raised when enabling/disabling an extension fails."""


class PostgreSQLGetLastArchivedWALError(Exception):
"""Exception raised when retrieving last archived WAL fails."""


class PostgreSQLGetPostgreSQLVersionError(Exception):
"""Exception raised when retrieving PostgreSQL version fails."""

Expand Down Expand Up @@ -383,6 +387,16 @@ def _generate_database_privileges_statements(
)
return statements

def get_last_archived_wal(self) -> str:
"""Get the name of the last archived wal for the current PostgreSQL cluster."""
try:
with self._connect_to_database() as connection, connection.cursor() as cursor:
cursor.execute("SELECT last_archived_wal FROM pg_stat_archiver;")
return cursor.fetchone()[0]
except psycopg2.Error as e:
logger.error(f"Failed to get PostgreSQL last archived WAL: {e}")
raise PostgreSQLGetLastArchivedWALError()

def get_postgresql_text_search_configs(self) -> Set[str]:
"""Returns the PostgreSQL available text search configs.
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cryptography = "^42.0.8"
jsonschema = "^4.22.0"
psycopg2 = "^2.9.9"
psycopg = {extras = ["c"], version = "^3.2.1"}
jinja2 = "^3.1.4"

[tool.poetry.group.charm-libs.dependencies]
# data_platform_libs/v0/data_interfaces.py
Expand Down Expand Up @@ -60,7 +61,6 @@ optional = true
coverage = {extras = ["toml"], version = "^7.5.4"}
pytest = "^8.2.2"
pytest-asyncio = "*"
jinja2 = "^3.1.4"
parameterized = "^0.9.0"

[tool.poetry.group.integration]
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/relations/test_db_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def test_landscape_scalable_bundle_db(ops_test: OpsTest, pgb_charm_jammy:
db_units=DATABASE_UNITS,
pgb_series="jammy",
pg_config={"profile": "testing"},
pgb_config={"max_db_connections": "20", "pool_mode": "transaction"},
pgb_config={"max_db_connections": "40", "pool_mode": "transaction"},
)

# Deploy and test the Landscape Scalable bundle (using this PostgreSQL charm).
Expand Down

0 comments on commit bd56ca9

Please sign in to comment.