Skip to content

Commit

Permalink
Changes to OS and package updates as a follow-up on the discussion in…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
georgievaVMW authored Nov 17, 2021
1 parent 29c5b06 commit 615352e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 19 deletions.
4 changes: 2 additions & 2 deletions agent/installer/installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ 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))
}

{
ob := algo.OutputBuilderCounter{}
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))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion agent/installer/internal/algo/algo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var _ = Describe("Installer Algo Tests", func() {
)

const (
stepsNum = 24
stepsNum = 22
)

BeforeEach(func() {
Expand Down
7 changes: 5 additions & 2 deletions agent/installer/internal/algo/apt_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 0 additions & 2 deletions agent/installer/internal/algo/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 0 additions & 4 deletions agent/installer/internal/algo/mock_ubuntu_with_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 0 additions & 8 deletions agent/installer/internal/algo/ubuntu20_4K8s1_22.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 615352e

Please sign in to comment.