@@ -58,7 +58,6 @@ type Discoverer struct {
58
58
log logr.Logger
59
59
manager * discovery.Manager
60
60
close chan struct {}
61
- mtxScrape sync.Mutex // Guards the fields below.
62
61
configsMap map [allocatorWatcher.EventSource ][]* promconfig.ScrapeConfig
63
62
hook discoveryHook
64
63
scrapeConfigsHash hash.Hash
@@ -140,9 +139,7 @@ func (m *Discoverer) Run() error {
140
139
141
140
// UpdateTsets updates the target sets to be scraped.
142
141
func (m * Discoverer ) UpdateTsets (tsets map [string ][]* targetgroup.Group ) {
143
- m .mtxScrape .Lock ()
144
142
m .targetSets = tsets
145
- m .mtxScrape .Unlock ()
146
143
}
147
144
148
145
// reloader triggers a reload of the scrape configs at regular intervals.
@@ -172,13 +169,13 @@ func (m *Discoverer) reloader() {
172
169
// Reload triggers a reload of the scrape configs.
173
170
// This will process the target groups and update the targets concurrently.
174
171
func (m * Discoverer ) Reload () {
175
- m . mtxScrape . Lock ()
172
+ targetSets := m . targetSets
176
173
var wg sync.WaitGroup
177
174
targets := map [string ]* Item {}
178
175
timer := prometheus .NewTimer (processTargetsDuration )
179
176
defer timer .ObserveDuration ()
180
177
181
- for jobName , groups := range m . targetSets {
178
+ for jobName , groups := range targetSets {
182
179
wg .Add (1 )
183
180
// Run the sync in parallel as these take a while and at high load can't catch up.
184
181
go func (jobName string , groups []* targetgroup.Group ) {
@@ -191,7 +188,6 @@ func (m *Discoverer) Reload() {
191
188
wg .Done ()
192
189
}(jobName , groups )
193
190
}
194
- m .mtxScrape .Unlock ()
195
191
wg .Wait ()
196
192
m .processTargetsCallBack (targets )
197
193
}
0 commit comments