Skip to content

Commit 4a5bc05

Browse files
fuweidqiutongs
authored andcommitted
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]> (cherry picked from commit b297775) Signed-off-by: Qiutong Song <[email protected]>
1 parent 71ee7de commit 4a5bc05

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
@@ -413,10 +413,9 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
413413
if err != nil {
414414
if plugin.IsSkipPlugin(err) {
415415
log.G(ctx).WithError(err).WithField("type", p.Type).Infof("skip loading plugin %q...", id)
416-
} else {
417-
log.G(ctx).WithError(err).Warnf("failed to load plugin %s", id)
416+
continue
418417
}
419-
continue
418+
return fmt.Errorf("failed to load plugin %s: %w", id, err)
420419
}
421420

422421
if src, ok := instance.(ttrpcService); ok {
@@ -430,6 +429,10 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
430429
}
431430
}
432431

432+
if len(ttrpcServices) == 0 {
433+
return fmt.Errorf("required that ttrpc service")
434+
}
435+
433436
unaryInterceptor := chainUnaryServerInterceptors(ttrpcUnaryInterceptors...)
434437
server, err := newServer(ttrpc.WithUnaryServerInterceptor(unaryInterceptor))
435438
if err != nil {

0 commit comments

Comments
 (0)