Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Fixes tolerations not working into release/1.5.x #4360

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4315.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
helm: fix issue where the API Gateway GatewayClassConfig tolerations can not be parsed by the Helm chart.
```
3 changes: 2 additions & 1 deletion charts/consul/templates/gateway-resources-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ spec:
- {{- toYaml .Values.connectInject.apiGateway.managedGatewayClass.nodeSelector | nindent 14 -}}
{{- end }}
{{- if .Values.connectInject.apiGateway.managedGatewayClass.tolerations }}
- -tolerations={{ .Values.connectInject.apiGateway.managedGatewayClass.tolerations }}
- -tolerations
- {{- toYaml .Values.connectInject.apiGateway.managedGatewayClass.tolerations | nindent 14 -}}
{{- end }}
{{- if .Values.connectInject.apiGateway.managedGatewayClass.copyAnnotations.service }}
- -service-annotations
Expand Down
44 changes: 27 additions & 17 deletions charts/consul/test/unit/gateway-resources-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ target=templates/gateway-resources-job.yaml
--set 'connectInject.apiGateway.managedGatewayClass.deployment.minInstances=1' \
--set 'connectInject.apiGateway.managedGatewayClass.deployment.maxInstances=3' \
--set 'connectInject.apiGateway.managedGatewayClass.nodeSelector=foo: bar' \
--set 'connectInject.apiGateway.managedGatewayClass.tolerations=- key: bar' \
--set 'connectInject.apiGateway.managedGatewayClass.copyAnnotations.service.annotations=- bingo' \
--set 'connectInject.apiGateway.managedGatewayClass.serviceType=Foo' \
--set 'connectInject.apiGateway.managedGatewayClass.openshiftSCCName=hello' \
Expand All @@ -90,23 +89,11 @@ target=templates/gateway-resources-job.yaml
local actual=$(echo "$spec" | jq 'any(index("-service-type=Foo"))')
[ "${actual}" = "true" ]

local actual=$(echo "$spec" | jq '.[12]')
[ "${actual}" = "\"-node-selector\"" ]

local actual=$(echo "$spec" | jq '.[13]')
[ "${actual}" = "\"foo: bar\"" ]

local actual=$(echo "$spec" | jq '.[14] | ."-tolerations=- key"')
[ "${actual}" = "\"bar\"" ]

local actual=$(echo "$spec" | jq '.[15]')
[ "${actual}" = "\"-service-annotations\"" ]

local actual=$(echo "$spec" | jq '.[16]')
[ "${actual}" = "\"- bingo\"" ]
local actual=$(echo $spec | yq 'contains(["-node-selector", "foo: bar"])')
[ "${actual}" = "true" ]

local actual=$(echo "$spec" | jq '.[17]')
[ "${actual}" = "\"-service-type=Foo\"" ]
local actual=$(echo $spec | yq 'contains(["-service-annotations", "- bingo"])')
[ "${actual}" = "true" ]
}

@test "apiGateway/GatewayClassConfig: custom configuration openshift enabled" {
Expand Down Expand Up @@ -138,3 +125,26 @@ target=templates/gateway-resources-job.yaml
tee /dev/stderr)
[ "${actual}" = "{}" ]
}


#--------------------------------------------------------------------
# tolerations

@test "apiGateway/GatewayClassConfig: tolerations" {
cd `chart_dir`
local tolerations=$(helm template \
-s $target \
--set 'connectInject.apiGateway.managedGatewayClass.tolerations=- "operator": "Equal" \
"effect": "NoSchedule" \
"key": "node" \
"value": "clients" \
- "operator": "Equal" \
"effect": "NoSchedule" \
"key": "node2" \
"value": "clients2"' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].args' | tee /dev/stderr)

local actual=$(echo $tolerations | yq 'contains(["tolerations","- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node\" \n\"value\": \"clients\" \n- \"operator\": \"Equal\" \n\"effect\": \"NoSchedule\" \n\"key\": \"node2\" \n\"value\": \"clients2\"" ])')
[ "${actual}" = "true" ]
}
11 changes: 8 additions & 3 deletions control-plane/subcommand/gateway-resources/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,14 @@ func TestRun_flagValidation(t *testing.T) {
flagNodeSelector: `
foo: 1
bar: 2`,
flagTolerations: `
- value: foo
- value: bar`,
flagTolerations: `- "operator": "Equal"
"effect": "NoSchedule"
"key": "node"
"value": "clients"
- "operator": "Equal"
"effect": "NoSchedule"
"key": "node2"
"value": "clients2"`,
flagServiceAnnotations: `
- foo
- bar`,
Expand Down
Loading