Skip to content

Commit b297775

Browse files
committed
runtime/v2/shim: return if error in load plugin
If there is any unskipable error during setuping shim plugins, we should fail return error to prevent from leaky shim instance. For example, there is error during init task plugin, the shim ttrpc server will not contain any shim API method. The any call to the shim will receive that failed to create shim task: service containerd.task.v2.Task: not implemented Then containerd can't use `Shutdown` to let the shim close. The shim will be leaky. And also fail return if there is no ttrpc service. Signed-off-by: Wei Fu <[email protected]>
1 parent 5f9b318 commit b297775

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

runtime/v2/shim/shim.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,9 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
417417
if err != nil {
418418
if plugin.IsSkipPlugin(err) {
419419
log.G(ctx).WithError(err).WithField("type", p.Type).Infof("skip loading plugin %q...", id)
420-
} else {
421-
log.G(ctx).WithError(err).Warnf("failed to load plugin %s", id)
420+
continue
422421
}
423-
continue
422+
return fmt.Errorf("failed to load plugin %s: %w", id, err)
424423
}
425424

426425
if src, ok := instance.(ttrpcService); ok {
@@ -434,6 +433,10 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
434433
}
435434
}
436435

436+
if len(ttrpcServices) == 0 {
437+
return fmt.Errorf("required that ttrpc service")
438+
}
439+
437440
unaryInterceptor := chainUnaryServerInterceptors(ttrpcUnaryInterceptors...)
438441
server, err := newServer(ttrpc.WithUnaryServerInterceptor(unaryInterceptor))
439442
if err != nil {

0 commit comments

Comments
 (0)