Skip to content

Commit 28f1e32

Browse files
wllenyjcpuguy83
authored andcommitted
shim: fix debug flag not working
As we know, shim starts twice. The first time we execute the shim with the `start` arguments, the `-debug` argument is passed to the shim process correctly. But the second time we execute shim, the debug flag is ignored. Signed-off-by: wllenyj <[email protected]> (cherry picked from commit f710505) Signed-off-by: Brian Goff <[email protected]>
1 parent 2ccfcff commit 28f1e32

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

runtime/v2/runc/manager/manager_linux.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type manager struct {
6969
name string
7070
}
7171

72-
func newCommand(ctx context.Context, id, containerdBinary, containerdAddress, containerdTTRPCAddress string) (*exec.Cmd, error) {
72+
func newCommand(ctx context.Context, id, containerdBinary, containerdAddress, containerdTTRPCAddress string, debug bool) (*exec.Cmd, error) {
7373
ns, err := namespaces.NamespaceRequired(ctx)
7474
if err != nil {
7575
return nil, err
@@ -87,6 +87,9 @@ func newCommand(ctx context.Context, id, containerdBinary, containerdAddress, co
8787
"-id", id,
8888
"-address", containerdAddress,
8989
}
90+
if debug {
91+
args = append(args, "-debug")
92+
}
9093
cmd := exec.Command(self, args...)
9194
cmd.Dir = cwd
9295
cmd.Env = append(os.Environ(), "GOMAXPROCS=4")
@@ -114,7 +117,7 @@ func (m manager) Name() string {
114117
}
115118

116119
func (manager) Start(ctx context.Context, id string, opts shim.StartOpts) (_ string, retErr error) {
117-
cmd, err := newCommand(ctx, id, opts.ContainerdBinary, opts.Address, opts.TTRPCAddress)
120+
cmd, err := newCommand(ctx, id, opts.ContainerdBinary, opts.Address, opts.TTRPCAddress, opts.Debug)
118121
if err != nil {
119122
return "", err
120123
}

runtime/v2/shim/shim.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type StartOpts struct {
5252
ContainerdBinary string
5353
Address string
5454
TTRPCAddress string
55+
Debug bool
5556
}
5657

5758
type StopStatus struct {
@@ -333,6 +334,7 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
333334
ContainerdBinary: containerdBinaryFlag,
334335
Address: addressFlag,
335336
TTRPCAddress: ttrpcAddress,
337+
Debug: debugFlag,
336338
}
337339

338340
address, err := manager.Start(ctx, id, opts)

0 commit comments

Comments
 (0)