Skip to content

Commit abd5ebc

Browse files
Add refresh v3 implementation (#411)
Does not include migration for refreshing from v2 (currently on stable) This PR branch only supports refreshing to/from mysql-router-k8s charm code with refresh v3 Uses `charm-refresh` Python package: https://github.com/canonical/charm-refresh Discussed with @paulomach—we will merge this & release to edge to enable mysql-router monorepo migration, but we will not promote to beta/candidate/stable until the v2 to v3 migration is implemented (once a decision on specification DA202 is made) Mostly the same as canonical/mysql-router-operator#241 (plus canonical/mysql-router-operator#279)
1 parent 5fb9752 commit abd5ebc

30 files changed

+620
-838
lines changed

.github/workflows/integration_test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ jobs:
8484
needs:
8585
- collect-integration-tests
8686
runs-on: ${{ matrix.job.runner }}
87-
timeout-minutes: 217 # Sum of steps `timeout-minutes` + 5
87+
timeout-minutes: 226 # Sum of steps `timeout-minutes` + 5
8888
steps:
8989
- name: Free up disk space
90-
timeout-minutes: 1
90+
timeout-minutes: 10
9191
run: |
9292
printf '\nDisk usage before cleanup\n'
9393
df --human-readable

.github/workflows/release.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright 2023 Canonical Ltd.
22
# See LICENSE file for licensing details.
3-
name: Release to Charmhub
3+
name: Release to Charmhub edge
44

55
on:
66
push:
@@ -13,18 +13,29 @@ on:
1313
- '.github/workflows/sync_docs.yaml'
1414

1515
jobs:
16+
tag:
17+
name: Create charm refresh compatibility version git tag
18+
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
19+
with:
20+
track: '8.0'
21+
permissions:
22+
contents: write # Needed to create git tag
23+
1624
ci-tests:
25+
needs:
26+
- tag
1727
uses: ./.github/workflows/ci.yaml
1828
permissions:
1929
contents: write # Needed for Allure Report
2030

2131
release:
2232
name: Release charm
2333
needs:
34+
- tag
2435
- ci-tests
2536
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
2637
with:
27-
track: '8.0'
38+
track: ${{ needs.tag.outputs.track }}
2839
artifact-prefix: ${{ needs.ci-tests.outputs.artifact-prefix }}
2940
secrets:
3041
charmhub-token: ${{ secrets.CHARMHUB_TOKEN }}

actions.yaml

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,61 @@
11
# Copyright 2023 Canonical Ltd.
22
# See LICENSE file for licensing details.
33

4-
resume-upgrade:
5-
description: Upgrade remaining units (after you manually verified that upgraded units are healthy).
4+
pre-refresh-check:
5+
description: Check if charm is ready to refresh
6+
additionalProperties: false
7+
force-refresh-start:
8+
description: |
9+
Potential of data loss and downtime
10+
11+
Force refresh of first unit
12+
13+
Must run with at least one of the parameters `=false`
614
params:
7-
force:
15+
check-compatibility:
16+
type: boolean
17+
default: true
18+
description: |
19+
Potential of data loss and downtime
20+
21+
If `false`, force refresh if new version of Router and/or charm is not compatible with previous version
22+
run-pre-refresh-checks:
823
type: boolean
9-
default: false
24+
default: true
1025
description: |
11-
Potential of *data loss* and *downtime*
12-
13-
Force upgrade of next unit.
14-
15-
Use to
16-
- force incompatible upgrade and/or
17-
- continue upgrade if 1+ upgraded units have non-active status
18-
required: []
26+
Potential of data loss and downtime
27+
28+
If `false`, force refresh if app is unhealthy or not ready to refresh (and unit status shows "Pre-refresh check failed")
29+
check-workload-container:
30+
type: boolean
31+
default: true
32+
description: |
33+
Potential of data loss and downtime during and after refresh
34+
35+
If `false`, allow refresh to Router container version that has not been validated to work with the charm revision
36+
additionalProperties: false
37+
resume-refresh:
38+
description: |
39+
Refresh next unit(s) (after you have manually verified that refreshed units are healthy)
40+
41+
If the `pause-after-unit-refresh` config is set to `all`, this action will refresh the next unit.
42+
43+
If `pause-after-unit-refresh` is set to `first`, this action will refresh all remaining units.
44+
Exception: if automatic health checks fail after a unit has refreshed, the refresh will pause.
45+
46+
If `pause-after-unit-refresh` is set to `none`, this action will have no effect unless it is called with `check-health-of-refreshed-units` as `false`.
47+
params:
48+
check-health-of-refreshed-units:
49+
type: boolean
50+
default: true
51+
description: |
52+
Potential of data loss and downtime
53+
54+
If `false`, force refresh (of next unit) if 1 or more refreshed units are unhealthy
55+
56+
Warning: if first unit to refresh is unhealthy, consider running `force-refresh-start` action on that unit instead of using this parameter.
57+
If first unit to refresh is unhealthy because compatibility checks, pre-refresh checks, or workload container checks are failing, this parameter is more destructive than the `force-refresh-start` action.
58+
additionalProperties: false
1959

2060
set-tls-private-key:
2161
description:

charm_version

Lines changed: 0 additions & 1 deletion
This file was deleted.

charmcraft.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,21 @@ parts:
8484
files:
8585
plugin: dump
8686
source: .
87+
after:
88+
- poetry-deps # Ensure poetry is installed
8789
build-packages:
8890
- git
8991
override-build: |
90-
# Workaround to add unique identifier (git hash) to charm version while specification
91-
# DA053 - Charm versioning
92-
# (https://docs.google.com/document/d/1Jv1jhWLl8ejK3iJn7Q3VbCIM9GIhp8926bgXpdtx-Sg/edit?pli=1)
93-
# is pending review.
94-
python3 -c 'import pathlib; import shutil; import subprocess; git_hash=subprocess.run(["git", "describe", "--always", "--dirty"], capture_output=True, check=True, encoding="utf-8").stdout; file = pathlib.Path("charm_version"); shutil.copy(file, pathlib.Path("charm_version.backup")); version = file.read_text().strip(); file.write_text(f"{version}+{git_hash}")'
92+
# Set `charm_version` in refresh_versions.toml from git tag
93+
# Create venv in `..` so that git working tree is not dirty
94+
python3 -m venv ../refresh-version-venv
95+
source ../refresh-version-venv/bin/activate
96+
poetry install --only build-refresh-version
97+
write-charm-version
9598
9699
craftctl default
97100
stage:
98101
- LICENSE
99-
- charm_version
100-
- workload_version
102+
- refresh_versions.toml
101103
- scripts
102104
- templates

config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ options:
1515
and managed by the charm.
1616
type: string
1717
default: "{}"
18+
19+
pause-after-unit-refresh:
20+
description: |
21+
Wait for manual confirmation to resume refresh after these units refresh
22+
23+
Allowed values: "all", "first", "none"
24+
type: string
25+
default: first

metadata.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ requires:
4949
peers:
5050
cos:
5151
interface: cos
52-
upgrade-version-a:
53-
# Relation versioning scheme:
54-
# DA056 - Upgrading in-place upgrade protocol
55-
# https://docs.google.com/document/d/1H7qy5SAwLiCOKO9xMQJbbQP5_-jGV6Lhi-mJOk4gZ08/edit
56-
interface: upgrade
52+
refresh-v-three:
53+
interface: refresh
5754
mysql-router-peers:
5855
interface: mysql_router_peers
5956
resources:

poetry.lock

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

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ tenacity = "^9.1.2"
1414
jinja2 = "^3.1.6"
1515
poetry-core = "^2.1.3"
1616
requests = "^2.32.4"
17+
charm-refresh = "^3.1.0.2"
1718

1819
[tool.poetry.group.charm-libs.dependencies]
1920
# data_platform_libs/v0/data_interfaces.py
@@ -58,6 +59,14 @@ pyyaml = "^6.0.2"
5859
tenacity = "^9.1.2"
5960
allure-pytest = "^2.14.3"
6061
allure-pytest-default-results = "^0.1.3"
62+
tomli = "^2.2.1"
63+
tomli-w = "^1.2.0"
64+
65+
[tool.poetry.group.build-refresh-version]
66+
optional = true
67+
68+
[tool.poetry.group.build-refresh-version.dependencies]
69+
charm-refresh-build-version = "^0.4.0"
6170

6271
[tool.coverage.run]
6372
branch = true

refresh_versions.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# https://canonical-charm-refresh.readthedocs-hosted.com/latest/refresh-versions-toml/
2+
3+
charm_major = 1
4+
workload = "8.0.42"

0 commit comments

Comments
 (0)