Skip to content

Commit 48f4651

Browse files
committed
Support disabling default setup of shim logger.
Before this change, the v2 runtime shim setup code was hardcoded to always configure logrus to write logs to the "log" FIFO present in the current working directory. This only happens in the "default" action codepath (i.e. not shim start or shim delete). This is problematic for shims that execute outside the current working directory of a bundle. For example, it often doesn't make sense for shims that manage multiple containers to execute in a single bundle directory. Additionally, shim processes that require being pre-created, i.e. spun up before tasks they will handle are actually created, won't have a log FIFO to write to until a task is created. This change leaves the default behavior as is but introduces a Binary Config field that will optionally disable automatic configuration of logrus to use the "log" FIFO. This allows shims to configure their own logger if necessary while still re-using the rest of the shim helper code in containerd. Signed-off-by: Erik Sipsma <[email protected]>
1 parent 2d780a7 commit 48f4651

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

runtime/v2/shim/shim.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ type Config struct {
7878
NoSubreaper bool
7979
// NoReaper disables the shim binary from reaping any child process implicitly
8080
NoReaper bool
81+
// NoSetupLogger disables automatic configuration of logrus to use the shim FIFO
82+
NoSetupLogger bool
8183
}
8284

8385
var (
@@ -206,8 +208,10 @@ func run(id string, initFunc Init, config Config) error {
206208
}
207209
return nil
208210
default:
209-
if err := setLogger(ctx, idFlag); err != nil {
210-
return err
211+
if !config.NoSetupLogger {
212+
if err := setLogger(ctx, idFlag); err != nil {
213+
return err
214+
}
211215
}
212216
client := NewShimClient(ctx, service, signals)
213217
if err := client.Serve(); err != nil {

0 commit comments

Comments
 (0)