Skip to content

Commit 3c6f749

Browse files
committed
docs: Update migration contribution
1 parent 64bf62c commit 3c6f749

1 file changed

Lines changed: 48 additions & 17 deletions

File tree

migration/README.md

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,63 @@ This directory contains the upgrade and migration steps for each major and minor
1010
Notice to developers on writing migration steps:
1111

1212
- Migration steps:
13-
- are written per minor version and placed in a subdirectory of the migration directory with the name `vX.Y/`,
14-
- are written to be idempotent and usable no matter which patch version you are upgrading from and to,
15-
- are documented in this document to be able to run them manually,
16-
- are divided into prepare and apply steps:
17-
- Prepare steps:
18-
- are placed in the `prepare/` directory,
19-
- may **only** modify the configuration of the environment,
20-
- may **not** modify the state of the environment,
21-
- steps are run in order of their names use two digit prefixes.
22-
- Apply steps:
23-
- are placed in the `apply/` directory,
24-
- may **only** modify the state of the environment,
25-
- may **not** modify the configuration of the environment,
26-
- are run in order of their names use two digit prefixes,
27-
- are run with the argument `execute` on upgrade and should return 1 on failure and 2 on successful internal rollback,
28-
- are rerun with the argument `rollback` on execute failure and should return 1 on failure.
13+
- are written per major and minor version and placed in a subdirectory of the migration directory with the name `main/`, during release this is promoted to the next release series `vX.Y/`,
14+
- are written to be idempotent and usable no matter which patch version you are upgrading from and to,
15+
- are documented in `main/README.md` to be able to run them manually,
16+
- are divided into prepare and apply steps:
17+
- Prepare steps:
18+
- are placed in the `prepare/` directory,
19+
- may **only** modify the configuration of the environment,
20+
- may **not** modify the state of the environment,
21+
- steps are run in order of their names using two digit prefixes.
22+
- Apply steps:
23+
- are placed in the `apply/` directory,
24+
- may **only** modify the state of the environment,
25+
- may **not** modify the configuration of the environment,
26+
- are run in order of their names using two digit prefixes,
27+
- are run with the argument `execute` on upgrade and should return 1 on failure and 2 on successful internal rollback,
28+
- are rerun with the argument `rollback` on execute failure and should return 1 on failure.
2929

3030
For prepare the init step is given.
31-
For apply the bootstrap and the apply steps are given, it is expected that releases upgraded in custom steps are excluded from the apply step.
31+
For apply the apply step is given, it is expected that releases upgraded in custom steps are excluded from the apply step.
32+
33+
> [tip]
34+
> This can be done by adding label expression of releases into the `skipped*` arrays of the `80-apply.sh` snippet:
35+
>
36+
> ```diff
37+
> --- a/migration/main/apply/80-apply.sh
38+
> +++ b/migration/main/apply/80-apply.sh
39+
> @@ -9,12 +9,15 @@ source "${ROOT}/scripts/migration/lib.sh"
40+
> # Example: "app!=something"
41+
> declare -a skipped
42+
> skipped=(
43+
> + "app!=something"
44+
> )
45+
> declare -a skipped_sc
46+
> skipped_sc=(
47+
> + "app!=something"
48+
> )
49+
> declare -a skipped_wc
50+
> skipped_wc=(
51+
> + "app!=something"
52+
> )
53+
>
54+
> run() {
55+
> ```
56+
>
57+
> During runtime these are `AND`:ed together.
3258
3359
Upgrades of components that are dependent on each other should be done within the same snippet to easily manage the upgrade to a working state and to be able to rollback to a working state.
3460
3561
Steps should use the `scripts/migration/lib.sh` which will provide helper functions, see the file for available helper functions.
3662
This script expects the `ROOT` environment variable to be set pointing to the root of the repository.
3763
As with all scripts in this repository `CK8S_CONFIG_PATH` is expected to be set.
3864
65+
> [!important]
66+
> Since the migration snippets should be idempotent, and usable from and to any patch version, it is important that they only perform actions when needed, especially in the case of destructive actions!
67+
>
68+
> Example: if a major upgrade of a component requires that another component is temporarily removed, then it should **only** remove the component if there is a major upgrade in the first place, if there is a minor upgrade then it should be applied without removing the component.
69+
3970
## Preparing migration steps for releases
4071
4172
When releasing new major or minor versions of Welkin Apps the current upgrade and migration directory should be promoted to the one for the release.

0 commit comments

Comments
 (0)