@@ -30,7 +30,6 @@ import (
3030 taskAPI "github.com/containerd/containerd/runtime/v2/task"
3131 "github.com/gogo/protobuf/types"
3232 "github.com/hashicorp/go-multierror"
33- "github.com/pkg/errors"
3433 "github.com/sirupsen/logrus"
3534 "golang.org/x/sys/unix"
3635
@@ -157,7 +156,7 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
157156 // this is technically validated earlier by containerd, but is added here too for extra safety
158157 taskExecID , err := TaskExecID (taskID , execID )
159158 if err != nil {
160- return nil , errors . Wrap ( err , "invalid task and/or exec ID" )
159+ return nil , fmt . Errorf ( "invalid task and/or exec ID: %w" , err )
161160 }
162161
163162 logger := log .G (requestCtx ).WithField ("TaskID" , taskID ).WithField ("ExecID" , execID )
@@ -174,7 +173,7 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
174173
175174 extraData , err := unmarshalExtraData (req .Options )
176175 if err != nil {
177- return nil , errors . Wrap ( err , "failed to unmarshal extra data" )
176+ return nil , fmt . Errorf ( "failed to unmarshal extra data: %w" , err )
178177 }
179178
180179 // Just provide runc the options it knows about, not our wrapper
@@ -184,7 +183,7 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
184183 ts .addCleanup (taskExecID , func () error {
185184 err := os .RemoveAll (bundleDir .RootPath ())
186185 if err != nil {
187- return errors . Wrapf ( err , "failed to remove bundle path %q" , bundleDir .RootPath ())
186+ return fmt . Errorf ( "failed to remove bundle path %q: %w " , bundleDir .RootPath (), err )
188187 }
189188 return nil
190189 })
@@ -195,22 +194,22 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
195194 // the bundledir was not created. Create it here.
196195 if isVMLocalRootFs {
197196 if err := os .MkdirAll (bundleDir .RootfsPath (), 0700 ); err != nil {
198- return nil , errors . Wrapf ( err , "Failed to create bundle's rootfs path from inside the vm %q" , bundleDir .RootfsPath ())
197+ return nil , fmt . Errorf ( "Failed to create bundle's rootfs path from inside the vm %q: %w " , bundleDir .RootfsPath (), err )
199198 }
200199 }
201200
202201 // check the rootfs dir has been created (presumed to be by a previous MountDrive call)
203202 rootfsStat , err := os .Stat (bundleDir .RootfsPath ())
204203 if err != nil {
205- return nil , errors . Wrapf ( err , "failed to stat bundle's rootfs path %q" , bundleDir .RootfsPath ())
204+ return nil , fmt . Errorf ( "failed to stat bundle's rootfs path %q: %w " , bundleDir .RootfsPath (), err )
206205 }
207206 if ! rootfsStat .IsDir () {
208- return nil , errors .Errorf ("bundle's rootfs path %q is not a dir" , bundleDir .RootfsPath ())
207+ return nil , fmt .Errorf ("bundle's rootfs path %q is not a dir" , bundleDir .RootfsPath ())
209208 }
210209 ts .addCleanup (taskExecID , func () error {
211210 err := mount .UnmountAll (bundleDir .RootfsPath (), unix .MNT_DETACH )
212211 if err != nil {
213- return errors . Wrapf ( err , "failed to unmount bundle rootfs %q" , bundleDir .RootfsPath ())
212+ return fmt . Errorf ( "failed to unmount bundle rootfs %q: %w " , bundleDir .RootfsPath (), err )
214213 }
215214 return nil
216215 })
@@ -228,12 +227,12 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
228227 }
229228 specData , err = vm .UpdateUserInSpec (requestCtx , specData , rootfsMount )
230229 if err != nil {
231- return nil , errors . Wrap ( err , "failed to update spec" )
230+ return nil , fmt . Errorf ( "failed to update spec: %w" , err )
232231 }
233232 }
234233 err = bundleDir .OCIConfig ().Write (specData )
235234 if err != nil {
236- return nil , errors . Wrap ( err , "failed to write oci config file" )
235+ return nil , fmt . Errorf ( "failed to write oci config file: %w" , err )
237236 }
238237
239238 var ioConnectorSet vm.IOProxy
@@ -244,7 +243,7 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
244243 // Override the incoming stdio FIFOs, which have paths from the host that we can't use
245244 fifoSet , err := cio .NewFIFOSetInDir (bundleDir .RootPath (), taskExecID , req .Terminal )
246245 if err != nil {
247- err = errors . Wrap ( err , "failed to open stdio FIFOs" )
246+ err = fmt . Errorf ( "failed to open stdio FIFOs: %w" , err )
248247 logger .WithError (err ).Error ()
249248 return nil , err
250249 }
@@ -331,7 +330,7 @@ func (ts *TaskService) Delete(requestCtx context.Context, req *taskAPI.DeleteReq
331330 // this is technically validated earlier by containerd, but is added here too for extra safety
332331 taskExecID , err := TaskExecID (taskID , execID )
333332 if err != nil {
334- return nil , errors . Wrap ( err , "invalid task and/or exec ID" )
333+ return nil , fmt . Errorf ( "invalid task and/or exec ID: %w" , err )
335334 }
336335
337336 log .G (requestCtx ).WithFields (logrus.Fields {"id" : taskID , "exec_id" : execID }).Debug ("delete" )
@@ -343,7 +342,7 @@ func (ts *TaskService) Delete(requestCtx context.Context, req *taskAPI.DeleteReq
343342
344343 err = ts .doCleanup (taskExecID )
345344 if err != nil {
346- return nil , errors . Wrapf ( err , "failed to cleanup task %q exec %q" , taskID , execID )
345+ return nil , fmt . Errorf ( "failed to cleanup task %q exec %q: %w " , taskID , execID , err )
347346 }
348347
349348 log .G (requestCtx ).WithFields (logrus.Fields {
@@ -437,7 +436,7 @@ func (ts *TaskService) Exec(requestCtx context.Context, req *taskAPI.ExecProcess
437436 // this is technically validated earlier by containerd, but is added here too for extra safety
438437 taskExecID , err := TaskExecID (taskID , execID )
439438 if err != nil {
440- return nil , errors . Wrap ( err , "invalid task and/or exec ID" )
439+ return nil , fmt . Errorf ( "invalid task and/or exec ID: %w" , err )
441440 }
442441
443442 logger := log .G (requestCtx ).WithField ("TaskID" , taskID ).WithField ("ExecID" , execID )
@@ -454,7 +453,7 @@ func (ts *TaskService) Exec(requestCtx context.Context, req *taskAPI.ExecProcess
454453
455454 extraData , err := unmarshalExtraData (req .Spec )
456455 if err != nil {
457- return nil , errors . Wrap ( err , "failed to unmarshal extra data" )
456+ return nil , fmt . Errorf ( "failed to unmarshal extra data: %w" , err )
458457 }
459458
460459 // Just provide runc the options it knows about, not our wrapper
@@ -470,7 +469,7 @@ func (ts *TaskService) Exec(requestCtx context.Context, req *taskAPI.ExecProcess
470469 // Override the incoming stdio FIFOs, which have paths from the host that we can't use
471470 fifoSet , err := cio .NewFIFOSetInDir (bundleDir .RootPath (), taskExecID , req .Terminal )
472471 if err != nil {
473- err = errors . Wrap ( err , "failed to open stdio FIFOs" )
472+ err = fmt . Errorf ( "failed to open stdio FIFOs: %w" , err )
474473 logger .WithError (err ).Error ()
475474 return nil , err
476475 }
0 commit comments