mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
lib/promscrape/discovery/kubernetes: simplify the reload logic for urlWatcher.objectsByKey
This commit is contained in:
parent
0f54c0121b
commit
c507faec0b
@ -443,20 +443,18 @@ func (uw *urlWatcher) reloadObjects() string {
|
|||||||
uw.gw.mu.Lock()
|
uw.gw.mu.Lock()
|
||||||
var updated, removed, added int
|
var updated, removed, added int
|
||||||
for key := range uw.objectsByKey {
|
for key := range uw.objectsByKey {
|
||||||
if o, ok := objectsByKey[key]; ok {
|
if _, ok := objectsByKey[key]; ok {
|
||||||
uw.objectsByKey[key] = o
|
|
||||||
updated++
|
updated++
|
||||||
} else {
|
} else {
|
||||||
delete(uw.objectsByKey, key)
|
|
||||||
removed++
|
removed++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for key, o := range objectsByKey {
|
for key := range objectsByKey {
|
||||||
if _, ok := uw.objectsByKey[key]; !ok {
|
if _, ok := uw.objectsByKey[key]; !ok {
|
||||||
uw.objectsByKey[key] = o
|
|
||||||
added++
|
added++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uw.objectsByKey = objectsByKey
|
||||||
uw.reloadScrapeWorksForAPIWatchersLocked(uw.aws)
|
uw.reloadScrapeWorksForAPIWatchersLocked(uw.aws)
|
||||||
uw.gw.mu.Unlock()
|
uw.gw.mu.Unlock()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user