mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-16 14:40:28 +00:00
fix reset not updating EFI files (#600)
This commit is contained in:
2082
internal/webui/public/package-lock.json
generated
2082
internal/webui/public/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -199,6 +199,16 @@ func (r ResetAction) Run() (err error) {
|
||||
// Create extra dirs in rootfs as afterwards this will be impossible due to RO system
|
||||
createExtraDirsInRootfs(r.cfg, r.spec.ExtraDirsRootfs, r.spec.Active.MountPoint)
|
||||
|
||||
// Mount EFI partition before installing grub as under EFI this copies stuff in there
|
||||
if r.spec.Efi {
|
||||
err = e.MountPartition(r.spec.Partitions.EFI)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cleanup.Push(func() error { return e.UnmountPartition(r.spec.Partitions.EFI) })
|
||||
}
|
||||
//TODO: does bios needs to be mounted here?
|
||||
|
||||
// install grub
|
||||
grub := utils.NewGrub(r.cfg)
|
||||
err = grub.Install(
|
||||
|
@@ -20,18 +20,15 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
||||
"github.com/kairos-io/kairos-agent/v2/pkg/action"
|
||||
agentConfig "github.com/kairos-io/kairos-agent/v2/pkg/config"
|
||||
"github.com/kairos-io/kairos-agent/v2/pkg/constants"
|
||||
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
|
||||
"github.com/kairos-io/kairos-agent/v2/pkg/utils"
|
||||
"github.com/kairos-io/kairos-agent/v2/pkg/utils/fs"
|
||||
v1mock "github.com/kairos-io/kairos-agent/v2/tests/mocks"
|
||||
ghwMock "github.com/kairos-io/kairos-sdk/ghw/mocks"
|
||||
sdkTypes "github.com/kairos-io/kairos-sdk/types"
|
||||
"path/filepath"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
@@ -159,20 +156,30 @@ var _ = Describe("Reset action tests", func() {
|
||||
_, err = fs.Create(grubCfg)
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
runner.SideEffect = func(cmd string, args ...string) ([]byte, error) {
|
||||
regexCmd := regexp.MustCompile(cmdFail)
|
||||
if cmdFail != "" && regexCmd.MatchString(cmd) {
|
||||
return []byte{}, errors.New("command failed")
|
||||
}
|
||||
return []byte{}, nil
|
||||
// create the fake grub dir with modules, it needs an arch in the path
|
||||
Expect(fsutils.MkdirAll(fs, filepath.Join(spec.Active.MountPoint, constants.Archx86), constants.DirPerm)).ToNot(HaveOccurred())
|
||||
for _, mod := range constants.GetGrubModules() {
|
||||
_, err = fs.Create(filepath.Join(spec.Active.MountPoint, constants.Archx86, mod))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
|
||||
// create fake shim
|
||||
Expect(fsutils.MkdirAll(fs, filepath.Join(spec.Active.MountPoint, "/usr/share/efi/x86_64/"), constants.DirPerm)).ToNot(HaveOccurred())
|
||||
_, err = fs.Create(filepath.Join(spec.Active.MountPoint, "/usr/share/efi/x86_64/", "shim.efi"))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// create fake grub
|
||||
Expect(fsutils.MkdirAll(fs, filepath.Join(spec.Active.MountPoint, "/usr/share/efi/x86_64/"), constants.DirPerm)).ToNot(HaveOccurred())
|
||||
_, err = fs.Create(filepath.Join(spec.Active.MountPoint, "/usr/share/efi/x86_64/", "grub.efi"))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
reset = action.NewResetAction(config, spec)
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
ghwTest.Clean()
|
||||
})
|
||||
|
||||
Describe("With EFI", func() {
|
||||
It("Successfully resets on non-squashfs recovery", func() {
|
||||
Expect(reset.Run()).To(BeNil())
|
||||
})
|
||||
@@ -196,11 +203,6 @@ var _ = Describe("Reset action tests", func() {
|
||||
Expect(reset.Run()).To(BeNil())
|
||||
|
||||
})
|
||||
It("Fails installing grub", func() {
|
||||
cmdFail = utils.FindCommand("grub2-install", []string{"grub2-install", "grub-install"})
|
||||
Expect(reset.Run()).NotTo(BeNil())
|
||||
Expect(runner.IncludesCmds([][]string{{cmdFail}}))
|
||||
})
|
||||
It("Fails formatting state partition", func() {
|
||||
cmdFail = "mkfs.ext4"
|
||||
Expect(reset.Run()).NotTo(BeNil())
|
||||
@@ -232,3 +234,4 @@ var _ = Describe("Reset action tests", func() {
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user