From 1a1bd6d0a7ee1b569c7de0f4fd78b9e5a6728d4e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 15 Nov 2023 13:18:33 +0100 Subject: [PATCH] runtime/v2/shim: 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 --- runtime/v2/shim/shim.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/v2/shim/shim.go b/runtime/v2/shim/shim.go index e66ca7f1d..87c053307 100644 --- a/runtime/v2/shim/shim.go +++ b/runtime/v2/shim/shim.go @@ -319,7 +319,7 @@ func run(ctx context.Context, manager Manager, config Config) error { for _, p := range registry.Graph(func(*plugin.Registration) bool { return false }) { pID := p.URI() - log.G(ctx).WithField("type", p.Type).Infof("loading plugin %q...", pID) + log.G(ctx).WithFields(log.Fields{"id": pID, "type": p.Type}).Info("loading plugin") initContext := plugin.NewContext( ctx, @@ -353,7 +353,7 @@ func run(ctx context.Context, manager Manager, config Config) error { instance, err := result.Instance() if err != nil { if plugin.IsSkipPlugin(err) { - log.G(ctx).WithError(err).WithField("type", p.Type).Infof("skip loading plugin %q...", pID) + log.G(ctx).WithFields(log.Fields{"id": pID, "type": p.Type, "error": err}).Info("skip loading plugin") continue } return fmt.Errorf("failed to load plugin %s: %w", pID, err)