Skip to content

Commit 8fea63a

Browse files
authored
[MISC] Update snap and renovate fixes (#432)
* Update snap and renovate tweaks * Revert charm.py * Only check for blocked status * Try larger ffwd period * Handle update config exceptions in push tls files * Use charm fixture instead of building it on the fly * Don't clean up per cloud app * Check old juju 2 agent * Redeploy old charm
1 parent c34b78d commit 8fea63a

File tree

7 files changed

+87
-34
lines changed

7 files changed

+87
-34
lines changed

.github/renovate.json5

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"extends": ["github>canonical/data-platform//renovate_presets/charm.json5"],
4-
"reviewers": ["dragomirp", "marceloneppel", "taurus-forever"],
4+
"reviewers": ["dragomirp", "lucasgameiroborges", "marceloneppel", "taurus-forever"],
55
"packageRules": [
66
// Later rules override earlier rules
77
{
@@ -10,6 +10,66 @@
1010
}, {
1111
"matchPackageNames": ["python"],
1212
"allowedVersions": "<3.11"
13+
},
14+
{
15+
"matchDepNames": ["Juju 2"],
16+
"matchPackageNames": ["juju/juju"],
17+
"allowedVersions": "<3.0.0",
18+
"extractVersion": "^v(?<version>.*)$",
19+
"groupName": "Juju 2"
20+
},
21+
{
22+
"matchDepNames": ["Juju 3"],
23+
"matchPackageNames": ["juju/juju"],
24+
"allowedVersions": "<3.2.0",
25+
"extractVersion": "^v(?<version>.*)$",
26+
"groupName": "Juju 3"
27+
},
28+
{
29+
"matchDepNames": ["libjuju 2"],
30+
"matchPackageNames": ["juju"],
31+
"matchManagers": ["regex"],
32+
"matchDatasources": ["pypi"],
33+
"versioning": "loose",
34+
"allowedVersions": "<3",
35+
"groupName": "Juju 2"
36+
}
37+
],
38+
"regexManagers": [
39+
{
40+
"customType": "regex",
41+
"fileMatch": ["^(workflow-templates|\\.github/workflows)/[^/]+\\.ya?ml$"],
42+
"matchStrings": [
43+
"(- agent: )(?<currentValue>.*?) +# renovate: latest juju 2"
44+
],
45+
"depNameTemplate": "Juju 2",
46+
"packageNameTemplate": "juju/juju",
47+
"datasourceTemplate": "github-releases",
48+
"versioningTemplate": "loose",
49+
"extractVersionTemplate": "Juju release"
50+
},
51+
{
52+
"customType": "regex",
53+
"fileMatch": ["^(workflow-templates|\\.github/workflows)/[^/]+\\.ya?ml$"],
54+
"matchStrings": [
55+
"(- agent: )(?<currentValue>.*?) +# renovate: latest juju 3"
56+
],
57+
"depNameTemplate": "Juju 3",
58+
"packageNameTemplate": "juju/juju",
59+
"datasourceTemplate": "github-releases",
60+
"versioningTemplate": "loose",
61+
"extractVersionTemplate": "Juju release"
62+
},
63+
{
64+
"customType": "regex",
65+
"fileMatch": ["^(workflow-templates|\\.github/workflows)/[^/]+\\.ya?ml$"],
66+
"matchStrings": [
67+
"(libjuju: )==(?<currentValue>.*?) +# renovate: latest libjuju 2"
68+
],
69+
"depNameTemplate": "libjuju 2",
70+
"packageNameTemplate": "juju",
71+
"datasourceTemplate": "pypi",
72+
"versioningTemplate": "loose"
1373
}
1474
]
1575
}

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ jobs:
5151
fail-fast: false
5252
matrix:
5353
juju:
54-
- agent: 2.9.46
55-
libjuju: ^2
54+
- agent: 2.9.46 # renovate: latest juju 2
55+
libjuju: ==2.9.46.1 # renovate: latest libjuju 2
5656
allure: false
57-
- agent: 3.1.7
57+
- agent: 3.1.7 # renovate: latest juju 3
5858
allure: true
5959
name: Integration test charm | ${{ matrix.juju.agent }}
6060
needs:

poetry.lock

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

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workf
7070
pytest-operator = "^0.34.0"
7171
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.1.0", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
7272
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.1.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
73-
juju = "^3.3.0.0"
73+
# renovate caret doesn't work: https://github.com/renovatebot/renovate/issues/26940
74+
juju = "<=3.4.0.0"
7475
boto3 = "*"
7576
tenacity = "*"
7677
landscape-api-py3 = "^0.9.0"

src/charm.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,11 @@ def push_tls_files_to_workload(self) -> bool:
13901390
if cert is not None:
13911391
self._patroni.render_file(f"{PATRONI_CONF_PATH}/{TLS_CERT_FILE}", cert, 0o600)
13921392

1393-
return self.update_config()
1393+
try:
1394+
return self.update_config()
1395+
except Exception:
1396+
logger.exception("TLS files failed to push. Error in config update")
1397+
return False
13941398

