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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-11-15 13:18:33 +01:00
parent 71fd85f5ed
commit 1a1bd6d0a7
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C

View File

@ -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)