diff --git a/internal/client/client.go b/internal/client/client.go index e43a561aa6..8f2957c668 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -458,10 +458,12 @@ func (a *APIClient) RestConfig() (*restclient.Config, error) { return a.config.RESTConfig() } +var NoConnectionToCachedDial = errors.New("no connection to cached dial") + // CachedDiscovery returns a cached discovery client. func (a *APIClient) CachedDiscovery() (*disk.CachedDiscoveryClient, error) { if !a.getConnOK() { - return nil, errors.New("no connection to cached dial") + return nil, NoConnectionToCachedDial } if c := a.getCachedClient(); c != nil { @@ -546,7 +548,11 @@ func (a *APIClient) SwitchContext(name string) error { return err } if err := a.invalidateCache(); err != nil { - return err + if err == NoConnectionToCachedDial { + log.Warn().Err(err).Msgf("No cache to invalidate") + } else { + return err + } } a.reset() ResetMetrics()