Skip to content

Commit 2c1e8e6

Browse files
Add refresh v3 implementation (#241)
Uses `charm-refresh` Python package: https://github.com/canonical/charm-refresh --------- Co-authored-by: Sinclert Pérez <[email protected]>
1 parent 9571b53 commit 2c1e8e6

36 files changed

+871
-1023
lines changed

.github/workflows/approve_renovate_pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ on:
1010
jobs:
1111
approve-pr:
1212
name: Approve Renovate pull request
13-
uses: canonical/data-platform-workflows/.github/workflows/approve_renovate_pr.yaml@v31.0.1
13+
uses: canonical/data-platform-workflows/.github/workflows/approve_renovate_pr.yaml@v32.0.0
1414
permissions:
1515
pull-requests: write # Needed to approve PR

.github/workflows/check_pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ on:
1515
jobs:
1616
check-pr:
1717
name: Check pull request
18-
uses: canonical/data-platform-workflows/.github/workflows/check_charm_pr.yaml@v31.0.1
18+
uses: canonical/data-platform-workflows/.github/workflows/check_charm_pr.yaml@v32.0.0

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555

5656
build:
5757
name: Build charm
58-
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v31.0.1
58+
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v32.0.0
5959

6060
integration-test:
6161
name: Integration test charm

.github/workflows/promote.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ on:
2525
jobs:
2626
promote:
2727
name: Promote charm
28-
uses: canonical/data-platform-workflows/.github/workflows/_promote_charm.yaml@v31.0.1
28+
uses: canonical/data-platform-workflows/.github/workflows/_promote_charm.yaml@v32.0.0
2929
with:
3030
track: 'dpe'
3131
from-risk: ${{ inputs.from-risk }}

.github/workflows/release.yaml

Lines changed: 15 additions & 4 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,8 +13,18 @@ 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: 'dpe'
21+
permissions:
22+
contents: write # Needed to create git tag
23+
1624
ci-tests:
1725
name: Tests
26+
needs:
27+
- tag
1828
uses: ./.github/workflows/ci.yaml
1929
secrets: inherit
2030
permissions:
@@ -23,12 +33,13 @@ jobs:
2333
release:
2434
name: Release charm
2535
needs:
36+
- tag
2637
- ci-tests
27-
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v31.0.1
38+
uses: canonical/data-platform-workflows/.github/workflows/release_charm_edge.yaml@v32.0.0
2839
with:
29-
channel: dpe/edge
40+
track: ${{ needs.tag.outputs.track }}
3041
artifact-prefix: ${{ needs.ci-tests.outputs.artifact-prefix }}
3142
secrets:
3243
charmhub-token: ${{ secrets.CHARMHUB_TOKEN }}
3344
permissions:
34-
contents: write # Needed to create GitHub release
45+
contents: write # Needed to create git tags

.github/workflows/sync_docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
sync-docs:
1212
name: Sync docs from Discourse
13-
uses: canonical/data-platform-workflows/.github/workflows/sync_docs.yaml@v31.0.1
13+
uses: canonical/data-platform-workflows/.github/workflows/sync_docs.yaml@v32.0.0
1414
with:
1515
reviewers: a-velasco
1616
permissions:

actions.yaml

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +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).
6-
7-
force-upgrade:
4+
pre-refresh-check:
5+
description: Check if charm is ready to refresh
6+
additionalProperties: false
7+
force-refresh-start:
88
description: |
9-
Potential of *data loss* and *downtime*
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`
14+
params:
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:
23+
type: boolean
24+
default: true
25+
description: |
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
1034
11-
Force upgrade of this unit.
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.
1245
13-
Use to
14-
- force incompatible upgrade and/or
15-
- continue upgrade if 1+ upgraded units have non-active status
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
1659

1760
set-tls-private-key:
1861
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
@@ -83,18 +83,20 @@ parts:
8383
files:
8484
plugin: dump
8585
source: .
86+
after:
87+
- poetry-deps # Ensure poetry is installed
8688
build-packages:
8789
- git
8890
override-build: |
89-
# Workaround to add unique identifier (git hash) to charm version while specification
90-
# DA053 - Charm versioning
91-
# (https://docs.google.com/document/d/1Jv1jhWLl8ejK3iJn7Q3VbCIM9GIhp8926bgXpdtx-Sg/edit?pli=1)
92-
# is pending review.
93-
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}")'
91+
# Set `charm_version` in refresh_versions.toml from git tag
92+
# Create venv in `..` so that git working tree is not dirty
93+
python3 -m venv ../refresh-version-venv
94+
source ../refresh-version-venv/bin/activate
95+
poetry install --only build-refresh-version
96+
write-charm-version
9497
9598
craftctl default
9699
stage:
97100
- LICENSE
98-
- charm_version
99-
- workload_version
101+
- refresh_versions.toml
100102
- templates

config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
# See LICENSE file for licensing details.
33

44
options:
5-
65
vip:
76
description: |
87
Virtual IP to use to front mysql router units. Used only in case of external node connection.
98
type: string
9+
pause_after_unit_refresh:
10+
description: |
11+
Wait for manual confirmation to resume refresh after these units refresh
12+
13+
Allowed values: "all", "first", "none"
14+
type: string
15+
default: first

0 commit comments

Comments
 (0)