Skip to content

Commit

Permalink
TLS defer
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Jan 7, 2025
1 parent 0f7a2df commit cc4a25b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ jobs:
- agent: 2.9.51 # renovate: juju-agent-pin-minor
libjuju: ==2.9.49.1 # renovate: latest libjuju 2
allure_on_amd64: false
- agent: 3.4.6 # renovate: juju-agent-pin-minor
- agent: 3.6.1 # renovate: juju-agent-pin-minor
allure_on_amd64: true
architecture:
- amd64
include:
- juju:
agent: 3.4.6 # renovate: juju-agent-pin-minor
agent: 3.6.1 # renovate: juju-agent-pin-minor
allure_on_amd64: true
architecture: arm64
name: Integration | ${{ matrix.juju.agent }} | ${{ matrix.architecture }}
Expand Down
10 changes: 5 additions & 5 deletions lib/charms/postgresql_k8s/v0/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import logging
from collections import OrderedDict
from typing import Optional, Set, Tuple
from typing import List, Optional, Set, Tuple

import psycopg2
from ops.model import Relation
Expand All @@ -35,7 +35,7 @@

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

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

Expand Down Expand Up @@ -108,7 +108,7 @@ def __init__(
user: str,
password: str,
database: str,
system_users: Optional[list[str]] = None,
system_users: Optional[List[str]] = None,
):
self.primary_host = primary_host
self.current_host = current_host
Expand Down Expand Up @@ -161,8 +161,8 @@ def create_database(
self,
database: str,
user: str,
plugins: Optional[list[str]] = None,
client_relations: Optional[list[Relation]] = None,
plugins: Optional[List[str]] = None,
client_relations: Optional[List[Relation]] = None,
) -> None:
"""Creates a new database and grant privileges to a user on it.
Expand Down
7 changes: 6 additions & 1 deletion lib/charms/postgresql_k8s/v0/postgresql_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

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

logger = logging.getLogger(__name__)
SCOPE = "unit"
Expand Down Expand Up @@ -136,6 +136,11 @@ def _on_certificate_available(self, event: CertificateAvailableEvent) -> None:
self.charm.set_secret(SCOPE, "cert", event.certificate)
self.charm.set_secret(SCOPE, "ca", event.ca)

if not event.certificate:
logger.debug("Cannot push TLS certificates at this moment")
event.defer()
return

try:
if not self.charm.push_tls_files_to_workload():
logger.debug("Cannot push TLS certificates at this moment")
Expand Down
48 changes: 27 additions & 21 deletions 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 @@ -70,7 +70,7 @@ pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workf
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.5", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.5", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"}
# renovate caret doesn't work: https://github.com/renovatebot/renovate/issues/26940
juju = "<=3.5.2.1"
juju = "<=3.6.1.0"
psycopg2-binary = "^2.9.10"
boto3 = "^1.35.70"
tenacity = "^9.0.0"
Expand Down

0 comments on commit cc4a25b

Please sign in to comment.