2 # Copyright © 2019 Amdocs, Bell Canada
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 Calculate the maximum number of zk server down in order to guarantee ZK quorum.
19 For guaranteeing ZK quorum we need half of the server + 1 up.
21 div in go template cast return an int64
22 so we need to know if it is an even number or an odd.
23 For this we are doing (n/2)*2=n?
24 if true it is even else it is even
26 {{- define "zk.maxUnavailable" -}}
27 {{- $halfReplica := div .Values.replicaCount 2 -}}
28 {{/* divide by 2 and multiply by 2 in order to know if it is an even number*/}}
29 {{if eq (mul $halfReplica 2) (int .Values.replicaCount) }}
30 {{- toYaml (sub $halfReplica 1) -}}
32 {{- toYaml $halfReplica -}}