Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
fix: mark walinux for hold in cloud-init (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrancis committed Mar 16, 2019
1 parent 7330764 commit 21ff4bd
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
12 changes: 10 additions & 2 deletions parts/k8s/kubernetesagentcustomdata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ write_files:
RemainAfterExit=yes
ExecStart=/usr/local/bin/health-monitor.sh container-runtime
- path: /etc/apt/preferences
permissions: "0644"
owner: root
content: |
Package: walinuxagent
Pin: version 2.2.32.2
Pin-Priority: 550
{{if .KubernetesConfig.RequiresDocker}}
{{if not .IsCoreOS}}
- path: /etc/systemd/system/docker.service.d/clear_mount_propagation_flags.conf
Expand Down Expand Up @@ -306,5 +314,5 @@ coreos:
runcmd:
- set -x
- . /opt/azure/containers/provision_source.sh
- {{GetKubernetesAgentPreprovisionYaml .}}
{{end}}
- aptmarkWALinuxAgent hold{{GetKubernetesAgentPreprovisionYaml .}}
{{end}}
16 changes: 0 additions & 16 deletions parts/k8s/kubernetesconfigs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ PRIVATE_IP=$(hostname -I | cut -d' ' -f1)
ETCD_PEER_URL="https://${PRIVATE_IP}:2380"
ETCD_CLIENT_URL="https://${PRIVATE_IP}:2379"

holdWALinuxAgent() {
retrycmd_if_failure 120 5 25 apt-mark $1 walinuxagent || \
if [[ "$1" == "hold" ]]; then
exit $ERR_HOLD_WALINUXAGENT
elif [[ "$1" == "unhold" ]]; then
exit $ERR_RELEASE_HOLD_WALINUXAGENT
fi
}

systemctlEnableAndStart() {
systemctl_restart 100 5 30 $1
RESTART_STATUS=$?
Expand Down Expand Up @@ -123,13 +114,6 @@ ensureRPC() {
systemctlEnableAndStart rpc-statd || exit $ERR_SYSTEMCTL_START_FAIL
}

runAptDaily() {
wait_for_apt_locks
/usr/lib/apt/apt.systemd.daily
wait_for_apt_locks
holdWALinuxAgent "unhold"
}

generateAggregatedAPICerts() {
AGGREGATED_API_CERTS_SETUP_FILE=/etc/kubernetes/generate-proxy-certs.sh
wait_for_file 1200 1 $AGGREGATED_API_CERTS_SETUP_FILE || exit $ERR_FILE_WATCH_TIMEOUT
Expand Down
9 changes: 3 additions & 6 deletions parts/k8s/kubernetescustomscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ else
FULL_INSTALL_REQUIRED=true
fi

if [[ $OS == $UBUNTU_OS_NAME ]]; then
holdWALinuxAgent "hold"
fi

if [[ ! -z "${MASTER_NODE}" ]] && [[ -z "${COSMOS_URI}" ]]; then
installEtcd
fi
Expand Down Expand Up @@ -179,10 +175,11 @@ if $REBOOTREQUIRED; then
echo 'reboot required, rebooting node in 1 minute'
/bin/bash -c "shutdown -r 1 &"
if [[ $OS == $UBUNTU_OS_NAME ]]; then
holdWALinuxAgent "unhold"
aptmarkWALinuxAgent unhold &
fi
else
if [[ $OS == $UBUNTU_OS_NAME ]]; then
runAptDaily &
/usr/lib/apt/apt.systemd.daily &
aptmarkWALinuxAgent unhold &
fi
fi
11 changes: 10 additions & 1 deletion parts/k8s/kubernetesmastercustomdata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ write_files:
RemainAfterExit=yes
ExecStart=/usr/local/bin/health-monitor.sh container-runtime
- path: /etc/apt/preferences
permissions: "0644"
owner: root
content: |
Package: walinuxagent
Pin: version 2.2.32.2
Pin-Priority: 550
{{if .OrchestratorProfile.KubernetesConfig.RequiresDocker}}
{{if not .MasterProfile.IsCoreOS}}
- path: /etc/systemd/system/docker.service.d/clear_mount_propagation_flags.conf
Expand Down Expand Up @@ -504,5 +512,6 @@ coreos:
{{else}}
runcmd:
- set -x
- {{GetKubernetesMasterPreprovisionYaml}}
- . /opt/azure/containers/provision_source.sh
- aptmarkWALinuxAgent hold{{GetKubernetesMasterPreprovisionYaml}}
{{end}}
10 changes: 10 additions & 0 deletions parts/k8s/kubernetesprovisionsource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ NVIDIA_DOCKER_VERSION=2.0.3
DOCKER_VERSION=1.13.1-1
NVIDIA_CONTAINER_RUNTIME_VERSION=2.0.0

aptmarkWALinuxAgent() {
wait_for_apt_locks
retrycmd_if_failure 120 5 25 apt-mark $1 walinuxagent || \
if [[ "$1" == "hold" ]]; then
exit $ERR_HOLD_WALINUXAGENT
elif [[ "$1" == "unhold" ]]; then
exit $ERR_RELEASE_HOLD_WALINUXAGENT
fi
}

retrycmd_if_failure() {
retries=$1; wait_sleep=$2; timeout=$3; shift && shift && shift
for i in $(seq 1 $retries); do
Expand Down

0 comments on commit 21ff4bd

Please sign in to comment.