From a71428fc0c7763583a40a5fd7f46625c66bc0263 Mon Sep 17 00:00:00 2001 From: Patryk Matuszak Date: Thu, 18 Jul 2024 15:32:36 +0200 Subject: [PATCH] Add service to cleanup stale kubelet files on boot --- packaging/rpm/microshift.spec | 7 +++++++ .../tuned/microshift-cleanup-kubelet.service | 15 +++++++++++++++ scripts/microshift-cleanup-data.sh | 1 + 3 files changed, 23 insertions(+) create mode 100644 packaging/tuned/microshift-cleanup-kubelet.service diff --git a/packaging/rpm/microshift.spec b/packaging/rpm/microshift.spec index ec3bbf8b08d..fa4b54c196b 100644 --- a/packaging/rpm/microshift.spec +++ b/packaging/rpm/microshift.spec @@ -345,6 +345,9 @@ cat assets/optional/multus/kustomization.x86_64.yaml >> %{buildroot}/%{_prefix}/ mkdir -p -m755 %{buildroot}%{_datadir}/microshift/release install -p -m644 assets/optional/multus/release-multus-{x86_64,aarch64}.json %{buildroot}%{_datadir}/microshift/release/ +# cleanup kubelet +install -p -m644 packaging/tuned/microshift-cleanup-kubelet.service %{buildroot}%{_unitdir}/microshift-cleanup-kubelet.service + %pre networking getent group hugetlbfs >/dev/null || groupadd -r hugetlbfs @@ -409,6 +412,7 @@ fi %{_bindir}/microshift-cleanup-data %{_bindir}/microshift-sos-report %{_unitdir}/microshift.service +%{_unitdir}/microshift-cleanup-kubelet.service %{_sysconfdir}/crio/crio.conf.d/00-crio-crun.conf %{_sysconfdir}/crio/crio.conf.d/10-microshift.conf %{_datadir}/microshift/spec/config-openapi-spec.json @@ -478,6 +482,9 @@ fi # Use Git command to generate the log and replace the VERSION string # LANG=C git log --date="format:%a %b %d %Y" --pretty="tformat:* %cd %an <%ae> VERSION%n- %s%n" packaging/rpm/microshift.spec %changelog +* Thu Jul 18 2024 Pablo Acevedo Montserrat 4.17.0 +- Add service to cleanup stale kubelet files on boot + * Mon Jul 08 2024 Pablo Acevedo Montserrat 4.17.0 - Add NM configuration file diff --git a/packaging/tuned/microshift-cleanup-kubelet.service b/packaging/tuned/microshift-cleanup-kubelet.service new file mode 100644 index 00000000000..970bb40bef7 --- /dev/null +++ b/packaging/tuned/microshift-cleanup-kubelet.service @@ -0,0 +1,15 @@ +# There are systems with multiple NUMA node that can change reported memory after rebooting +# causing kubelet's Memory Manager to block startup. +# To work around this, this unit will delete stale files on boot. +# Borrowed from: https://github.com/openshift/machine-config-operator/pull/4124 +[Unit] +Description=Delete Kubelet CPU and Memory managers state on boot +Before=microshift.service + +[Service] +Type=oneshot +ExecStart=/bin/rm -f /var/lib/kubelet/cpu_manager_state +ExecStart=/bin/rm -f /var/lib/kubelet/memory_manager_state + +[Install] +WantedBy=multi-user.target diff --git a/scripts/microshift-cleanup-data.sh b/scripts/microshift-cleanup-data.sh index 521750ef398..f6aaae56812 100755 --- a/scripts/microshift-cleanup-data.sh +++ b/scripts/microshift-cleanup-data.sh @@ -114,6 +114,7 @@ function clean_data() { if ${FULL_CLEAN} ; then echo Removing MicroShift configuration rm -rf /var/lib/microshift + rm -rf /var/lib/kubelet elif ${CERT_CLEAN} ; then echo Removing MicroShift certificates rm -rf /var/lib/microshift/certs