Merge pull request #898 from parente/config-timeout-check-connectivity

Use config.CallTimeout() in APIClient
mine
Fernand Galiana 2020-10-26 20:38:18 -06:00 committed by GitHub
commit 6f1b18fba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 6 deletions

View File

@ -231,7 +231,7 @@ func (a *APIClient) CheckConnectivity() bool {
a.connOK = false a.connOK = false
return a.connOK return a.connOK
} }
cfg.Timeout = defaultCallTimeoutDuration cfg.Timeout = a.config.CallTimeout()
client, err := kubernetes.NewForConfig(cfg) client, err := kubernetes.NewForConfig(cfg)
if err != nil { if err != nil {
log.Error().Err(err).Msgf("Unable to connect to api server") log.Error().Err(err).Msgf("Unable to connect to api server")
@ -277,11 +277,7 @@ func (a *APIClient) HasMetrics() bool {
return flag return flag
} }
timeout, err := time.ParseDuration(*a.config.flags.Timeout) ctx, cancel := context.WithTimeout(context.Background(), a.config.CallTimeout())
if err != nil {
timeout = defaultCallTimeoutDuration
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel() defer cancel()
if _, err := dial.MetricsV1beta1().NodeMetricses().List(ctx, metav1.ListOptions{Limit: 1}); err == nil { if _, err := dial.MetricsV1beta1().NodeMetricses().List(ctx, metav1.ListOptions{Limit: 1}); err == nil {
flag = true flag = true