Skip to content

Commit

Permalink
create-federation-secret job runs only when server.updatePartition is…
Browse files Browse the repository at this point in the history
… 0 (#1512)

* create-federation-secret job runs only
when server.updatePartition is 0

* I added a test to check createFederationSecret/Job doesn't run when  updatepartition != 0

Co-authored-by: David Yu <dyu@hashicorp.com>
  • Loading branch information
20sr20 and david-yu committed Sep 26, 2022
1 parent b89e654 commit 25b3b99
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ BUG FIXES:
* Control plane
* Use global ACL auth method to provision ACL tokens for API Gateway in secondary datacenter [[GH-1481](https://github.com/hashicorp/consul-k8s/pull/1481)]
* Helm:
* Fixes a typo in the templating of `global.connectInject.disruptionBudget.maxUnavailable`. [[GH-1530](https://github.com/hashicorp/consul-k8s/pull/1530)].
* Only create Federation Secret Job when server.updatePartition is 0 [[GH-1512](https://github.com/hashicorp/consul-k8s/pull/1512)]
* Fixes a typo in the templating of `global.connectInject.disruptionBudget.maxUnavailable`. [[GH-1530](https://github.com/hashicorp/consul-k8s/pull/1530)]

IMPROVEMENTS:
* Helm:
Expand Down
2 changes: 2 additions & 0 deletions charts/consul/templates/create-federation-secret-job.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- if .Values.global.federation.createFederationSecret }}
{{- if not .Values.global.federation.enabled }}{{ fail "global.federation.enabled must be true when global.federation.createFederationSecret is true" }}{{ end }}
{{- if and (not .Values.global.acls.createReplicationToken) .Values.global.acls.manageSystemACLs }}{{ fail "global.acls.createReplicationToken must be true when global.acls.manageSystemACLs is true because the federation secret must include the replication token" }}{{ end }}
{{- if eq (int .Values.server.updatePartition) 0 }}
apiVersion: batch/v1
kind: Job
metadata:
Expand Down Expand Up @@ -157,3 +158,4 @@ spec:
memory: "50Mi"
cpu: "50m"
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/consul/test/unit/create-federation-secret-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ load _helpers
[[ "$output" =~ "global.acls.createReplicationToken must be true when global.acls.manageSystemACLs is true because the federation secret must include the replication token" ]]
}

@test "createFederationSecret/Job: disabled by updatepartition != 0" {
cd `chart_dir`
assert_empty helm template \
-s templates/create-federation-secret-job.yaml \
--set 'global.federation.enabled=true' \
--set 'global.federation.createFederationSecret=true' \
--set 'global.acls.createReplicationToken=true' \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.tls.enabled=true' \
--set 'meshGateway.enabled=true' \
--set 'connectInject.enabled=true' \
--set 'server.updatePartition=1' \
.
}

@test "createFederationSecret/Job: mounts auto-created ca secrets by default" {
cd `chart_dir`
local volumes=$(helm template \
Expand Down

0 comments on commit 25b3b99

Please sign in to comment.