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 <fuweid89@gmail.com>
This commit is contained in:
parent
5f9b318e50
commit
b297775eaf
@ -417,10 +417,9 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
|
||||
if err != nil {
|
||||
if plugin.IsSkipPlugin(err) {
|
||||
log.G(ctx).WithError(err).WithField("type", p.Type).Infof("skip loading plugin %q...", id)
|
||||
} else {
|
||||
log.G(ctx).WithError(err).Warnf("failed to load plugin %s", id)
|
||||
continue
|
||||
}
|
||||
continue
|
||||
return fmt.Errorf("failed to load plugin %s: %w", id, err)
|
||||
}
|
||||
|
||||
if src, ok := instance.(ttrpcService); ok {
|
||||
@ -434,6 +433,10 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
|
||||
}
|
||||
}
|
||||
|
||||
if len(ttrpcServices) == 0 {
|
||||
return fmt.Errorf("required that ttrpc service")
|
||||
}
|
||||
|
||||
unaryInterceptor := chainUnaryServerInterceptors(ttrpcUnaryInterceptors...)
|
||||
server, err := newServer(ttrpc.WithUnaryServerInterceptor(unaryInterceptor))
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user