13951399
def _reboot_on_detached_storage(self, event: EventBase) -> None:
13961400
"""Reboot on detached storage.

src/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
SNAP_PACKAGES = [
3636
(
3737
POSTGRESQL_SNAP_NAME,
38-
{"revision": {"aarch64": "105", "x86_64": "104"}, "channel": "14/stable"},
38+
{"revision": {"aarch64": "110", "x86_64": "111"}, "channel": "14/stable"},
3939
)
4040
]
4141

tests/integration/test_backups.py

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,8 @@ async def cloud_configs(ops_test: OpsTest, github_secrets) -> None:
9292

9393
@pytest.mark.group(1)
9494
@pytest.mark.abort_on_fail
95-
async def test_backup(ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict]) -> None:
95+
async def test_backup(ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict], charm) -> None:
9696
"""Build and deploy two units of PostgreSQL and then test the backup and restore actions."""
97-
# Build the PostgreSQL charm.
98-
charm = await ops_test.build_charm(".")
99-
10097
# Deploy S3 Integrator and TLS Certificates Operator.
10198
await ops_test.model.deploy(S3_INTEGRATOR_APP_NAME)
10299
await ops_test.model.deploy(TLS_CERTIFICATES_APP_NAME, config=TLS_CONFIG, channel=TLS_CHANNEL)
@@ -126,7 +123,7 @@ async def test_backup(ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict]) -> No
126123
await action.wait()
127124
async with ops_test.fast_forward(fast_interval="60s"):
128125
await ops_test.model.wait_for_idle(
129-
apps=[database_app_name, S3_INTEGRATOR_APP_NAME], status="active", timeout=1200
126+
apps=[database_app_name, S3_INTEGRATOR_APP_NAME], status="active", timeout=1500
130127
)
131128

132129
primary = await get_primary(ops_test, f"{database_app_name}/0")
@@ -279,14 +276,14 @@ async def test_backup(ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict]) -> No
279276

280277
# Remove the database app.
281278
await ops_test.model.remove_application(database_app_name, block_until_done=True)
279+
282280
# Remove the TLS operator.
283281
await ops_test.model.remove_application(TLS_CERTIFICATES_APP_NAME, block_until_done=True)
284282

285283

286284
@pytest.mark.group(1)
287-
async def test_restore_on_new_cluster(ops_test: OpsTest, github_secrets) -> None:
285+
async def test_restore_on_new_cluster(ops_test: OpsTest, github_secrets, charm) -> None:
288286
"""Test that is possible to restore a backup to another PostgreSQL cluster."""
289-
charm = await ops_test.build_charm(".")
290287
previous_database_app_name = f"{DATABASE_APP_NAME}-gcp"
291288
database_app_name = f"new-{DATABASE_APP_NAME}"
292289
await ops_test.model.deploy(charm, application_name=previous_database_app_name)
@@ -355,12 +352,9 @@ async def test_restore_on_new_cluster(ops_test: OpsTest, github_secrets) -> None
355352

356353
# Wait for the restore to complete.
357354
async with ops_test.fast_forward():
358-
await wait_for_idle_on_blocked(
359-
ops_test,
360-
database_app_name,
361-
0,
362-
S3_INTEGRATOR_APP_NAME,
363-
ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE,
355+
unit = ops_test.model.units.get(f"{database_app_name}/0")
356+
await ops_test.model.block_until(
357+
lambda: unit.workload_status_message == ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE
364358
)
365359

366360
# Check that the backup was correctly restored by having only the first created table.
@@ -402,12 +396,9 @@ async def test_invalid_config_and_recovery_after_fixing_it(
402396
)
403397
await action.wait()
404398
logger.info("waiting for the database charm to become blocked")
405-
await wait_for_idle_on_blocked(
406-
ops_test,
407-
database_app_name,
408-
0,
409-
S3_INTEGRATOR_APP_NAME,
410-
FAILED_TO_ACCESS_CREATE_BUCKET_ERROR_MESSAGE,
399+
unit = ops_test.model.units.get(f"{database_app_name}/0")
400+
await ops_test.model.block_until(
401+
lambda: unit.workload_status_message == FAILED_TO_ACCESS_CREATE_BUCKET_ERROR_MESSAGE
411402
)
412403

413404
# Provide valid backup configurations, but from another cluster repository.
@@ -421,12 +412,9 @@ async def test_invalid_config_and_recovery_after_fixing_it(
421412
)
422413
await action.wait()
423414
logger.info("waiting for the database charm to become blocked")
424-
await wait_for_idle_on_blocked(
425-
ops_test,
426-
database_app_name,
427-
0,
428-
S3_INTEGRATOR_APP_NAME,
429-
ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE,
415+
unit = ops_test.model.units.get(f"{database_app_name}/0")
416+
await ops_test.model.block_until(
417+
lambda: unit.workload_status_message == ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE
430418
)
431419

432420
# Provide valid backup configurations, with another path in the S3 bucket.

0 commit comments

Comments
 (0)