Improvements

- Set debug from ENV var as well
 - Only set sentinel if we are not on a dry-run so we can examine the
   DAG
 - Set the DAG with Init so tmpfs is part of it

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
Itxaka
2023-02-14 13:48:57 +01:00
parent 3ef3ac0251
commit 220641df60
2 changed files with 9 additions and 7 deletions

View File

@@ -33,16 +33,19 @@ Sends a generic event payload with the configuration found in the scanned direct
debug := len(utils.ReadCMDLineArg("rd.immucore.debug")) > 0 debug := len(utils.ReadCMDLineArg("rd.immucore.debug")) > 0
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Logger() log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Logger()
zerolog.SetGlobalLevel(zerolog.InfoLevel) zerolog.SetGlobalLevel(zerolog.InfoLevel)
if debug { debugFromEnv := os.Getenv("IMMUCORE_DEBUG") != ""
if debug || debugFromEnv {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Caller().Logger() log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Caller().Logger()
zerolog.SetGlobalLevel(zerolog.DebugLevel) zerolog.SetGlobalLevel(zerolog.DebugLevel)
} }
// First set the sentinel file // First set the sentinel file
err = utils.SetSentinelFile() if !c.Bool("dry-run") {
if err != nil { err = utils.SetSentinelFile()
log.Logger.Err(err).Send() if err != nil {
return err log.Logger.Err(err).Send()
return err
}
} }
// If we boot from CD, we do nothing // If we boot from CD, we do nothing
@@ -61,7 +64,7 @@ Sends a generic event payload with the configuration found in the scanned direct
} }
} }
log.Debug().Strs("TargetImage", img).Msg("Target image") log.Debug().Strs("TargetImage", img).Msg("Target image")
g := herd.DAG() g := herd.DAG(herd.EnableInit)
s := &mount.State{ s := &mount.State{
Logger: log.Logger, Logger: log.Logger,
Rootdir: utils.GetRootDir(), Rootdir: utils.GetRootDir(),

View File

@@ -192,7 +192,6 @@ func (s *State) Register(g *herd.Graph) error {
// TODO: add hooks, fstab (might have missed some), systemd compat // TODO: add hooks, fstab (might have missed some), systemd compat
// TODO: We should also set tmpfs here (not -related) // TODO: We should also set tmpfs here (not -related)
err = g.Add(opMountTmpfs, herd.WithCallback(s.MountOP("tmpfs", "/tmp", "tmpfs", []string{"rw"}, 10*time.Second))) err = g.Add(opMountTmpfs, herd.WithCallback(s.MountOP("tmpfs", "/tmp", "tmpfs", []string{"rw"}, 10*time.Second)))
if err != nil { if err != nil {
s.Logger.Debug().Err(err).Msg("tmpfs mount") s.Logger.Debug().Err(err).Msg("tmpfs mount")