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,17 +33,20 @@ Sends a generic event payload with the configuration found in the scanned direct
debug := len(utils.ReadCMDLineArg("rd.immucore.debug")) > 0
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Logger()
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()
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
// First set the sentinel file
if !c.Bool("dry-run") {
err = utils.SetSentinelFile()
if err != nil {
log.Logger.Err(err).Send()
return err
}
}
// If we boot from CD, we do nothing
cdBoot, err := utils.BootedFromCD()
@@ -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")
g := herd.DAG()
g := herd.DAG(herd.EnableInit)
s := &mount.State{
Logger: log.Logger,
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: We should also set tmpfs here (not -related)
err = g.Add(opMountTmpfs, herd.WithCallback(s.MountOP("tmpfs", "/tmp", "tmpfs", []string{"rw"}, 10*time.Second)))
if err != nil {
s.Logger.Debug().Err(err).Msg("tmpfs mount")