Skip to content

Commit

Permalink
fix: do not restart addon-manager if a reboot is required (Azure#3721)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cecile Robert-Michon authored and penggu committed Oct 28, 2020
1 parent 17f719e commit 78e4d4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
7 changes: 5 additions & 2 deletions parts/k8s/cloud-init/artifacts/cse_config.sh
Expand Up @@ -392,8 +392,7 @@ ensureAddons() {
retrycmd 120 5 30 $KUBECTL get podsecuritypolicy privileged restricted || exit {{GetCSEErrorCode "ERR_ADDONS_START_FAIL"}}
rm -Rf ${ADDONS_DIR}/init
{{- end}}
wait_for_file 1200 1 $ADDON_MANAGER_SPEC || exit {{GetCSEErrorCode "ERR_FILE_WATCH_TIMEOUT"}}
sed -i "s|${ADDONS_DIR}/init|${ADDONS_DIR}|g" $ADDON_MANAGER_SPEC || exit {{GetCSEErrorCode "ERR_ADDONS_START_FAIL"}}
replaceAddonsInit
{{/* Force re-load all addons because we have changed the source location for addon specs */}}
retrycmd 10 5 30 ${KUBECTL} delete pods -l app=kube-addon-manager -n kube-system || \
retrycmd 120 5 30 ${KUBECTL} delete pods -l app=kube-addon-manager -n kube-system --force --grace-period 0 || \
Expand All @@ -420,6 +419,10 @@ ensureAddons() {
done
{{end}}
}
replaceAddonsInit() {
wait_for_file 1200 1 $ADDON_MANAGER_SPEC || exit {{GetCSEErrorCode "ERR_FILE_WATCH_TIMEOUT"}}
sed -i "s|${ADDONS_DIR}/init|${ADDONS_DIR}|g" $ADDON_MANAGER_SPEC || exit {{GetCSEErrorCode "ERR_ADDONS_START_FAIL"}}
}
ensureLabelNodes() {
LABEL_NODES_SCRIPT_FILE=/opt/azure/containers/label-nodes.sh
wait_for_file 1200 1 $LABEL_NODES_SCRIPT_FILE || exit {{GetCSEErrorCode "ERR_FILE_WATCH_TIMEOUT"}}
Expand Down
6 changes: 5 additions & 1 deletion parts/k8s/cloud-init/artifacts/cse_main.sh
Expand Up @@ -226,7 +226,11 @@ if [[ -n ${MASTER_NODE} ]]; then
{{if IsAzurePolicyAddonEnabled}}
time_metric "EnsureLabelExclusionForAzurePolicyAddon" ensureLabelExclusionForAzurePolicyAddon
{{end}}
time_metric "EnsureAddons" ensureAddons
if [ -f /var/run/reboot-required ]; then
time_metric "ReplaceAddonsInit" replaceAddonsInit
else
time_metric "EnsureAddons" ensureAddons
fi
fi
time_metric "EnsureJournal" ensureJournal

Expand Down
13 changes: 10 additions & 3 deletions pkg/engine/templates_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 78e4d4e

Please sign in to comment.