From f9bdd382ddf911c88b33d2bbd8f8aa9be2885a39 Mon Sep 17 00:00:00 2001 From: Francois Tur Date: Wed, 19 Sep 2018 05:11:24 -0400 Subject: Ensure Re-register of metrics variables after a reload (#2080) * - ensure plugins that use prometheus.MustRegister, re-register after reload - removing once.Do on the startup function was simplest way to do it. * - fix underscored names (advice of bot) * - tune existing UT for reload, and add a test verifying failing reload does not prevent correct registering for metrics * - ensure different ports for tests that can run in same time .. --- plugin/cache/handler.go | 3 --- plugin/cache/setup.go | 8 +++----- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'plugin/cache') diff --git a/plugin/cache/handler.go b/plugin/cache/handler.go index a44a4ec3b..2d608e8d3 100644 --- a/plugin/cache/handler.go +++ b/plugin/cache/handler.go @@ -3,7 +3,6 @@ package cache import ( "context" "math" - "sync" "time" "github.com/coredns/coredns/plugin" @@ -126,5 +125,3 @@ var ( Help: "The number responses that are not cached, because the reply is malformed.", }, []string{"server"}) ) - -var once sync.Once diff --git a/plugin/cache/setup.go b/plugin/cache/setup.go index 8464c27d9..d6052b162 100644 --- a/plugin/cache/setup.go +++ b/plugin/cache/setup.go @@ -34,11 +34,9 @@ func setup(c *caddy.Controller) error { }) c.OnStartup(func() error { - once.Do(func() { - metrics.MustRegister(c, - cacheSize, cacheHits, cacheMisses, - cachePrefetches, cacheDrops) - }) + metrics.MustRegister(c, + cacheSize, cacheHits, cacheMisses, + cachePrefetches, cacheDrops) return nil }) -- cgit v1.2.3