mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Make runsc log header more helpful.
Changes: - Header is more compact (in non-debug mode). - Added Go runtime version. - Added number of CPU cores. - In debug mode, log page size. - Removed some non-important pieces of configuration to info-level logs. - Made debug mode enable the entire configuration to be logged. - Move initialization of some non-logging-related stuff be after log initialization. (Some of them *use* the log, so it makes no sense to do that before logging is actually initialized.) PiperOrigin-RevId: 595309362
This commit is contained in:
committed by
gVisor bot
parent
757cf83b7e
commit
9425d102e5
+17
-29
@@ -178,16 +178,6 @@ func Main() {
|
||||
if ulEmittter, add := userLogEmitter(conf, subcommand); add {
|
||||
emitters = append(emitters, ulEmittter)
|
||||
}
|
||||
if *coverageFD >= 0 {
|
||||
f := os.NewFile(uintptr(*coverageFD), "coverage file")
|
||||
coverage.EnableReport(f)
|
||||
}
|
||||
if *profilingMetricsFD >= 0 {
|
||||
metric.ProfilingMetricWriter = os.NewFile(uintptr(*profilingMetricsFD), "metrics file")
|
||||
if metric.ProfilingMetricWriter == nil {
|
||||
log.Warningf("Failed to use -profiling-metrics-fd")
|
||||
}
|
||||
}
|
||||
|
||||
switch len(emitters) {
|
||||
case 0:
|
||||
@@ -200,26 +190,24 @@ func Main() {
|
||||
log.SetTarget(&emitters)
|
||||
}
|
||||
|
||||
log.Infof("***************************")
|
||||
log.Infof("Args: %s", os.Args)
|
||||
log.Infof("Version %s", version.Version())
|
||||
log.Infof("GOOS: %s", runtime.GOOS)
|
||||
log.Infof("GOARCH: %s", runtime.GOARCH)
|
||||
log.Infof("PID: %d", os.Getpid())
|
||||
log.Infof("UID: %d, GID: %d", os.Getuid(), os.Getgid())
|
||||
log.Infof("Configuration:")
|
||||
log.Infof("\t\tRootDir: %s", conf.RootDir)
|
||||
log.Infof("\t\tPlatform: %v", conf.Platform)
|
||||
log.Infof("\t\tFileAccess: %v", conf.FileAccess)
|
||||
log.Infof("\t\tDirectfs: %t", conf.DirectFS)
|
||||
log.Infof("\t\tOverlay: %s", conf.GetOverlay2())
|
||||
log.Infof("\t\tNetwork: %v, logging: %t", conf.Network, conf.LogPackets)
|
||||
log.Infof("\t\tStrace: %t, max size: %d, syscalls: %s", conf.Strace, conf.StraceLogSize, conf.StraceSyscalls)
|
||||
log.Infof("\t\tIOURING: %t", conf.IOUring)
|
||||
log.Infof("\t\tDebug: %v", conf.Debug)
|
||||
log.Infof("\t\tSystemd: %v", conf.SystemdCgroup)
|
||||
log.Infof("***************************")
|
||||
const delimString = `**************** gVisor ****************`
|
||||
log.Infof(delimString)
|
||||
log.Infof("Version %s, %s, %s, %d CPUs, %s, PID %d, PPID %d, UID %d, GID %d", version.Version(), runtime.Version(), runtime.GOARCH, runtime.NumCPU(), runtime.GOOS, os.Getpid(), os.Getppid(), os.Getuid(), os.Getgid())
|
||||
log.Debugf("Page size: 0x%x (%d bytes)", os.Getpagesize(), os.Getpagesize())
|
||||
log.Infof("Args: %v", os.Args)
|
||||
conf.Log()
|
||||
log.Infof(delimString)
|
||||
|
||||
if *coverageFD >= 0 {
|
||||
f := os.NewFile(uintptr(*coverageFD), "coverage file")
|
||||
coverage.EnableReport(f)
|
||||
}
|
||||
if *profilingMetricsFD >= 0 {
|
||||
metric.ProfilingMetricWriter = os.NewFile(uintptr(*profilingMetricsFD), "metrics file")
|
||||
if metric.ProfilingMetricWriter == nil {
|
||||
log.Warningf("Failed to use -profiling-metrics-fd")
|
||||
}
|
||||
}
|
||||
if conf.TestOnlyAllowRunAsCurrentUserWithoutChroot {
|
||||
// SIGTERM is sent to all processes if a test exceeds its
|
||||
// timeout and this case is handled by syscall_test_runner.
|
||||
|
||||
@@ -20,11 +20,13 @@ package config
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/log"
|
||||
"gvisor.dev/gvisor/pkg/refs"
|
||||
"gvisor.dev/gvisor/pkg/sentry/watchdog"
|
||||
"gvisor.dev/gvisor/runsc/flag"
|
||||
@@ -393,6 +395,33 @@ func (c *Config) validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Log logs important aspects of the configuration to the given log function.
|
||||
func (c *Config) Log() {
|
||||
log.Infof("Platform: %v", c.Platform)
|
||||
log.Infof("RootDir: %s", c.RootDir)
|
||||
log.Infof("FileAccess: %v / Directfs: %t / Overlay: %v", c.FileAccess, c.DirectFS, c.GetOverlay2())
|
||||
log.Infof("Network: %v", c.Network)
|
||||
if c.Debug || c.Strace {
|
||||
log.Infof("Debug: %t. Strace: %t, max size: %d, syscalls: %s", c.Debug, c.Strace, c.StraceLogSize, c.StraceSyscalls)
|
||||
}
|
||||
if c.Debug {
|
||||
obj := reflect.ValueOf(c).Elem()
|
||||
st := obj.Type()
|
||||
for i := 0; i < st.NumField(); i++ {
|
||||
f := st.Field(i)
|
||||
val := obj.Field(i).String()
|
||||
if val == "" {
|
||||
val = "(empty)"
|
||||
}
|
||||
if flagName, hasFlag := f.Tag.Lookup("flag"); hasFlag {
|
||||
log.Debugf("Config.%s (--%s): %v", f.Name, flagName, val)
|
||||
} else {
|
||||
log.Debugf("Config.%s: %v", f.Name, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetHostUDS returns the FS gofer communication that is allowed, taking into
|
||||
// consideration all flags what affect the result.
|
||||
func (c *Config) GetHostUDS() HostUDS {
|
||||
|
||||
Reference in New Issue
Block a user