File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
cluster/addons/addon-manager Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -210,13 +210,15 @@ function is_leader() {
210
210
# Disabling because "${KUBECTL_OPTS}" needs to allow for expansion here
211
211
KUBE_CONTROLLER_MANAGER_LEADER=$( ${KUBECTL} ${KUBECTL_OPTS} -n kube-system get ep kube-controller-manager \
212
212
-o go-template=$' {{index .metadata.annotations "control-plane.alpha.kubernetes.io/leader"}}' \
213
- | sed ' s/^.*"holderIdentity":"\([^"]*\)".*/\1/' | awk -F ' _ ' ' {print $1} ' )
213
+ | sed ' s/^.*"holderIdentity":"\([^"]*\)".*/\1/' )
214
214
# If there was any problem with getting the leader election results, var will
215
215
# be empty. Since it's better to have multiple addon managers than no addon
216
216
# managers at all, we're going to assume that we're the leader in such case.
217
217
log INFO " Leader is $KUBE_CONTROLLER_MANAGER_LEADER "
218
- [[ " $KUBE_CONTROLLER_MANAGER_LEADER " == " " ||
219
- " $HOSTNAME " == " $KUBE_CONTROLLER_MANAGER_LEADER " ]]
218
+ # KUBE_CONTROLLER_MANAGER_LEADER value is in the form "${HOSTNAME}_*"
219
+ # Here we verify that the value is either empty or is in the expected form for the leader
220
+ KUBE_CONTROLLER_MANAGER_LEADER=" ${KUBE_CONTROLLER_MANAGER_LEADER## ${HOSTNAME} _* } "
221
+ [[ " $KUBE_CONTROLLER_MANAGER_LEADER " == " " ]]
220
222
}
221
223
222
224
# The business logic for whether a given object should be created
You can’t perform that action at this time.
0 commit comments