mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-10 15:14:09 +00:00
lib/promscrape/discovery/kubernetes: avoid possible panic if given caFile under kubernetes.SDConfig.HTTPClientConfig is not exist (#5243)
follow up d5a599badc
This commit is contained in:
parent
632d788b63
commit
90427abc65
2 changed files with 5 additions and 0 deletions
|
@ -90,6 +90,10 @@ func newAPIConfig(sdc *SDConfig, baseDir string, swcFunc ScrapeWorkConstructorFu
|
|||
for strings.HasSuffix(apiServer, "/") {
|
||||
apiServer = apiServer[:len(apiServer)-1]
|
||||
}
|
||||
// pre-check tls config
|
||||
if _, err := ac.NewTLSConfig(); err != nil {
|
||||
return nil, fmt.Errorf("cannot initialize tls config: %w", err)
|
||||
}
|
||||
aw := newAPIWatcher(apiServer, ac, sdc, swcFunc)
|
||||
cfg := &apiConfig{
|
||||
aw: aw,
|
||||
|
|
|
@ -234,6 +234,7 @@ func newGroupWatcher(apiServer string, ac *promauth.Config, namespaces []string,
|
|||
proxy = http.ProxyURL(proxyURL)
|
||||
}
|
||||
tlsConfig, err := ac.NewTLSConfig()
|
||||
// we should always check tlsconfig in advance to avoid panic here
|
||||
if err != nil {
|
||||
logger.Panicf("FATAL: cannot initialize tls config: %s", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue