@@ -27,6 +27,8 @@ import (
2727 "github.com/containerd/containerd/errdefs"
2828 "github.com/containerd/containerd/log"
2929 cni "github.com/containerd/go-cni"
30+ "github.com/containerd/nri"
31+ v1 "github.com/containerd/nri/types/v1"
3032 "github.com/containerd/typeurl"
3133 "github.com/davecgh/go-spew/spew"
3234 "github.com/pkg/errors"
@@ -269,7 +271,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
269271 deferCtx , deferCancel := ctrdutil .DeferContext ()
270272 defer deferCancel ()
271273 // Cleanup the sandbox container if an error is returned.
272- if _ , err := task .Delete (deferCtx , containerd .WithProcessKill ); err != nil && ! errdefs .IsNotFound (err ) {
274+ if _ , err := task .Delete (deferCtx , WithNRISandboxDelete ( id ), containerd .WithProcessKill ); err != nil && ! errdefs .IsNotFound (err ) {
273275 log .G (ctx ).WithError (err ).Errorf ("Failed to delete sandbox container %q" , id )
274276 }
275277 }
@@ -281,6 +283,20 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
281283 return nil , errors .Wrap (err , "failed to wait for sandbox container task" )
282284 }
283285
286+ nric , err := nri .New ()
287+ if err != nil {
288+ return nil , errors .Wrap (err , "unable to create nri client" )
289+ }
290+ if nric != nil {
291+ nriSB := & nri.Sandbox {
292+ ID : id ,
293+ Labels : config .Labels ,
294+ }
295+ if _ , err := nric .InvokeWithSandbox (ctx , task , v1 .Create , nriSB ); err != nil {
296+ return nil , errors .Wrap (err , "nri invoke" )
297+ }
298+ }
299+
284300 if err := task .Start (ctx ); err != nil {
285301 return nil , errors .Wrapf (err , "failed to start sandbox container task %q" , id )
286302 }
0 commit comments