mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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:
committed by
gVisor bot
parent
fefc03e151
commit
1faac756ee
@@ -73,6 +73,7 @@ type Init struct {
|
||||
IoGID int
|
||||
Sandbox bool
|
||||
UserLog string
|
||||
PanicLog string
|
||||
Monitor ProcessMonitor
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user