From 305209e869bd40040de1237ee98061349e425d32 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Thu, 17 Oct 2019 12:19:43 -0700 Subject: [PATCH 01/13] Automatically install periodic cleanup script on macOS and Linux --- hack/jenkins/cron/Darwin.crontab | 1 + .../cleanup-and-reboot_Darwin.sh} | 0 hack/jenkins/cron/cleanup-and-reboot_Linux.sh | 39 +++++++++++++++++++ hack/jenkins/linux_integration_tests_kvm.sh | 2 + hack/jenkins/linux_integration_tests_none.sh | 2 + .../linux_integration_tests_virtualbox.sh | 2 + .../jenkins/osx_integration_tests_hyperkit.sh | 3 ++ .../osx_integration_tests_virtualbox.sh | 3 ++ 8 files changed, 52 insertions(+) create mode 100644 hack/jenkins/cron/Darwin.crontab rename hack/jenkins/{osx_cleanup_and_reboot.sh => cron/cleanup-and-reboot_Darwin.sh} (100%) create mode 100755 hack/jenkins/cron/cleanup-and-reboot_Linux.sh diff --git a/hack/jenkins/cron/Darwin.crontab b/hack/jenkins/cron/Darwin.crontab new file mode 100644 index 0000000000..58dd2d5477 --- /dev/null +++ b/hack/jenkins/cron/Darwin.crontab @@ -0,0 +1 @@ +*/20 * * * * /Users/jenkins/cleanup-and-reboot.sh diff --git a/hack/jenkins/osx_cleanup_and_reboot.sh b/hack/jenkins/cron/cleanup-and-reboot_Darwin.sh similarity index 100% rename from hack/jenkins/osx_cleanup_and_reboot.sh rename to hack/jenkins/cron/cleanup-and-reboot_Darwin.sh diff --git a/hack/jenkins/cron/cleanup-and-reboot_Linux.sh b/hack/jenkins/cron/cleanup-and-reboot_Linux.sh new file mode 100755 index 0000000000..246b0e0bea --- /dev/null +++ b/hack/jenkins/cron/cleanup-and-reboot_Linux.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Periodically cleanup and reboot if no Jenkins subprocesses are running. +# +# Installation: +# install cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot + +function check_jenkins() { + jenkins_pid="$(pidof java)" + if [[ "${jenkins_pid}" = "" ]]; then + return + fi + pstree "${jenkins_pid}" \ + | grep -v java \ + && echo "jenkins is running at pid ${jenkins_pid} ..." \ + && exit 1 +} + +check_jenkins +logger "cleanup-and-reboot running - may shutdown in 60 seconds" +wall "cleanup-and-reboot running - may shutdown in 60 seconds" + +sleep 60 + +check_jenkins +logger "cleanup-and-reboot is happening!" + +# kill jenkins to avoid an incoming request +killall java + +# disable localkube, kubelet +systemctl list-unit-files --state=enabled \ + | grep kube \ + | awk '{ print $1 }' \ + | xargs systemctl disable + +# update and reboot +apt update -y \ + && apt upgrade -y \ + && reboot diff --git a/hack/jenkins/linux_integration_tests_kvm.sh b/hack/jenkins/linux_integration_tests_kvm.sh index 5af0e48b30..5137b76a02 100755 --- a/hack/jenkins/linux_integration_tests_kvm.sh +++ b/hack/jenkins/linux_integration_tests_kvm.sh @@ -30,5 +30,7 @@ VM_DRIVER="kvm2" JOB_NAME="KVM_Linux" PARALLEL_COUNT=4 +install cron/cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot + # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/linux_integration_tests_none.sh b/hack/jenkins/linux_integration_tests_none.sh index 6721d15e24..eb83215460 100755 --- a/hack/jenkins/linux_integration_tests_none.sh +++ b/hack/jenkins/linux_integration_tests_none.sh @@ -50,5 +50,7 @@ systemctl is-active --quiet kubelet \ && echo "stopping kubelet" \ && sudo systemctl stop kubelet +install cron/cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot + # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/linux_integration_tests_virtualbox.sh b/hack/jenkins/linux_integration_tests_virtualbox.sh index bd413c1586..a4b61833e1 100755 --- a/hack/jenkins/linux_integration_tests_virtualbox.sh +++ b/hack/jenkins/linux_integration_tests_virtualbox.sh @@ -30,5 +30,7 @@ VM_DRIVER="virtualbox" JOB_NAME="VirtualBox_Linux" PARALLEL_COUNT=4 +install cron/cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot + # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/osx_integration_tests_hyperkit.sh b/hack/jenkins/osx_integration_tests_hyperkit.sh index 7091d6512b..6c98564d60 100755 --- a/hack/jenkins/osx_integration_tests_hyperkit.sh +++ b/hack/jenkins/osx_integration_tests_hyperkit.sh @@ -33,5 +33,8 @@ EXTRA_ARGS="--bootstrapper=kubeadm" EXTRA_START_ARGS="" PARALLEL_COUNT=3 +install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh +crontab < cron/Darwin.crontab + # Download files and set permissions source common.sh diff --git a/hack/jenkins/osx_integration_tests_virtualbox.sh b/hack/jenkins/osx_integration_tests_virtualbox.sh index cb48a389ed..ad67abdcc8 100755 --- a/hack/jenkins/osx_integration_tests_virtualbox.sh +++ b/hack/jenkins/osx_integration_tests_virtualbox.sh @@ -31,5 +31,8 @@ JOB_NAME="VirtualBox_macOS" EXTRA_ARGS="--bootstrapper=kubeadm" PARALLEL_COUNT=3 +install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh +crontab < cron/Darwin.crontab + # Download files and set permissions source common.sh From c3e20bac5eba2a08deefb0b061532836aded81c8 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Thu, 17 Oct 2019 12:42:14 -0700 Subject: [PATCH 02/13] Add boilerplate --- hack/jenkins/cron/cleanup-and-reboot_Linux.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hack/jenkins/cron/cleanup-and-reboot_Linux.sh b/hack/jenkins/cron/cleanup-and-reboot_Linux.sh index 246b0e0bea..ebcbb1b8c7 100755 --- a/hack/jenkins/cron/cleanup-and-reboot_Linux.sh +++ b/hack/jenkins/cron/cleanup-and-reboot_Linux.sh @@ -1,4 +1,19 @@ #!/bin/bash + +# Copyright 2016 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # Periodically cleanup and reboot if no Jenkins subprocesses are running. # # Installation: From 0c7788532998b7f16fc0425331b612337cd106f7 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Thu, 17 Oct 2019 13:11:04 -0700 Subject: [PATCH 03/13] Add boilerplate --- hack/jenkins/cron/cleanup-and-reboot_Linux.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hack/jenkins/cron/cleanup-and-reboot_Linux.sh b/hack/jenkins/cron/cleanup-and-reboot_Linux.sh index ebcbb1b8c7..a039e62dd8 100755 --- a/hack/jenkins/cron/cleanup-and-reboot_Linux.sh +++ b/hack/jenkins/cron/cleanup-and-reboot_Linux.sh @@ -1,5 +1,19 @@ #!/bin/bash +# Copyright 2019 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Copyright 2016 The Kubernetes Authors All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); From 0ce8ab0524cf8fbfbc785063845cb351ff6ecbb6 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Thu, 17 Oct 2019 13:11:31 -0700 Subject: [PATCH 04/13] Add boilerplate --- hack/jenkins/cron/cleanup-and-reboot_Linux.sh | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/hack/jenkins/cron/cleanup-and-reboot_Linux.sh b/hack/jenkins/cron/cleanup-and-reboot_Linux.sh index a039e62dd8..dcf1283816 100755 --- a/hack/jenkins/cron/cleanup-and-reboot_Linux.sh +++ b/hack/jenkins/cron/cleanup-and-reboot_Linux.sh @@ -14,25 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Copyright 2016 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Periodically cleanup and reboot if no Jenkins subprocesses are running. -# -# Installation: -# install cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot - function check_jenkins() { jenkins_pid="$(pidof java)" if [[ "${jenkins_pid}" = "" ]]; then From fb6295823ff00a11a56d12bd9b4f36a7379d89cf Mon Sep 17 00:00:00 2001 From: tstromberg Date: Mon, 21 Oct 2019 11:37:32 -0700 Subject: [PATCH 05/13] rsync cron directory --- hack/jenkins/linux_integration_tests_kvm.sh | 1 + hack/jenkins/linux_integration_tests_none.sh | 1 + hack/jenkins/linux_integration_tests_virtualbox.sh | 1 + hack/jenkins/osx_integration_tests_hyperkit.sh | 1 + hack/jenkins/osx_integration_tests_virtualbox.sh | 1 + 5 files changed, 5 insertions(+) diff --git a/hack/jenkins/linux_integration_tests_kvm.sh b/hack/jenkins/linux_integration_tests_kvm.sh index 5137b76a02..d59b42a923 100755 --- a/hack/jenkins/linux_integration_tests_kvm.sh +++ b/hack/jenkins/linux_integration_tests_kvm.sh @@ -30,6 +30,7 @@ VM_DRIVER="kvm2" JOB_NAME="KVM_Linux" PARALLEL_COUNT=4 +mkdir cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron install cron/cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot # Download files and set permissions diff --git a/hack/jenkins/linux_integration_tests_none.sh b/hack/jenkins/linux_integration_tests_none.sh index eb83215460..34284bf507 100755 --- a/hack/jenkins/linux_integration_tests_none.sh +++ b/hack/jenkins/linux_integration_tests_none.sh @@ -50,6 +50,7 @@ systemctl is-active --quiet kubelet \ && echo "stopping kubelet" \ && sudo systemctl stop kubelet +mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron install cron/cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot # Download files and set permissions diff --git a/hack/jenkins/linux_integration_tests_virtualbox.sh b/hack/jenkins/linux_integration_tests_virtualbox.sh index a4b61833e1..259000aac5 100755 --- a/hack/jenkins/linux_integration_tests_virtualbox.sh +++ b/hack/jenkins/linux_integration_tests_virtualbox.sh @@ -30,6 +30,7 @@ VM_DRIVER="virtualbox" JOB_NAME="VirtualBox_Linux" PARALLEL_COUNT=4 +mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron install cron/cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot # Download files and set permissions diff --git a/hack/jenkins/osx_integration_tests_hyperkit.sh b/hack/jenkins/osx_integration_tests_hyperkit.sh index 6c98564d60..62a6a7b57e 100755 --- a/hack/jenkins/osx_integration_tests_hyperkit.sh +++ b/hack/jenkins/osx_integration_tests_hyperkit.sh @@ -33,6 +33,7 @@ EXTRA_ARGS="--bootstrapper=kubeadm" EXTRA_START_ARGS="" PARALLEL_COUNT=3 +mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh crontab < cron/Darwin.crontab diff --git a/hack/jenkins/osx_integration_tests_virtualbox.sh b/hack/jenkins/osx_integration_tests_virtualbox.sh index ad67abdcc8..44d2583ae9 100755 --- a/hack/jenkins/osx_integration_tests_virtualbox.sh +++ b/hack/jenkins/osx_integration_tests_virtualbox.sh @@ -31,6 +31,7 @@ JOB_NAME="VirtualBox_macOS" EXTRA_ARGS="--bootstrapper=kubeadm" PARALLEL_COUNT=3 +mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh crontab < cron/Darwin.crontab From f8f38f917b8bbc40711f447185f9e225e0ac7271 Mon Sep 17 00:00:00 2001 From: tstromberg Date: Tue, 29 Oct 2019 16:10:13 -0700 Subject: [PATCH 06/13] Fix issues with crontab installation --- hack/jenkins/cron/Darwin.crontab | 1 - hack/jenkins/linux_integration_tests_kvm.sh | 2 +- hack/jenkins/linux_integration_tests_none.sh | 4 ++-- hack/jenkins/linux_integration_tests_virtualbox.sh | 4 ++-- hack/jenkins/osx_integration_tests_hyperkit.sh | 3 ++- hack/jenkins/osx_integration_tests_virtualbox.sh | 3 ++- 6 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 hack/jenkins/cron/Darwin.crontab diff --git a/hack/jenkins/cron/Darwin.crontab b/hack/jenkins/cron/Darwin.crontab deleted file mode 100644 index 58dd2d5477..0000000000 --- a/hack/jenkins/cron/Darwin.crontab +++ /dev/null @@ -1 +0,0 @@ -*/20 * * * * /Users/jenkins/cleanup-and-reboot.sh diff --git a/hack/jenkins/linux_integration_tests_kvm.sh b/hack/jenkins/linux_integration_tests_kvm.sh index d59b42a923..d91c459cc3 100755 --- a/hack/jenkins/linux_integration_tests_kvm.sh +++ b/hack/jenkins/linux_integration_tests_kvm.sh @@ -31,7 +31,7 @@ JOB_NAME="KVM_Linux" PARALLEL_COUNT=4 mkdir cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cron/cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot +install cron/cleanup-and-reboot_Linux.sh /etc/cron.hourly/cleanup-and-reboot # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/linux_integration_tests_none.sh b/hack/jenkins/linux_integration_tests_none.sh index 34284bf507..d54246d2b2 100755 --- a/hack/jenkins/linux_integration_tests_none.sh +++ b/hack/jenkins/linux_integration_tests_none.sh @@ -50,8 +50,8 @@ systemctl is-active --quiet kubelet \ && echo "stopping kubelet" \ && sudo systemctl stop kubelet -mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cron/cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot +mkdir -p cron && gsutil -m rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron +install cron/cleanup-and-reboot_Linux.sh /etc/cron.hourly/cleanup-and-reboot # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/linux_integration_tests_virtualbox.sh b/hack/jenkins/linux_integration_tests_virtualbox.sh index 259000aac5..e1febe720f 100755 --- a/hack/jenkins/linux_integration_tests_virtualbox.sh +++ b/hack/jenkins/linux_integration_tests_virtualbox.sh @@ -30,8 +30,8 @@ VM_DRIVER="virtualbox" JOB_NAME="VirtualBox_Linux" PARALLEL_COUNT=4 -mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cron/cleanup-and-reboot.linux /etc/cron.hourly/cleanup-and-reboot +mkdir -p cron && gsutil -m rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron +install cleanup-and-reboot_Linux.sh /etc/cron.hourly/cleanup-and-reboot # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/osx_integration_tests_hyperkit.sh b/hack/jenkins/osx_integration_tests_hyperkit.sh index 62a6a7b57e..d4e8018eb6 100755 --- a/hack/jenkins/osx_integration_tests_hyperkit.sh +++ b/hack/jenkins/osx_integration_tests_hyperkit.sh @@ -35,7 +35,8 @@ PARALLEL_COUNT=3 mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh -crontab < cron/Darwin.crontab +echo "0 * * * * $HOME/cleanup-and-reboot.sh" | crontab +crontab -l # Download files and set permissions source common.sh diff --git a/hack/jenkins/osx_integration_tests_virtualbox.sh b/hack/jenkins/osx_integration_tests_virtualbox.sh index 44d2583ae9..8cbb5c964a 100755 --- a/hack/jenkins/osx_integration_tests_virtualbox.sh +++ b/hack/jenkins/osx_integration_tests_virtualbox.sh @@ -33,7 +33,8 @@ PARALLEL_COUNT=3 mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh -crontab < cron/Darwin.crontab +echo "0 * * * * $HOME/cleanup-and-reboot.sh" | crontab +crontab -l # Download files and set permissions source common.sh From 0b65bbf1d958448b00cc7b51f461afce9b9730c4 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 29 Oct 2019 21:33:39 -0700 Subject: [PATCH 07/13] Use underscores for script names, clear dhcpd leases --- ...up-and-reboot_Darwin.sh => cleanup_and_reboot_Darwin.sh} | 1 + ...anup-and-reboot_Linux.sh => cleanup_and_reboot_Linux.sh} | 6 +++--- hack/jenkins/linux_integration_tests_kvm.sh | 2 +- hack/jenkins/linux_integration_tests_none.sh | 2 +- hack/jenkins/linux_integration_tests_virtualbox.sh | 2 +- hack/jenkins/osx_integration_tests_hyperkit.sh | 2 +- hack/jenkins/osx_integration_tests_virtualbox.sh | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) rename hack/jenkins/cron/{cleanup-and-reboot_Darwin.sh => cleanup_and_reboot_Darwin.sh} (94%) rename hack/jenkins/cron/{cleanup-and-reboot_Linux.sh => cleanup_and_reboot_Linux.sh} (87%) diff --git a/hack/jenkins/cron/cleanup-and-reboot_Darwin.sh b/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh similarity index 94% rename from hack/jenkins/cron/cleanup-and-reboot_Darwin.sh rename to hack/jenkins/cron/cleanup_and_reboot_Darwin.sh index 503796c212..544070d313 100755 --- a/hack/jenkins/cron/cleanup-and-reboot_Darwin.sh +++ b/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh @@ -36,4 +36,5 @@ echo "doing it" killall java sudo rm -Rf ~jenkins/.minikube || echo "could not delete minikube" sudo rm -Rf ~/jenkins/minikube-integration/* || true +sudo rm /var/db/dhcpd_leases || echo "could not clear dhcpd leases" sudo reboot diff --git a/hack/jenkins/cron/cleanup-and-reboot_Linux.sh b/hack/jenkins/cron/cleanup_and_reboot_Linux.sh similarity index 87% rename from hack/jenkins/cron/cleanup-and-reboot_Linux.sh rename to hack/jenkins/cron/cleanup_and_reboot_Linux.sh index dcf1283816..eb2678288f 100755 --- a/hack/jenkins/cron/cleanup-and-reboot_Linux.sh +++ b/hack/jenkins/cron/cleanup_and_reboot_Linux.sh @@ -26,13 +26,13 @@ function check_jenkins() { } check_jenkins -logger "cleanup-and-reboot running - may shutdown in 60 seconds" -wall "cleanup-and-reboot running - may shutdown in 60 seconds" +logger "cleanup_and_reboot running - may shutdown in 60 seconds" +wall "cleanup_and_reboot running - may shutdown in 60 seconds" sleep 60 check_jenkins -logger "cleanup-and-reboot is happening!" +logger "cleanup_and_reboot is happening!" # kill jenkins to avoid an incoming request killall java diff --git a/hack/jenkins/linux_integration_tests_kvm.sh b/hack/jenkins/linux_integration_tests_kvm.sh index d91c459cc3..773eec2367 100755 --- a/hack/jenkins/linux_integration_tests_kvm.sh +++ b/hack/jenkins/linux_integration_tests_kvm.sh @@ -31,7 +31,7 @@ JOB_NAME="KVM_Linux" PARALLEL_COUNT=4 mkdir cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cron/cleanup-and-reboot_Linux.sh /etc/cron.hourly/cleanup-and-reboot +install cron/cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/linux_integration_tests_none.sh b/hack/jenkins/linux_integration_tests_none.sh index d54246d2b2..653ec6bcc0 100755 --- a/hack/jenkins/linux_integration_tests_none.sh +++ b/hack/jenkins/linux_integration_tests_none.sh @@ -51,7 +51,7 @@ systemctl is-active --quiet kubelet \ && sudo systemctl stop kubelet mkdir -p cron && gsutil -m rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cron/cleanup-and-reboot_Linux.sh /etc/cron.hourly/cleanup-and-reboot +install cron/cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/linux_integration_tests_virtualbox.sh b/hack/jenkins/linux_integration_tests_virtualbox.sh index e1febe720f..cf491076b5 100755 --- a/hack/jenkins/linux_integration_tests_virtualbox.sh +++ b/hack/jenkins/linux_integration_tests_virtualbox.sh @@ -31,7 +31,7 @@ JOB_NAME="VirtualBox_Linux" PARALLEL_COUNT=4 mkdir -p cron && gsutil -m rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cleanup-and-reboot_Linux.sh /etc/cron.hourly/cleanup-and-reboot +install cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/osx_integration_tests_hyperkit.sh b/hack/jenkins/osx_integration_tests_hyperkit.sh index d4e8018eb6..2561f4e9aa 100755 --- a/hack/jenkins/osx_integration_tests_hyperkit.sh +++ b/hack/jenkins/osx_integration_tests_hyperkit.sh @@ -35,7 +35,7 @@ PARALLEL_COUNT=3 mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh -echo "0 * * * * $HOME/cleanup-and-reboot.sh" | crontab +echo "*/30 * * * * $HOME/cleanup_and_reboot.sh" | crontab crontab -l # Download files and set permissions diff --git a/hack/jenkins/osx_integration_tests_virtualbox.sh b/hack/jenkins/osx_integration_tests_virtualbox.sh index 8cbb5c964a..2a5c1089ad 100755 --- a/hack/jenkins/osx_integration_tests_virtualbox.sh +++ b/hack/jenkins/osx_integration_tests_virtualbox.sh @@ -33,7 +33,7 @@ PARALLEL_COUNT=3 mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh -echo "0 * * * * $HOME/cleanup-and-reboot.sh" | crontab +echo "*/30 * * * * $HOME/cleanup_and_reboot.sh" | crontab crontab -l # Download files and set permissions From 9a8c26c2fe5dd48d4ede24686bfb4c4bf3bd31c3 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 29 Oct 2019 22:05:39 -0700 Subject: [PATCH 08/13] Call sudo to install cleanup script on Linux --- hack/jenkins/linux_integration_tests_kvm.sh | 2 +- hack/jenkins/linux_integration_tests_none.sh | 2 +- hack/jenkins/linux_integration_tests_virtualbox.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hack/jenkins/linux_integration_tests_kvm.sh b/hack/jenkins/linux_integration_tests_kvm.sh index 773eec2367..0a72f6b2aa 100755 --- a/hack/jenkins/linux_integration_tests_kvm.sh +++ b/hack/jenkins/linux_integration_tests_kvm.sh @@ -31,7 +31,7 @@ JOB_NAME="KVM_Linux" PARALLEL_COUNT=4 mkdir cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cron/cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot +sudo install cron/cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/linux_integration_tests_none.sh b/hack/jenkins/linux_integration_tests_none.sh index 653ec6bcc0..da2c3ed437 100755 --- a/hack/jenkins/linux_integration_tests_none.sh +++ b/hack/jenkins/linux_integration_tests_none.sh @@ -51,7 +51,7 @@ systemctl is-active --quiet kubelet \ && sudo systemctl stop kubelet mkdir -p cron && gsutil -m rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cron/cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot +sudo install cron/cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/linux_integration_tests_virtualbox.sh b/hack/jenkins/linux_integration_tests_virtualbox.sh index cf491076b5..03db115280 100755 --- a/hack/jenkins/linux_integration_tests_virtualbox.sh +++ b/hack/jenkins/linux_integration_tests_virtualbox.sh @@ -31,7 +31,7 @@ JOB_NAME="VirtualBox_Linux" PARALLEL_COUNT=4 mkdir -p cron && gsutil -m rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot +sudo install cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot # Download files and set permissions source ./common.sh From 323854239056eab6128f140ad1ed85a68ad5f737 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 29 Oct 2019 22:51:22 -0700 Subject: [PATCH 09/13] Fix awkward typo in macOS script --- hack/jenkins/cron/cleanup_and_reboot_Darwin.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh b/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh index 544070d313..f6dbb8169d 100755 --- a/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh +++ b/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh @@ -21,11 +21,11 @@ PATH=/usr/local/bin:/sbin:/usr/local/sbin:$PATH exit_if_jenkins() { jenkins=$(pgrep java) - if [[ "$jenkins" -- "" ]]; then + if [[ "${jenkins}" == "" ]]; then echo "no java, no jenkins" return 0 fi - pstree $jenkins | grep -v java && echo "jenkins is running..." && exit 1 + pstree "${jenkins}" | grep -v java && echo "jenkins is running..." && exit 1 } exit_if_jenkins From 52e965ecc01293d4a4cf34207710324277c0db34 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 30 Oct 2019 06:30:10 -0700 Subject: [PATCH 10/13] Unify behavior between macOS and Linux cleanup scripts --- .../jenkins/cron/cleanup_and_reboot_Darwin.sh | 32 +++++++++++-------- hack/jenkins/cron/cleanup_and_reboot_Linux.sh | 15 ++++----- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh b/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh index f6dbb8169d..74f72314a4 100755 --- a/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh +++ b/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh @@ -19,22 +19,28 @@ set -uf -o pipefail PATH=/usr/local/bin:/sbin:/usr/local/sbin:$PATH -exit_if_jenkins() { - jenkins=$(pgrep java) - if [[ "${jenkins}" == "" ]]; then - echo "no java, no jenkins" - return 0 +# cleanup shared between Linux and macOS +function check_jenkins() { + jenkins_pid="$(pidof java)" + if [[ "${jenkins_pid}" = "" ]]; then + return fi - pstree "${jenkins}" | grep -v java && echo "jenkins is running..." && exit 1 + pstree "${jenkins_pid}" \ + | egrep -i 'bash|integration|e2e|minikube' \ + && echo "tests are is running on pid ${jenkins_pid} ..." \ + && exit 1 } -exit_if_jenkins -echo "waiting to see if any jobs are coming in..." -sleep 15 -exit_if_jenkins -echo "doing it" +check_jenkins +logger "cleanup_and_reboot running - may shutdown in 60 seconds" +wall "cleanup_and_reboot running - may shutdown in 60 seconds" +sleep 10 +check_jenkins +logger "cleanup_and_reboot is happening!" + +# kill jenkins to avoid an incoming request killall java -sudo rm -Rf ~jenkins/.minikube || echo "could not delete minikube" -sudo rm -Rf ~/jenkins/minikube-integration/* || true + +# macOS specific cleanup sudo rm /var/db/dhcpd_leases || echo "could not clear dhcpd leases" sudo reboot diff --git a/hack/jenkins/cron/cleanup_and_reboot_Linux.sh b/hack/jenkins/cron/cleanup_and_reboot_Linux.sh index eb2678288f..f75eeb3c18 100755 --- a/hack/jenkins/cron/cleanup_and_reboot_Linux.sh +++ b/hack/jenkins/cron/cleanup_and_reboot_Linux.sh @@ -14,29 +14,30 @@ # See the License for the specific language governing permissions and # limitations under the License. +# cleanup shared between Linux and macOS function check_jenkins() { jenkins_pid="$(pidof java)" if [[ "${jenkins_pid}" = "" ]]; then return fi pstree "${jenkins_pid}" \ - | grep -v java \ - && echo "jenkins is running at pid ${jenkins_pid} ..." \ + | egrep -i 'bash|integration|e2e|minikube' \ + && echo "tests are is running on pid ${jenkins_pid} ..." \ && exit 1 } check_jenkins logger "cleanup_and_reboot running - may shutdown in 60 seconds" wall "cleanup_and_reboot running - may shutdown in 60 seconds" - -sleep 60 - +sleep 10 check_jenkins logger "cleanup_and_reboot is happening!" # kill jenkins to avoid an incoming request killall java +# Linux-specific cleanup + # disable localkube, kubelet systemctl list-unit-files --state=enabled \ | grep kube \ @@ -44,6 +45,4 @@ systemctl list-unit-files --state=enabled \ | xargs systemctl disable # update and reboot -apt update -y \ - && apt upgrade -y \ - && reboot +apt update -y && apt upgrade -y && reboot From 96a96a044ae52bb6f5251b8f486e6ea0d31bd86e Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 30 Oct 2019 06:30:59 -0700 Subject: [PATCH 11/13] Add software update to macOS for behavioral parity --- hack/jenkins/cron/cleanup_and_reboot_Darwin.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh b/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh index 74f72314a4..595b5334d6 100755 --- a/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh +++ b/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh @@ -43,4 +43,5 @@ killall java # macOS specific cleanup sudo rm /var/db/dhcpd_leases || echo "could not clear dhcpd leases" +sudo softwareupdate -i -a -R sudo reboot From bf69daf93bc10f07a9f0f2268df496109042cad3 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 30 Oct 2019 06:34:40 -0700 Subject: [PATCH 12/13] Invoke wall in the older BSD style for macOS compat --- hack/jenkins/cron/cleanup_and_reboot_Darwin.sh | 2 +- hack/jenkins/cron/cleanup_and_reboot_Linux.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh b/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh index 595b5334d6..993d6c82f6 100755 --- a/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh +++ b/hack/jenkins/cron/cleanup_and_reboot_Darwin.sh @@ -33,7 +33,7 @@ function check_jenkins() { check_jenkins logger "cleanup_and_reboot running - may shutdown in 60 seconds" -wall "cleanup_and_reboot running - may shutdown in 60 seconds" +echo "cleanup_and_reboot running - may shutdown in 60 seconds" | wall sleep 10 check_jenkins logger "cleanup_and_reboot is happening!" diff --git a/hack/jenkins/cron/cleanup_and_reboot_Linux.sh b/hack/jenkins/cron/cleanup_and_reboot_Linux.sh index f75eeb3c18..b2e067c58e 100755 --- a/hack/jenkins/cron/cleanup_and_reboot_Linux.sh +++ b/hack/jenkins/cron/cleanup_and_reboot_Linux.sh @@ -28,7 +28,7 @@ function check_jenkins() { check_jenkins logger "cleanup_and_reboot running - may shutdown in 60 seconds" -wall "cleanup_and_reboot running - may shutdown in 60 seconds" +echo "cleanup_and_reboot running - may shutdown in 60 seconds" | wall sleep 10 check_jenkins logger "cleanup_and_reboot is happening!" From 07ab2751ec9f29c87312c5785fc7bbd92c1d0a15 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 30 Oct 2019 09:33:43 -0700 Subject: [PATCH 13/13] Output warning rather than fail if install does not work --- hack/jenkins/linux_integration_tests_kvm.sh | 4 ++-- hack/jenkins/linux_integration_tests_none.sh | 4 ++-- hack/jenkins/osx_integration_tests_hyperkit.sh | 4 ++-- hack/jenkins/osx_integration_tests_virtualbox.sh | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hack/jenkins/linux_integration_tests_kvm.sh b/hack/jenkins/linux_integration_tests_kvm.sh index 0a72f6b2aa..3c5240045b 100755 --- a/hack/jenkins/linux_integration_tests_kvm.sh +++ b/hack/jenkins/linux_integration_tests_kvm.sh @@ -30,8 +30,8 @@ VM_DRIVER="kvm2" JOB_NAME="KVM_Linux" PARALLEL_COUNT=4 -mkdir cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -sudo install cron/cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot +mkdir cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron || echo "FAILED TO GET CRON FILES" +sudo install cron/cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot || echo "FAILED TO INSTALL CLEANUP" # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/linux_integration_tests_none.sh b/hack/jenkins/linux_integration_tests_none.sh index da2c3ed437..80da5c0f0a 100755 --- a/hack/jenkins/linux_integration_tests_none.sh +++ b/hack/jenkins/linux_integration_tests_none.sh @@ -50,8 +50,8 @@ systemctl is-active --quiet kubelet \ && echo "stopping kubelet" \ && sudo systemctl stop kubelet -mkdir -p cron && gsutil -m rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -sudo install cron/cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot +mkdir -p cron && gsutil -m rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron || echo "FAILED TO GET CRON FILES" +sudo install cron/cleanup_and_reboot_Linux.sh /etc/cron.hourly/cleanup_and_reboot || echo "FAILED TO INSTALL CLEANUP" # Download files and set permissions source ./common.sh diff --git a/hack/jenkins/osx_integration_tests_hyperkit.sh b/hack/jenkins/osx_integration_tests_hyperkit.sh index 2561f4e9aa..d6d509b3e5 100755 --- a/hack/jenkins/osx_integration_tests_hyperkit.sh +++ b/hack/jenkins/osx_integration_tests_hyperkit.sh @@ -33,8 +33,8 @@ EXTRA_ARGS="--bootstrapper=kubeadm" EXTRA_START_ARGS="" PARALLEL_COUNT=3 -mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh +mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron || echo "FAILED TO GET CRON FILES" +install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh || echo "FAILED TO INSTALL CLEANUP" echo "*/30 * * * * $HOME/cleanup_and_reboot.sh" | crontab crontab -l diff --git a/hack/jenkins/osx_integration_tests_virtualbox.sh b/hack/jenkins/osx_integration_tests_virtualbox.sh index 2a5c1089ad..ac7435ee1d 100755 --- a/hack/jenkins/osx_integration_tests_virtualbox.sh +++ b/hack/jenkins/osx_integration_tests_virtualbox.sh @@ -31,8 +31,8 @@ JOB_NAME="VirtualBox_macOS" EXTRA_ARGS="--bootstrapper=kubeadm" PARALLEL_COUNT=3 -mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron -install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh +mkdir -p cron && gsutil -qm rsync "gs://minikube-builds/${MINIKUBE_LOCATION}/cron" cron || echo "FAILED TO GET CRON FILES" +install cron/cleanup_and_reboot_Darwin.sh $HOME/cleanup_and_reboot.sh || echo "FAILED TO GET INSTALL CLEANUP" echo "*/30 * * * * $HOME/cleanup_and_reboot.sh" | crontab crontab -l