From 22138541a23762bd079f963aacc9136ac4262f97 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 7 Dec 2023 15:41:46 +0100 Subject: [PATCH] tracing/plugin: newTracer: ignore context.Canceled errors on Close() Before this, containerd would always print an error when shutting down; ERRO[2023-12-07T14:35:00.070333131Z] failed to close plugin error="context canceled" id=io.containerd.internal.v1.tracing Signed-off-by: Sebastiaan van Stijn --- tracing/plugin/otlp.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tracing/plugin/otlp.go b/tracing/plugin/otlp.go index a7c4953e3..40c1d5b62 100644 --- a/tracing/plugin/otlp.go +++ b/tracing/plugin/otlp.go @@ -18,6 +18,7 @@ package plugin import ( "context" + "errors" "fmt" "io" "net/url" @@ -66,7 +67,7 @@ func init() { TraceSamplingRatio: 1.0, }, InitFn: func(ic *plugin.InitContext) (interface{}, error) { - //get TracingProcessorPlugin which is a dependency + // get TracingProcessorPlugin which is a dependency plugins, err := ic.GetByType(plugins.TracingProcessorPlugin) if err != nil { return nil, fmt.Errorf("failed to get tracing processors: %w", err) @@ -178,13 +179,12 @@ func newTracer(ctx context.Context, config *TraceConfig, procs []trace.SpanProce return &closer{close: func() error { for _, p := range procs { - if err := p.Shutdown(ctx); err != nil { + if err := p.Shutdown(ctx); err != nil && !errors.Is(err, context.Canceled) { return err } } return nil }}, nil - } // Returns a composite TestMap propagator