mirror of
https://github.com/kairos-io/immucore.git
synced 2025-07-30 21:55:27 +00:00
This makes immucore run more in parallel rather than block everything else. We just tell sysroot.mount that eventually it will be mounted and to wait for a bit. This allows us to be more flexible where to run and run in parallel in cases like cdrom in which we may do things but we need the sysroot to be mounted already but not from us. Also adds the initramfs stage directly in immucore and merges all the dracut config into one Dont create sysroot, just add a timeout override so it waits for us Dont block on the service, just make sure to finish before initrd.target Fix mounts from cmdline More proper log Store logs under the /run/immucore dir Store rootfs and initramfs logs separated Do not log the full stages in INFO level Run initramfs stage in immucore directly on boot and cd/netboot Drop systemd requirement from dracut module Signed-off-by: Itxaka itxaka.garcia@spectrocloud.com
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package mount
|
|
|
|
import (
|
|
"github.com/containerd/containerd/mount"
|
|
"github.com/deniswernert/go-fstab"
|
|
"github.com/kairos-io/immucore/internal/constants"
|
|
internalUtils "github.com/kairos-io/immucore/internal/utils"
|
|
"github.com/moby/sys/mountinfo"
|
|
"github.com/rs/zerolog"
|
|
)
|
|
|
|
type mountOperation struct {
|
|
FstabEntry fstab.Mount
|
|
MountOption mount.Mount
|
|
Target string
|
|
PrepareCallback func() error
|
|
}
|
|
|
|
func (m mountOperation) run() error {
|
|
// Add context to sublogger
|
|
l := internalUtils.Log.With().Str("what", m.MountOption.Source).Str("where", m.Target).Str("type", m.MountOption.Type).Strs("options", m.MountOption.Options).Logger().Level(zerolog.InfoLevel)
|
|
// Not sure why this defaults to debuglevel when creating a sublogger, so make sure we set it properly
|
|
debug := len(internalUtils.ReadCMDLineArg("rd.immucore.debug")) > 0
|
|
if debug {
|
|
l.Level(zerolog.DebugLevel)
|
|
}
|
|
|
|
if m.PrepareCallback != nil {
|
|
if err := m.PrepareCallback(); err != nil {
|
|
l.Err(err).Msg("executing mount callback")
|
|
return err
|
|
}
|
|
}
|
|
//TODO: not only check if mounted but also if the type,options and source are the same?
|
|
mounted, err := mountinfo.Mounted(m.Target)
|
|
if err != nil {
|
|
l.Err(err).Msg("checking mount status")
|
|
return err
|
|
}
|
|
if mounted {
|
|
l.Debug().Msg("Already mounted")
|
|
return constants.ErrAlreadyMounted
|
|
}
|
|
l.Debug().Msg("mount ready")
|
|
return mount.All([]mount.Mount{m.MountOption}, m.Target)
|
|
}
|