Skip to content

Commit 6517ee6

Browse files
Add in-place upgrades & rollbacks with charm-refresh (#866)
Uses `charm-refresh` Python package: https://github.com/canonical/charm-refresh Only supports refreshing to/from postgresql charm code with refresh v3
1 parent 3f81441 commit 6517ee6

31 files changed

+757
-1961
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
@@ -16,4 +16,4 @@ on:
1616
jobs:
1717
check-pr:
1818
name: Check pull request
19-
uses: canonical/data-platform-workflows/.github/workflows/check_charm_pr.yaml@v31.0.1
19+
uses: canonical/data-platform-workflows/.github/workflows/check_charm_pr.yaml@v32.0.0

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
jobs:
2828
lint:
2929
name: Lint
30-
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v31.0.1
30+
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v32.0.0
3131

3232
unit-test:
3333
name: Unit test charm
@@ -49,7 +49,7 @@ jobs:
4949

5050
build:
5151
name: Build charm
52-
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v31.0.1
52+
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v32.0.0
5353

5454
integration-test:
5555
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: '16'
3131
from-risk: ${{ inputs.from-risk }}

.github/workflows/release.yaml

Lines changed: 14 additions & 3 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:
@@ -16,8 +16,18 @@ on:
1616
- '.github/workflows/sync_docs.yaml'
1717

1818
jobs:
19+
tag:
20+
name: Create charm refresh compatibility version git tag
21+
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
22+
with:
23+
track: '16'
24+
permissions:
25+
contents: write # Needed to create git tag
26+
1927
ci-tests:
2028
name: Tests
29+
needs:
30+
- tag
2131
uses: ./.github/workflows/ci.yaml
2232
secrets: inherit
2333
permissions:
@@ -26,10 +36,11 @@ jobs:
2636
release:
2737
name: Release charm
2838
needs:
39+
- tag
2940
- ci-tests
30-
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v31.0.1
41+
uses: canonical/data-platform-workflows/.github/workflows/release_charm_edge.yaml@v32.0.0
3142
with:
32-
channel: ${{ github.ref_name }}
43+
track: ${{ needs.tag.outputs.track }}
3344
artifact-prefix: ${{ needs.ci-tests.outputs.artifact-prefix }}
3445
secrets:
3546
charmhub-token: ${{ secrets.CHARMHUB_TOKEN }}

.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,izmalk
1616
permissions:

actions.yaml

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,61 @@ get-primary:
2222
description: Get the unit which is the primary/leader in the replication.
2323
list-backups:
2424
description: Lists backups in s3 storage.
25-
pre-upgrade-check:
26-
description: Run necessary pre-upgrade checks and preparations before executing a charm refresh.
25+
pre-refresh-check:
26+
description: Check if charm is ready to refresh
27+
additionalProperties: false
28+
force-refresh-start:
29+
description: |
30+
Potential of data loss and downtime
31+
32+
Force refresh of first unit
33+
34+
Must run with at least one of the parameters `=false`
35+
params:
36+
check-compatibility:
37+
type: boolean
38+
default: true
39+
description: |
40+
Potential of data loss and downtime
41+
42+
If `false`, force refresh if new version of PostgreSQL and/or charm is not compatible with previous version
43+
run-pre-refresh-checks:
44+
type: boolean
45+
default: true
46+
description: |
47+
Potential of data loss and downtime
48+
49+
If `false`, force refresh if app is unhealthy or not ready to refresh (and unit status shows "Pre-refresh check failed")
50+
check-workload-container:
51+
type: boolean
52+
default: true
53+
description: |
54+
Potential of data loss and downtime during and after refresh
55+
56+
If `false`, allow refresh to PostgreSQL container version that has not been validated to work with the charm revision
57+
additionalProperties: false
58+
resume-refresh:
59+
description: |
60+
Refresh next unit(s) (after you have manually verified that refreshed units are healthy)
61+
62+
If the `pause_after_unit_refresh` config is set to `all`, this action will refresh the next unit.
63+
64+
If `pause_after_unit_refresh` is set to `first`, this action will refresh all remaining units.
65+
Exception: if automatic health checks fail after a unit has refreshed, the refresh will pause.
66+
67+
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`.
68+
params:
69+
check-health-of-refreshed-units:
70+
type: boolean
71+
default: true
72+
description: |
73+
Potential of data loss and downtime
74+
75+
If `false`, force refresh (of next unit) if 1 or more refreshed units are unhealthy
76+
77+
Warning: if first unit to refresh is unhealthy, consider running `force-refresh-start` action on that unit instead of using this parameter.
78+
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.
79+
additionalProperties: false
2780
promote-to-primary:
2881
description: Promotes the cluster of choice to a primary cluster. Must be ran against the leader unit when promoting a cluster
2982
or against the unit to be promoted within the cluster.

charmcraft.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,21 @@ parts:
8484
files:
8585
plugin: dump
8686
source: .
87+
after:
88+
- poetry-deps # Ensure poetry is installed
89+
build-packages:
90+
- git
91+
override-build: |
92+
# Set `charm_version` in refresh_versions.toml from git tag
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
97+
98+
craftctl default
8799
stage:
88100
- LICENSE
101+
- refresh_versions.toml
89102
- scripts
90103
- templates
91104
libpq:

config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@ options:
383383
Allowed values are: from 0 to 1.80E+308.
384384
type: float
385385
default: 0.1
386+
pause_after_unit_refresh:
387+
description: |
388+
Wait for manual confirmation to resume refresh after these units refresh
389+
Allowed values: "all", "first", "none"
390+
type: string
391+
default: first
386392
plugin_address_standardizer_data_us_enable:
387393
default: false
388394
type: boolean

0 commit comments

Comments
 (0)