services/server: use structured log for plugin ID
These logs were already using structured logs, so include "id" as a field, which also prevents the id being quoted (and escaped when printing); time="2023-11-15T11:30:23.745574884Z" level=info msg="loading plugin \"io.containerd.internal.v1.shutdown\"..." runtime=io.containerd.runc.v2 type=io.containerd.internal.v1 time="2023-11-15T11:30:23.745612425Z" level=info msg="loading plugin \"io.containerd.ttrpc.v1.pause\"..." runtime=io.containerd.runc.v2 type=io.containerd.ttrpc.v1 time="2023-11-15T11:30:23.745620884Z" level=info msg="loading plugin \"io.containerd.event.v1.publisher\"..." runtime=io.containerd.runc.v2 type=io.containerd.event.v1 time="2023-11-15T11:30:23.745625925Z" level=info msg="loading plugin \"io.containerd.ttrpc.v1.task\"..." runtime=io.containerd.runc.v2 type=io.containerd.ttrpc.v1 Also updated some changed `WithError().WithField()` calls, to prevent some overhead. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
09de4f1fcc
commit
be22e12d56
@ -247,7 +247,7 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
|
|||||||
|
|
||||||
for _, p := range loaded {
|
for _, p := range loaded {
|
||||||
id := p.URI()
|
id := p.URI()
|
||||||
log.G(ctx).WithField("type", p.Type).Infof("loading plugin %q...", id)
|
log.G(ctx).WithFields(log.Fields{"id": id, "type": p.Type}).Info("loading plugin")
|
||||||
var mustSucceed int32
|
var mustSucceed int32
|
||||||
|
|
||||||
initContext := plugin.NewContext(
|
initContext := plugin.NewContext(
|
||||||
@ -281,9 +281,9 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
|
|||||||
instance, err := result.Instance()
|
instance, err := result.Instance()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if plugin.IsSkipPlugin(err) {
|
if plugin.IsSkipPlugin(err) {
|
||||||
log.G(ctx).WithError(err).WithField("type", p.Type).Infof("skip loading plugin %q...", id)
|
log.G(ctx).WithFields(log.Fields{"error": err, "id": id, "type": p.Type}).Info("skip loading plugin")
|
||||||
} else {
|
} else {
|
||||||
log.G(ctx).WithError(err).Warnf("failed to load plugin %s", id)
|
log.G(ctx).WithFields(log.Fields{"error": err, "id": id, "type": p.Type}).Warn("failed to load plugin")
|
||||||
}
|
}
|
||||||
if _, ok := required[id]; ok {
|
if _, ok := required[id]; ok {
|
||||||
return nil, fmt.Errorf("load required plugin %s: %w", id, err)
|
return nil, fmt.Errorf("load required plugin %s: %w", id, err)
|
||||||
@ -432,8 +432,7 @@ func (s *Server) Stop() {
|
|||||||
p := s.plugins[i]
|
p := s.plugins[i]
|
||||||
instance, err := p.Instance()
|
instance, err := p.Instance()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.L.WithError(err).WithField("id", p.Registration.URI()).
|
log.L.WithFields(log.Fields{"error": err, "id": p.Registration.URI()}).Error("could not get plugin instance")
|
||||||
Error("could not get plugin instance")
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
closer, ok := instance.(io.Closer)
|
closer, ok := instance.(io.Closer)
|
||||||
@ -441,8 +440,7 @@ func (s *Server) Stop() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := closer.Close(); err != nil {
|
if err := closer.Close(); err != nil {
|
||||||
log.L.WithError(err).WithField("id", p.Registration.URI()).
|
log.L.WithFields(log.Fields{"error": err, "id": p.Registration.URI()}).Error("failed to close plugin")
|
||||||
Error("failed to close plugin")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,7 +521,7 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]plugin.Regist
|
|||||||
if pp.Platform != "" {
|
if pp.Platform != "" {
|
||||||
p, err = platforms.Parse(pp.Platform)
|
p, err = platforms.Parse(pp.Platform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.G(ctx).WithError(err).WithField("plugin", name).Warn("skipping proxy platform with bad platform")
|
log.G(ctx).WithFields(log.Fields{"error": err, "plugin": name}).Warn("skipping proxy platform with bad platform")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p = platforms.DefaultSpec()
|
p = platforms.DefaultSpec()
|
||||||
|
Loading…
Reference in New Issue
Block a user