-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail helm upgrades if partition name is updated.
- This does not cause the parition-init job from running or the agents from attempting to join the new partition, but the helm upgrade stays in a failed state until an upgrade is run with the partition name reverted.
- Loading branch information
Ashwin Venkatesh
committed
Sep 14, 2021
1 parent
8910fd3
commit 7bb77a2
Showing
3 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{- $serverEnabled := (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled)) -}} | ||
{{- if (and .Values.global.adminPartitions.enabled (not $serverEnabled)) }} | ||
# Immutable ConfigMap which saves the partition name. Attempting to update this configmap | ||
# with a new Admin Partition name will cause the helm upgrade to fail | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "consul.fullname" . }}-partition-configmap | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
app: {{ template "consul.name" . }} | ||
chart: {{ template "consul.chart" . }} | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
immutable: true | ||
data: | ||
partitionName: {{ .Values.global.adminPartitions.name }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bats | ||
|
||
load _helpers | ||
|
||
@test "partitionName/ConfigMap: disabled by default" { | ||
cd `chart_dir` | ||
assert_empty helm template \ | ||
-s templates/partition-init-role.yaml \ | ||
. | ||
} | ||
|
||
@test "partitionName/ConfigMap: enabled with global.adminPartitions.enabled=true and servers = false" { | ||
cd `chart_dir` | ||
local actual=$(helm template \ | ||
-s templates/partition-init-role.yaml \ | ||
--set 'global.adminPartitions.enabled=true' \ | ||
--set 'server.enabled=false' \ | ||
. | tee /dev/stderr | | ||
yq 'length > 0' | tee /dev/stderr) | ||
[ "${actual}" = "true" ] | ||
} | ||
|
||
@test "partitionName/ConfigMap: disabled with global.adminPartitions.enabled=true and servers = true" { | ||
cd `chart_dir` | ||
assert_empty helm template \ | ||
-s templates/partition-init-role.yaml \ | ||
--set 'global.adminPartitions.enabled=true' \ | ||
--set 'server.enabled=true' \ | ||
. | ||
} | ||
|
||
@test "partitionName/ConfigMap: disabled with global.adminPartitions.enabled=true and global.enabled = true" { | ||
cd `chart_dir` | ||
assert_empty helm template \ | ||
-s templates/partition-init-role.yaml \ | ||
--set 'global.adminPartitions.enabled=true' \ | ||
--set 'global.enabled=true' \ | ||
. | ||
} | ||
|
||
@test "partitionName/ConfigMap: disabled with global.adminPartitions.enabled=false" { | ||
cd `chart_dir` | ||
assert_empty helm template \ | ||
-s templates/partition-init-role.yaml \ | ||
--set 'global.adminPartitions.enabled=false' \ | ||
. | ||
} |