diff --git a/internal/client/client.go b/internal/client/client.go index e43a561aa6..67cf12655e 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 { @@ -545,7 +547,10 @@ func (a *APIClient) SwitchContext(name string) error { if err := a.config.SwitchContext(name); err != nil { return err } - if err := a.invalidateCache(); err != nil { + err := a.invalidateCache() + if err == NoConnectionToCachedDial { + log.Warn().Err(err).Msgf("No cache to invalidate") + } else if err != nil { return err } a.reset()