Skip to content

Commit 55d6c91

Browse files
committed
fix(foundationdb): refuse a render that would move the release line
Migration 60 carries cluster.version over to version, but platform migrations run only on the variants that enable them. On any other the new chart ignored cluster.version and rendered the v7.3 default, so a 7.4 cluster was downgraded and a 7.1 one moved onto a line nothing had upgraded it to. The render now fails when a stored cluster.version names another release line than version selects, and says how to proceed, so the release stays on the revision it runs until someone picks the line. Where the migration ran the two agree and nothing changes. Assisted-by: LLM Signed-off-by: Andrei Kvapil <[email protected]>
1 parent eb6388d commit 55d6c91

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

‎packages/apps/foundationdb/templates/_versions.tpl‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,25 @@
1010
{{- end }}
1111
{{- index $versionMap $version }}
1212
{{- end }}
13+
14+
{{/* cluster.version is no longer read, but a release that still carries one
15+
runs that version today. Migration 59 carries it over to version where
16+
the platform runs migrations; nothing does on a variant that runs none,
17+
and there a new render would move the cluster to another release line
18+
without a word: down from 7.4, or off 7.1, which the operator no longer
19+
manages. Refusing the render keeps such a release on the revision it runs
20+
until someone picks the line. A patch-level difference inside the same
21+
line is left alone. */}}
22+
{{- define "foundationdb.checkLegacyVersion" }}
23+
{{- $cluster := .Values.cluster }}
24+
{{- if kindIs "map" $cluster }}
25+
{{- $legacy := get $cluster "version" }}
26+
{{- if and (not (kindIs "invalid" $legacy)) (ne (toString $legacy) "") }}
27+
{{- $line := regexFind "^[0-9]+\\.[0-9]+" (toString $legacy) }}
28+
{{- $version := .Values.version | toString }}
29+
{{- if ne $line (trimPrefix "v" $version) }}
30+
{{- printf `cluster.version %s is no longer read, and it is on a different release line than version %s. Set version to the line the cluster runs, upgrading the cluster first if that line is no longer offered, or remove cluster.version to move the cluster to %s.` (toString $legacy) $version (include "foundationdb.versionMap" .) | fail }}
31+
{{- end }}
32+
{{- end }}
33+
{{- end }}
34+
{{- end }}

‎packages/apps/foundationdb/templates/cluster.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{- $clusterDomain := index .Values._cluster "cluster-domain" | default "cozy.local" }}
2+
{{- include "foundationdb.checkLegacyVersion" . }}
23
---
34
apiVersion: apps.foundationdb.org/v1beta2
45
kind: FoundationDBCluster

‎packages/apps/foundationdb/tests/versions_test.yaml‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,37 @@ tests:
3333
- failedTemplate:
3434
errorMessage: "FoundationDB version <nil> is not supported, allowed versions are [v7.3 v7.4]"
3535

36-
- it: ignores a leftover cluster.version
36+
- it: renders a leftover cluster.version on the line version selects
3737
set:
3838
cluster:
3939
version: "7.3.69"
4040
asserts:
4141
- equal:
4242
path: spec.version
4343
value: "7.3.63"
44+
45+
- it: refuses a leftover cluster.version on another line than version
46+
set:
47+
cluster:
48+
version: "7.4.2"
49+
asserts:
50+
- failedTemplate:
51+
errorMessage: "cluster.version 7.4.2 is no longer read, and it is on a different release line than version v7.3. Set version to the line the cluster runs, upgrading the cluster first if that line is no longer offered, or remove cluster.version to move the cluster to 7.3.63."
52+
53+
- it: refuses a leftover cluster.version on a line the chart no longer offers
54+
set:
55+
cluster:
56+
version: "7.1.67"
57+
asserts:
58+
- failedTemplate:
59+
errorMessage: "cluster.version 7.1.67 is no longer read, and it is on a different release line than version v7.3. Set version to the line the cluster runs, upgrading the cluster first if that line is no longer offered, or remove cluster.version to move the cluster to 7.3.63."
60+
61+
- it: renders once version picks the line cluster.version is on
62+
set:
63+
version: v7.4
64+
cluster:
65+
version: "7.4.2"
66+
asserts:
67+
- equal:
68+
path: spec.version
69+
value: "7.4.1"

0 commit comments

Comments
 (0)