diff --git a/CHANGELOG.md b/CHANGELOG.md index 44cc42b59..be49a5c04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.2 / 2016-08-24 + +* [BUGFIX] Clean up old targets after config reload. + ## 1.0.1 / 2016-07-21 * [BUGFIX] Exit with error on non-flag command-line arguments. diff --git a/VERSION b/VERSION index 7dea76edb..6d7de6e6a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.1 +1.0.2 diff --git a/retrieval/targetmanager.go b/retrieval/targetmanager.go index 56d847d1d..ca01cfdc9 100644 --- a/retrieval/targetmanager.go +++ b/retrieval/targetmanager.go @@ -180,8 +180,7 @@ type targetSet struct { mtx sync.RWMutex // Sets of targets by a source string that is unique across target providers. - tgroups map[string][]*Target - providers map[string]TargetProvider + tgroups map[string][]*Target scrapePool *scrapePool config *config.ScrapeConfig @@ -193,7 +192,6 @@ type targetSet struct { func newTargetSet(cfg *config.ScrapeConfig, app storage.SampleAppender) *targetSet { ts := &targetSet{ - tgroups: map[string][]*Target{}, scrapePool: newScrapePool(cfg, app), syncCh: make(chan struct{}, 1), config: cfg, @@ -272,6 +270,11 @@ func (ts *targetSet) runProviders(ctx context.Context, providers map[string]Targ } ctx, ts.cancelProviders = context.WithCancel(ctx) + // (Re-)create a fresh tgroups map to not keep stale targets around. We + // will retrieve all targets below anyway, so cleaning up everything is + // safe and doesn't inflict any additional cost. + ts.tgroups = map[string][]*Target{} + for name, prov := range providers { wg.Add(1)