Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the fix #2033

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/elemental/elemental.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,8 @@ func DeployRecoverySystem(cfg types.Config, img *types.Image, bootDir string) er
"initrd": initrd,
} {
// if kernel/initrd is actually named "vmlinuz"/"initrd" we just skip the symlink part.
if kernel == name || initrd == name {
if filepath.Base(kernel) == name || filepath.Base(initrd) == name {
cfg.Logger.Debugf("File already exists, skipping: %s", name)
continue
}

Expand Down
44 changes: 44 additions & 0 deletions pkg/elemental/elemental_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package elemental_test
import (
"errors"
"fmt"
iofs "io/fs"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -1027,6 +1028,49 @@ var _ = Describe("Elemental", Label("elemental"), func() {
}})).To(BeNil())
})
})
Describe("DeployRecoverySystem", Label("recovery"), func() {
BeforeEach(func() {
extractor.SideEffect = func(_, destination, platform string, _ bool) (string, error) {
Expect(destination).To(Equal("/recovery/recovery.imgTree"))

bootDir := filepath.Join(destination, "boot")
logger.Debugf("Creating %s", bootDir)
err := utils.MkdirAll(fs, bootDir, constants.DirPerm)
Expect(err).ShouldNot(HaveOccurred())

libDir := "/lib/modules/6.4"
err = utils.MkdirAll(fs, filepath.Join(destination, libDir), constants.DirPerm)
Expect(err).ShouldNot(HaveOccurred())

kernelPath := filepath.Join(libDir, "vmlinuz")
_, err = fs.Create(filepath.Join(destination, kernelPath))
Expect(err).ShouldNot(HaveOccurred())

err = fs.Symlink(filepath.Join(libDir, "vmlinuz"), filepath.Join(bootDir, "vmlinuz-6.4"))
Expect(err).ShouldNot(HaveOccurred())

_, err = fs.Create(filepath.Join(bootDir, "initrd"))
Expect(err).ShouldNot(HaveOccurred())
return mocks.FakeDigest, err
}
})
It("deploys a recovery system", func() {
Expect(fs.Mkdir("/recovery", constants.DirPerm)).To(Succeed())
Expect(fs.Mkdir("/recovery/boot", constants.DirPerm)).To(Succeed())

img := &types.Image{
File: filepath.Join("/recovery", constants.RecoveryImgFile),
Source: types.NewDockerSrc("elemental:latest"),
FS: constants.SquashFs,
}
err := elemental.DeployRecoverySystem(*config, img, "/recovery/boot")
Expect(err).ShouldNot(HaveOccurred())

info, err := fs.Stat("/recovery/boot/vmlinuz")
Expect(err).ShouldNot(HaveOccurred())
Expect(info.Mode() & iofs.ModeSymlink).To(BeZero())
})
})
})

// PathInMountPoints will check if the given path is in the mountPoints list
Expand Down
Loading