diff --git a/pkg/shim/proc/init.go b/pkg/shim/proc/init.go index 6bf090813..a92513ca6 100644 --- a/pkg/shim/proc/init.go +++ b/pkg/shim/proc/init.go @@ -73,6 +73,7 @@ type Init struct { IoGID int Sandbox bool UserLog string + PanicLog string Monitor ProcessMonitor } diff --git a/pkg/shim/runsc/runsc.go b/pkg/shim/runsc/runsc.go index 888cb0bcb..a3404744c 100644 --- a/pkg/shim/runsc/runsc.go +++ b/pkg/shim/runsc/runsc.go @@ -108,6 +108,10 @@ type CreateOpts struct { // UserLog is a path to where runsc user log should be generated. UserLog string + + // PanicLog is a path to where runsc will output its panic message + // (in case it does panic). + PanicLog string } func (o *CreateOpts) args() (out []string, err error) { @@ -124,6 +128,9 @@ func (o *CreateOpts) args() (out []string, err error) { if o.UserLog != "" { out = append(out, "--user-log", o.UserLog) } + if o.PanicLog != "" { + out = append(out, "--panic-log", o.PanicLog) + } return out, nil } diff --git a/pkg/shim/service.go b/pkg/shim/service.go index 80ce0c0af..ac55a4963 100644 --- a/pkg/shim/service.go +++ b/pkg/shim/service.go @@ -1097,6 +1097,7 @@ func newInit(path, workDir, namespace string, platform stdio.Platform, r *proc.C p.IoGID = int(options.IoGID) p.Sandbox = specutils.SpecContainerType(spec) == specutils.ContainerTypeSandbox p.UserLog = utils.UserLogPath(spec) + p.PanicLog = utils.PanicLogPath(spec) p.Monitor = reaper.Default return p, nil } diff --git a/pkg/shim/utils/utils.go b/pkg/shim/utils/utils.go index f183b1bbc..10c7340e3 100644 --- a/pkg/shim/utils/utils.go +++ b/pkg/shim/utils/utils.go @@ -61,3 +61,12 @@ func UserLogPath(spec *specs.Spec) string { } return filepath.Join(sandboxLogDir, "gvisor.log") } + +// PanicLogPath gets the panic log path from OCI annotation. +func PanicLogPath(spec *specs.Spec) string { + sandboxLogDir := spec.Annotations[sandboxLogDirAnnotation] + if sandboxLogDir == "" { + return "" + } + return filepath.Join(sandboxLogDir, "gvisor_panic.log") +}