@@ -30,7 +30,6 @@ import (
30
30
taskAPI "github.com/containerd/containerd/runtime/v2/task"
31
31
"github.com/gogo/protobuf/types"
32
32
"github.com/hashicorp/go-multierror"
33
- "github.com/pkg/errors"
34
33
"github.com/sirupsen/logrus"
35
34
"golang.org/x/sys/unix"
36
35
@@ -157,7 +156,7 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
157
156
// this is technically validated earlier by containerd, but is added here too for extra safety
158
157
taskExecID , err := TaskExecID (taskID , execID )
159
158
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 )
161
160
}
162
161
163
162
logger := log .G (requestCtx ).WithField ("TaskID" , taskID ).WithField ("ExecID" , execID )
@@ -174,7 +173,7 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
174
173
175
174
extraData , err := unmarshalExtraData (req .Options )
176
175
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 )
178
177
}
179
178
180
179
// 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
184
183
ts .addCleanup (taskExecID , func () error {
185
184
err := os .RemoveAll (bundleDir .RootPath ())
186
185
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 )
188
187
}
189
188
return nil
190
189
})
@@ -195,22 +194,22 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
195
194
// the bundledir was not created. Create it here.
196
195
if isVMLocalRootFs {
197
196
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 )
199
198
}
200
199
}
201
200
202
201
// check the rootfs dir has been created (presumed to be by a previous MountDrive call)
203
202
rootfsStat , err := os .Stat (bundleDir .RootfsPath ())
204
203
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 )
206
205
}
207
206
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 ())
209
208
}
210
209
ts .addCleanup (taskExecID , func () error {
211
210
err := mount .UnmountAll (bundleDir .RootfsPath (), unix .MNT_DETACH )
212
211
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 )
214
213
}
215
214
return nil
216
215
})
@@ -228,12 +227,12 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
228
227
}
229
228
specData , err = vm .UpdateUserInSpec (requestCtx , specData , rootfsMount )
230
229
if err != nil {
231
- return nil , errors . Wrap ( err , "failed to update spec" )
230
+ return nil , fmt . Errorf ( "failed to update spec: %w" , err )
232
231
}
233
232
}
234
233
err = bundleDir .OCIConfig ().Write (specData )
235
234
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 )
237
236
}
238
237
239
238
var ioConnectorSet vm.IOProxy
@@ -244,7 +243,7 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
244
243
// Override the incoming stdio FIFOs, which have paths from the host that we can't use
245
244
fifoSet , err := cio .NewFIFOSetInDir (bundleDir .RootPath (), taskExecID , req .Terminal )
246
245
if err != nil {
247
- err = errors . Wrap ( err , "failed to open stdio FIFOs" )
246
+ err = fmt . Errorf ( "failed to open stdio FIFOs: %w" , err )
248
247
logger .WithError (err ).Error ()
249
248
return nil , err
250
249
}
@@ -331,7 +330,7 @@ func (ts *TaskService) Delete(requestCtx context.Context, req *taskAPI.DeleteReq
331
330
// this is technically validated earlier by containerd, but is added here too for extra safety
332
331
taskExecID , err := TaskExecID (taskID , execID )
333
332
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 )
335
334
}
336
335
337
336
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
343
342
344
343
err = ts .doCleanup (taskExecID )
345
344
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 )
347
346
}
348
347
349
348
log .G (requestCtx ).WithFields (logrus.Fields {
@@ -437,7 +436,7 @@ func (ts *TaskService) Exec(requestCtx context.Context, req *taskAPI.ExecProcess
437
436
// this is technically validated earlier by containerd, but is added here too for extra safety
438
437
taskExecID , err := TaskExecID (taskID , execID )
439
438
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 )
441
440
}
442
441
443
442
logger := log .G (requestCtx ).WithField ("TaskID" , taskID ).WithField ("ExecID" , execID )
@@ -454,7 +453,7 @@ func (ts *TaskService) Exec(requestCtx context.Context, req *taskAPI.ExecProcess
454
453
455
454
extraData , err := unmarshalExtraData (req .Spec )
456
455
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 )
458
457
}
459
458
460
459
// 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
470
469
// Override the incoming stdio FIFOs, which have paths from the host that we can't use
471
470
fifoSet , err := cio .NewFIFOSetInDir (bundleDir .RootPath (), taskExecID , req .Terminal )
472
471
if err != nil {
473
- err = errors . Wrap ( err , "failed to open stdio FIFOs" )
472
+ err = fmt . Errorf ( "failed to open stdio FIFOs: %w" , err )
474
473
logger .WithError (err ).Error ()
475
474
return nil , err
476
475
}
0 commit comments