@@ -20,6 +20,7 @@ package process
20
20
21
21
import (
22
22
"context"
23
+ "errors"
23
24
"fmt"
24
25
"io"
25
26
"net/url"
@@ -36,7 +37,6 @@ import (
36
37
"github.com/containerd/fifo"
37
38
runc "github.com/containerd/go-runc"
38
39
"github.com/containerd/log"
39
- "github.com/hashicorp/go-multierror"
40
40
)
41
41
42
42
const binaryIOProcTermTimeout = 12 * time .Second // Give logger process solid 10 seconds for cleanup
@@ -255,11 +255,11 @@ func NewBinaryIO(ctx context.Context, id string, uri *url.URL) (_ runc.IO, err e
255
255
if err == nil {
256
256
return
257
257
}
258
- result := multierror . Append ( err )
258
+ result := [] error { err }
259
259
for _ , fn := range closers {
260
- result = multierror . Append (result , fn ())
260
+ result = append (result , fn ())
261
261
}
262
- err = multierror . Flatten (result )
262
+ err = errors . Join (result ... )
263
263
}()
264
264
265
265
out , err := newPipe ()
@@ -313,39 +313,35 @@ type binaryIO struct {
313
313
}
314
314
315
315
func (b * binaryIO ) CloseAfterStart () error {
316
- var (
317
- result * multierror.Error
318
- )
316
+ var result []error
319
317
320
318
for _ , v := range []* pipe {b .out , b .err } {
321
319
if v != nil {
322
320
if err := v .r .Close (); err != nil {
323
- result = multierror . Append (result , err )
321
+ result = append (result , err )
324
322
}
325
323
}
326
324
}
327
325
328
- return result . ErrorOrNil ( )
326
+ return errors . Join ( result ... )
329
327
}
330
328
331
329
func (b * binaryIO ) Close () error {
332
- var (
333
- result * multierror.Error
334
- )
330
+ var result []error
335
331
336
332
for _ , v := range []* pipe {b .out , b .err } {
337
333
if v != nil {
338
334
if err := v .Close (); err != nil {
339
- result = multierror . Append (result , err )
335
+ result = append (result , err )
340
336
}
341
337
}
342
338
}
343
339
344
340
if err := b .cancel (); err != nil {
345
- result = multierror . Append (result , err )
341
+ result = append (result , err )
346
342
}
347
343
348
- return result . ErrorOrNil ( )
344
+ return errors . Join ( result ... )
349
345
}
350
346
351
347
func (b * binaryIO ) cancel () error {
@@ -355,15 +351,15 @@ func (b *binaryIO) cancel() error {
355
351
356
352
// Send SIGTERM first, so logger process has a chance to flush and exit properly
357
353
if err := b .cmd .Process .Signal (syscall .SIGTERM ); err != nil {
358
- result := multierror . Append ( fmt .Errorf ("failed to send SIGTERM: %w" , err ))
354
+ result := [] error { fmt .Errorf ("failed to send SIGTERM: %w" , err )}
359
355
360
356
log .L .WithError (err ).Warn ("failed to send SIGTERM signal, killing logging shim" )
361
357
362
358
if err := b .cmd .Process .Kill (); err != nil {
363
- result = multierror . Append (result , fmt .Errorf ("failed to kill process after faulty SIGTERM: %w" , err ))
359
+ result = append (result , fmt .Errorf ("failed to kill process after faulty SIGTERM: %w" , err ))
364
360
}
365
361
366
- return result . ErrorOrNil ( )
362
+ return errors . Join ( result ... )
367
363
}
368
364
369
365
done := make (chan error , 1 )
@@ -424,15 +420,15 @@ type pipe struct {
424
420
}
425
421
426
422
func (p * pipe ) Close () error {
427
- var result * multierror. Error
423
+ var result [] error
428
424
429
425
if err := p .w .Close (); err != nil {
430
- result = multierror . Append (result , fmt .Errorf ("failed to close write pipe: %w" , err ))
426
+ result = append (result , fmt .Errorf ("pipe: failed to close write pipe: %w" , err ))
431
427
}
432
428
433
429
if err := p .r .Close (); err != nil {
434
- result = multierror . Append (result , fmt .Errorf ("failed to close read pipe: %w" , err ))
430
+ result = append (result , fmt .Errorf ("pipe: failed to close read pipe: %w" , err ))
435
431
}
436
432
437
- return multierror . Prefix (result .ErrorOrNil (), "pipe:" )
433
+ return errors . Join (result ... )
438
434
}
0 commit comments