mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
lib/promscrape/discovery/kubernetes: fix deadlock in startWatcherForURL
reloadObjects must be called without holding aw.mu lock
This commit is contained in:
parent
b523e0369c
commit
68a0f5ce12
1 changed files with 4 additions and 2 deletions
|
@ -217,14 +217,16 @@ func (aw *apiWatcher) startWatchersForRole(role string) {
|
|||
|
||||
func (aw *apiWatcher) startWatcherForURL(role, apiURL string, parseObject parseObjectFunc, parseObjectList parseObjectListFunc) {
|
||||
aw.mu.Lock()
|
||||
defer aw.mu.Unlock()
|
||||
if aw.watchersByURL[apiURL] != nil {
|
||||
// Watcher for the given path already exists.
|
||||
aw.mu.Unlock()
|
||||
return
|
||||
}
|
||||
uw := aw.newURLWatcher(role, apiURL, parseObject, parseObjectList)
|
||||
resourceVersion := uw.reloadObjects()
|
||||
aw.watchersByURL[apiURL] = uw
|
||||
aw.mu.Unlock()
|
||||
|
||||
resourceVersion := uw.reloadObjects()
|
||||
go func() {
|
||||
uw.watchForUpdates(resourceVersion)
|
||||
aw.mu.Lock()
|
||||
|
|
Loading…
Reference in a new issue