mirror of
https://github.com/kairos-io/immucore.git
synced 2025-09-25 13:38:30 +00:00
fix not initialized map and check for already mounted mounts instead of
failing Signed-off-by: Itxaka <itxaka@spectrocloud.com>
This commit is contained in:
@@ -3,6 +3,10 @@ package mount
|
|||||||
import (
|
import (
|
||||||
"github.com/containerd/containerd/mount"
|
"github.com/containerd/containerd/mount"
|
||||||
"github.com/deniswernert/go-fstab"
|
"github.com/deniswernert/go-fstab"
|
||||||
|
"github.com/moby/sys/mountinfo"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type mountOperation struct {
|
type mountOperation struct {
|
||||||
@@ -13,11 +17,22 @@ type mountOperation struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m mountOperation) run() error {
|
func (m mountOperation) run() error {
|
||||||
|
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Caller().Logger()
|
||||||
if m.PrepareCallback != nil {
|
if m.PrepareCallback != nil {
|
||||||
if err := m.PrepareCallback(); err != nil {
|
if err := m.PrepareCallback(); err != nil {
|
||||||
|
log.Logger.Err(err).Str("what", m.MountOption.Source).Str("where", m.Target).Str("type", m.MountOption.Type).Msg("executing mount callback")
|
||||||
return err
|
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 {
|
||||||
|
log.Logger.Err(err).Str("what", m.MountOption.Source).Str("where", m.Target).Str("type", m.MountOption.Type).Msg("checking mount status")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if mounted {
|
||||||
|
log.Logger.Debug().Str("what", m.MountOption.Source).Str("where", m.Target).Str("type", m.MountOption.Type).Msg("Already mounted")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return mount.All([]mount.Mount{m.MountOption}, m.Target)
|
return mount.All([]mount.Mount{m.MountOption}, m.Target)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user