Skip to content

Commit de74296

Browse files
authored
[MISC] Enable Juju 3.6 (#813)
* TLS defer * Don't overwrite keys * Disable primary label tests
1 parent b9f24b2 commit de74296

File tree

7 files changed

+57
-37
lines changed

7 files changed

+57
-37
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ jobs:
5757
- agent: 2.9.51 # renovate: juju-agent-pin-minor
5858
libjuju: ==2.9.49.1 # renovate: latest libjuju 2
5959
allure_on_amd64: false
60-
- agent: 3.4.6 # renovate: juju-agent-pin-minor
60+
- agent: 3.6.1 # renovate: juju-agent-pin-minor
6161
allure_on_amd64: true
6262
architecture:
6363
- amd64
6464
include:
6565
- juju:
66-
agent: 3.4.6 # renovate: juju-agent-pin-minor
66+
agent: 3.6.1 # renovate: juju-agent-pin-minor
6767
allure_on_amd64: true
6868
architecture: arm64
6969
name: Integration | ${{ matrix.juju.agent }} | ${{ matrix.architecture }}

lib/charms/postgresql_k8s/v0/postgresql.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import logging
2323
from collections import OrderedDict
24-
from typing import Optional, Set, Tuple
24+
from typing import List, Optional, Set, Tuple
2525

2626
import psycopg2
2727
from ops.model import Relation
@@ -35,7 +35,7 @@
3535

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

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

@@ -108,7 +108,7 @@ def __init__(
108108
user: str,
109109
password: str,
110110
database: str,
111-
system_users: Optional[list[str]] = None,
111+
system_users: Optional[List[str]] = None,
112112
):
113113
self.primary_host = primary_host
114114
self.current_host = current_host
@@ -161,8 +161,8 @@ def create_database(
161161
self,
162162
database: str,
163163
user: str,
164-
plugins: Optional[list[str]] = None,
165-
client_relations: Optional[list[Relation]] = None,
164+
plugins: Optional[List[str]] = None,
165+
client_relations: Optional[List[Relation]] = None,
166166
) -> None:
167167
"""Creates a new database and grant privileges to a user on it.
168168
@@ -368,8 +368,8 @@ def enable_disable_extensions(
368368
connection.close()
369369

370370
def _generate_database_privileges_statements(
371-
self, relations_accessing_this_database: int, schemas: list[str], user: str
372-
) -> list[Composed]:
371+
self, relations_accessing_this_database: int, schemas: List[str], user: str
372+
) -> List[Composed]:
373373
"""Generates a list of databases privileges statements."""
374374
statements = []
375375
if relations_accessing_this_database == 1:

lib/charms/postgresql_k8s/v0/postgresql_tls.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

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

5050
logger = logging.getLogger(__name__)
5151
SCOPE = "unit"
@@ -130,11 +130,21 @@ def _on_certificate_available(self, event: CertificateAvailableEvent) -> None:
130130
logger.error("An unknown certificate available.")
131131
return
132132

133-
self.charm.set_secret(
134-
SCOPE, "chain", "\n".join(event.chain) if event.chain is not None else None
135-
)
136-
self.charm.set_secret(SCOPE, "cert", event.certificate)
137-
self.charm.set_secret(SCOPE, "ca", event.ca)
133+
if not event.certificate:
134+
logger.debug("No certificate available.")
135+
event.defer()
136+
return
137+
138+
chain = self.charm.get_secret(SCOPE, "chain")
139+
new_chain = "\n".join(event.chain) if event.chain is not None else None
140+
if chain != new_chain:
141+
self.charm.set_secret(SCOPE, "chain", new_chain)
142+
cert = self.charm.get_secret(SCOPE, "cert")
143+
if cert != event.certificate:
144+
self.charm.set_secret(SCOPE, "cert", event.certificate)
145+
ca = self.charm.get_secret(SCOPE, "ca")
146+
if ca != event.ca:
147+
self.charm.set_secret(SCOPE, "ca", event.ca)
138148

139149
try:
140150
if not self.charm.push_tls_files_to_workload():

poetry.lock

Lines changed: 27 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workf
7070
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
7171
allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"}
7272
# renovate caret doesn't work: https://github.com/renovatebot/renovate/issues/26940
73-
juju = "<=3.5.2.1"
73+
juju = "<=3.6.1.0"
7474
psycopg2-binary = "^2.9.10"
7575
boto3 = "^1.35.70"
7676
tenacity = "^9.0.0"

tests/integration/ha_tests/test_rollback_to_master_label.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
@pytest.mark.group(1)
4040
@markers.juju3
41+
@pytest.mark.unstable
4142
@markers.amd64_only # TODO: remove after arm64 stable release
4243
@pytest.mark.abort_on_fail
4344
async def test_deploy_stable(ops_test: OpsTest) -> None:
@@ -72,6 +73,7 @@ async def test_deploy_stable(ops_test: OpsTest) -> None:
7273

7374
@pytest.mark.group(1)
7475
@markers.juju3
76+
@pytest.mark.unstable
7577
@markers.amd64_only # TODO: remove after arm64 stable release
7678
async def test_fail_and_rollback(ops_test, continuous_writes) -> None:
7779
# Start an application that continuously writes data to the database.

tests/integration/ha_tests/test_upgrade_to_primary_label.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
@pytest.mark.group(1)
3838
@markers.amd64_only # TODO: remove after arm64 stable release
39+
@pytest.mark.unstable
3940
@pytest.mark.abort_on_fail
4041
async def test_deploy_stable(ops_test: OpsTest) -> None:
4142
"""Simple test to ensure that the PostgreSQL and application charms get deployed."""
@@ -75,6 +76,7 @@ async def test_deploy_stable(ops_test: OpsTest) -> None:
7576

7677
@pytest.mark.group(1)
7778
@markers.amd64_only # TODO: remove after arm64 stable release
79+
@pytest.mark.unstable
7880
async def test_upgrade(ops_test, continuous_writes) -> None:
7981
# Start an application that continuously writes data to the database.
8082
logger.info("starting continuous writes to the database")

0 commit comments

Comments
 (0)