Skip to content

Commit a1dea02

Browse files
syn2mas: make sure we cant migrate twice with the deployment markers
1 parent e4f78e1 commit a1dea02

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

charts/matrix-stack/source/matrixAuthenticationService.yaml.j2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ privateKeys:
4747
## The migration process must follow the following steps:
4848
## 1. Set `matrixAuthenticationService.enabled: true` and `matrixAuthenticationService.syn2mas.enable: true`, run the helm upgrade command, check the result of the pre-upgrade hook job
4949
## 2. Set `matrixAuthenticationService.syn2mas.dryRun`: false, run the helm upgrade command, check the result of the pre-upgrade hook job
50-
## 3. To disable the job scaling-down Synapse in future helm-upgrades, set `matrixAuthenticationService.syn2mas.enabled: false`
50+
## 3. Set `matrixAuthenticationService.syn2mas.enabled: false` to disable syn2mas and allow running `helm upgrade` again.
5151
##
5252
## If `deploymentMarkers` are enabled, following the steps above will cause the following `MATRIX_STACK_MSC3861` marker transitions :
5353
## 1. Stay on `legacy_auth`
5454
## 2. `legacy_auth` -> `syn2mas_migrated`
5555
## 3. `syn2mas_migrated` -> `delegated_auth`
56-
## The marker will effectively prevent downgrading from `syn2mas_migrated`/`delegated_auth` to `legacy_auth`
56+
## The marker will effectively prevent :
57+
## - Running syn2mas migration again after it has run successfully and is in `syn2mas_migrated` state
58+
## - Downgrading from `syn2mas_migrated`/`delegated_auth` to `legacy_auth`
5759
syn2mas:
5860
enabled: false
5961

charts/matrix-stack/templates/deployment-markers/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ app.kubernetes.io/version: {{ include "element-io.ess-library.labels.makeSafe" $
6262
$root.Values.matrixAuthenticationService.enabled
6363
$root.Values.matrixAuthenticationService.syn2mas.enabled
6464
(not $root.Values.matrixAuthenticationService.syn2mas.dryRun) }}
65-
- {{ (printf "%s-markers" $root.Release.Name) }}:MATRIX_STACK_MSC3861:syn2mas_migrated:legacy_auth;syn2mas_migrated
65+
- {{ (printf "%s-markers" $root.Release.Name) }}:MATRIX_STACK_MSC3861:syn2mas_migrated:legacy_auth
6666
{{- end }}
6767

6868
{{- /* We allow deploying of Synapse with Matrix Authentication Service, only

charts/matrix-stack/values.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,13 +1732,15 @@ matrixAuthenticationService:
17321732
## The migration process must follow the following steps:
17331733
## 1. Set `matrixAuthenticationService.enabled: true` and `matrixAuthenticationService.syn2mas.enable: true`, run the helm upgrade command, check the result of the pre-upgrade hook job
17341734
## 2. Set `matrixAuthenticationService.syn2mas.dryRun`: false, run the helm upgrade command, check the result of the pre-upgrade hook job
1735-
## 3. To disable the job scaling-down Synapse in future helm-upgrades, set `matrixAuthenticationService.syn2mas.enabled: false`
1735+
## 3. Set `matrixAuthenticationService.syn2mas.enabled: false` to disable syn2mas and allow running `helm upgrade` again.
17361736
##
17371737
## If `deploymentMarkers` are enabled, following the steps above will cause the following `MATRIX_STACK_MSC3861` marker transitions :
17381738
## 1. Stay on `legacy_auth`
17391739
## 2. `legacy_auth` -> `syn2mas_migrated`
17401740
## 3. `syn2mas_migrated` -> `delegated_auth`
1741-
## The marker will effectively prevent downgrading from `syn2mas_migrated`/`delegated_auth` to `legacy_auth`
1741+
## The marker will effectively prevent :
1742+
## - Running syn2mas migration again after it has run successfully and is in `syn2mas_migrated` state
1743+
## - Downgrading from `syn2mas_migrated`/`delegated_auth` to `legacy_auth`
17421744
syn2mas:
17431745
enabled: false
17441746

tests/integration/test_syn2mas.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ async def test_run_syn2mas_upgrade(
6262
# Syn2Mas is running in migrate mode, so the state must have changed
6363
assert await get_deployment_marker(kube_client, generated_data, "MATRIX_STACK_MSC3861") == "syn2mas_migrated"
6464

65+
# Assert we cant run syn2mas again
66+
revision, error = await deploy_with_values_patch(generated_data, helm_client, {}, timeout="15s")
67+
assert error is not None
68+
assert revision.status == pyhelm3.ReleaseRevisionStatus.FAILED
69+
6570
# Auth metadata endpoint should be reachable
6671
response = await aiohttp_get_json(
6772
f"https://synapse.{generated_data.server_name}/_matrix/client/unstable/org.matrix.msc2965/auth_metadata",

0 commit comments

Comments
 (0)