From 14b475d091e26d7497ad28eca93ef4d4e39bee28 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 16 Apr 2021 22:04:29 +0200 Subject: [PATCH] daemon/stats: fix notRunningErr / notFoundErr detected as unused (false positive) Also looks like a false positive, but given that these were basically testing for the `errdefs.Conflict` and `errdefs.NotFound` interfaces, I replaced these with those; daemon/stats/collector.go:154:6: type `notRunningErr` is unused (unused) type notRunningErr interface { ^ daemon/stats/collector.go:159:6: type `notFoundErr` is unused (unused) type notFoundErr interface { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 09191c093645f308e5fbce4275b5cdfefb048a67) Signed-off-by: Sebastiaan van Stijn --- daemon/stats/collector.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/daemon/stats/collector.go b/daemon/stats/collector.go index 5f1d84fe4f..4356661c40 100644 --- a/daemon/stats/collector.go +++ b/daemon/stats/collector.go @@ -7,6 +7,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/container" + "github.com/docker/docker/errdefs" "github.com/docker/docker/pkg/pubsub" "github.com/sirupsen/logrus" ) @@ -131,7 +132,7 @@ func (s *Collector) Run() { pair.publisher.Publish(*stats) - case notRunningErr, notFoundErr: + case errdefs.ErrConflict, errdefs.ErrNotFound: // publish empty stats containing only name and ID if not running or not found pair.publisher.Publish(types.StatsJSON{ Name: pair.container.Name, @@ -150,13 +151,3 @@ func (s *Collector) Run() { time.Sleep(s.interval) } } - -type notRunningErr interface { - error - Conflict() -} - -type notFoundErr interface { - error - NotFound() -}