From 615352e736d3af721b1ce37108275f8932cf1786 Mon Sep 17 00:00:00 2001 From: georgievaVMW <90902341+georgievaVMW@users.noreply.github.com> Date: Wed, 17 Nov 2021 12:14:24 +0200 Subject: [PATCH] Changes to OS and package updates as a follow-up on the discussion in PR #169 (#209) * Changes done as a follow-up on the discussion in PR #169 Removed the step that changes the OS auto-upgrading settings. Changed the step that installs outside packages such as kubeadm, kubelet and so on to disable auto-upgrading after installing the package. Updated the tests which are checking for number of completed steps with the new values. * Removed apt-mark unhold from the undo step as it is not needed and added comments. --- agent/installer/installer_test.go | 4 ++-- agent/installer/internal/algo/algo_test.go | 2 +- agent/installer/internal/algo/apt_step.go | 7 +++++-- agent/installer/internal/algo/installer.go | 2 -- agent/installer/internal/algo/mock_ubuntu_with_error.go | 4 ---- agent/installer/internal/algo/ubuntu20_4K8s1_22.go | 8 -------- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/agent/installer/installer_test.go b/agent/installer/installer_test.go index ae348266b..b68afeeee 100644 --- a/agent/installer/installer_test.go +++ b/agent/installer/installer_test.go @@ -55,7 +55,7 @@ var _ = Describe("Byohost Installer Tests", func() { i := NewPreviewInstaller(os, &ob) err := i.Install(k8s, testTag) Expect(err).ShouldNot((HaveOccurred())) - Expect(ob.LogCalledCnt).Should(Equal(24)) + Expect(ob.LogCalledCnt).Should(Equal(22)) } { @@ -63,7 +63,7 @@ var _ = Describe("Byohost Installer Tests", func() { i := NewPreviewInstaller(os, &ob) err := i.Uninstall(k8s, testTag) Expect(err).ShouldNot((HaveOccurred())) - Expect(ob.LogCalledCnt).Should(Equal(24)) + Expect(ob.LogCalledCnt).Should(Equal(22)) } } } diff --git a/agent/installer/internal/algo/algo_test.go b/agent/installer/internal/algo/algo_test.go index 2953b1367..0b4fb67b7 100644 --- a/agent/installer/internal/algo/algo_test.go +++ b/agent/installer/internal/algo/algo_test.go @@ -15,7 +15,7 @@ var _ = Describe("Installer Algo Tests", func() { ) const ( - stepsNum = 24 + stepsNum = 22 ) BeforeEach(func() { diff --git a/agent/installer/internal/algo/apt_step.go b/agent/installer/internal/algo/apt_step.go index 66b439181..2cd13b963 100755 --- a/agent/installer/internal/algo/apt_step.go +++ b/agent/installer/internal/algo/apt_step.go @@ -26,8 +26,11 @@ func NewAptStepEx(k *BaseK8sInstaller, aptPkg string, optional bool) Step { if optional { condCmd = fmt.Sprintf("if [ -f %s ]; then %%s; fi", pkgAbsolutePath) } - - doCmd := fmt.Sprintf("dpkg --install '%s'", pkgAbsolutePath) + // apt-mark hold will prevent the package from being automatically installed, upgraded or removed. + // This is done to prevent unexpected upgrades of the external package in order to ensure that + // the working environment is stable. If needed the package can be manually upgraded. + doCmd := fmt.Sprintf("dpkg --install '%s' && apt-mark hold %s", pkgAbsolutePath, pkgName) + // When uninstalling the package the hold is removed automatically. undoCmd := fmt.Sprintf("dpkg --purge %s", pkgName) return &ShellStep{ diff --git a/agent/installer/internal/algo/installer.go b/agent/installer/internal/algo/installer.go index 2d9a2d885..e35a6fc21 100755 --- a/agent/installer/internal/algo/installer.go +++ b/agent/installer/internal/algo/installer.go @@ -47,7 +47,6 @@ type K8sStepProvider interface { // os state related steps swapStep(*BaseK8sInstaller) Step firewallStep(*BaseK8sInstaller) Step - unattendedUpdStep(*BaseK8sInstaller) Step kernelModsLoadStep(*BaseK8sInstaller) Step // packages related steps @@ -132,7 +131,6 @@ func (b *BaseK8sInstaller) getSteps(bki *BaseK8sInstaller) []Step { var steps = []Step{ b.swapStep(bki), b.firewallStep(bki), - b.unattendedUpdStep(bki), b.kernelModsLoadStep(bki), b.osWideCfgUpdateStep(bki), b.criToolsStep(bki), diff --git a/agent/installer/internal/algo/mock_ubuntu_with_error.go b/agent/installer/internal/algo/mock_ubuntu_with_error.go index 7311b0e95..f60a28568 100644 --- a/agent/installer/internal/algo/mock_ubuntu_with_error.go +++ b/agent/installer/internal/algo/mock_ubuntu_with_error.go @@ -56,10 +56,6 @@ func (u *MockUbuntuWithError) kernelModsLoadStep(bki *BaseK8sInstaller) Step { return u.getEmptyStep("KERNEL MODULES", bki) } -func (u *MockUbuntuWithError) unattendedUpdStep(bki *BaseK8sInstaller) Step { - return u.getEmptyStep("AUTO OS UPGRADES", bki) -} - func (u *MockUbuntuWithError) osWideCfgUpdateStep(bki *BaseK8sInstaller) Step { return u.getEmptyStep("OS CONFIGURATION", bki) } diff --git a/agent/installer/internal/algo/ubuntu20_4K8s1_22.go b/agent/installer/internal/algo/ubuntu20_4K8s1_22.go index 2206c7cb0..b1d6d20cc 100755 --- a/agent/installer/internal/algo/ubuntu20_4K8s1_22.go +++ b/agent/installer/internal/algo/ubuntu20_4K8s1_22.go @@ -36,14 +36,6 @@ func (u *Ubuntu20_4K8s1_22) kernelModsLoadStep(bki *BaseK8sInstaller) Step { UndoCmd: "modprobe -r overlay && modprobe -r br_netfilter"} } -func (u *Ubuntu20_4K8s1_22) unattendedUpdStep(bki *BaseK8sInstaller) Step { - return &ShellStep{ - BaseK8sInstaller: bki, - Desc: "AUTO OS UPGRADES", - DoCmd: "sed -ri 's/1/0/g' /etc/apt/apt.conf.d/20auto-upgrades", - UndoCmd: "sed -ri 's/0/1/g' /etc/apt/apt.conf.d/20auto-upgrades"} -} - func (u *Ubuntu20_4K8s1_22) osWideCfgUpdateStep(bki *BaseK8sInstaller) Step { confAbsolutePath := filepath.Join(bki.BundlePath, "conf.tar")