Add shim support for calling runsc create with --panic-log.

Making the panic log directory be inside of the normal user-log directory makes
it possible to simply reuse the same spec annotation.

PiperOrigin-RevId: 466785655
This commit is contained in:
Konstantin Bogomolov
2022-08-10 14:31:14 -07:00
committed by gVisor bot
parent fefc03e151
commit 1faac756ee
4 changed files with 18 additions and 0 deletions
+1
View File
@@ -73,6 +73,7 @@ type Init struct {
IoGID int
Sandbox bool
UserLog string
PanicLog string
Monitor ProcessMonitor
}
+7
View File
@@ -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
}
+1
View File
@@ -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
}
+9
View File
@@ -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")
}