@@ -26,6 +26,7 @@ import (
2626
2727 "github.com/containerd/containerd/events/exchange"
2828 "github.com/containerd/containerd/log"
29+ "github.com/containerd/containerd/namespaces"
2930 "github.com/containerd/containerd/runtime"
3031 client "github.com/containerd/containerd/runtime/v2/shim"
3132 "github.com/containerd/containerd/runtime/v2/task"
@@ -74,7 +75,15 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_
7475 if err != nil {
7576 return nil , err
7677 }
77- f , err := openShimLog (ctx , b .bundle , client .AnonDialer )
78+ // Windows needs a namespace when openShimLog
79+ ns , _ := namespaces .Namespace (ctx )
80+ shimCtx , cancelShimLog := context .WithCancel (namespaces .WithNamespace (context .Background (), ns ))
81+ defer func () {
82+ if err != nil {
83+ cancelShimLog ()
84+ }
85+ }()
86+ f , err := openShimLog (shimCtx , b .bundle , client .AnonDialer )
7887 if err != nil {
7988 return nil , errors .Wrap (err , "open shim log pipe" )
8089 }
@@ -103,7 +112,11 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_
103112 if err != nil {
104113 return nil , err
105114 }
106- client := ttrpc .NewClient (conn , ttrpc .WithOnClose (onClose ))
115+ onCloseWithShimLog := func () {
116+ onClose ()
117+ cancelShimLog ()
118+ }
119+ client := ttrpc .NewClient (conn , ttrpc .WithOnClose (onCloseWithShimLog ))
107120 return & shim {
108121 bundle : b .bundle ,
109122 client : client ,
0 commit comments