Merge pull request #48016 from liggitt/api-versions-cache

Automatic merge from submit-queue (batch tested with PRs 47869, 48013, 48016, 48005)

Fix kubectl api-versions caching

xref https://github.com/kubernetes/kubectl/issues/41

The point of the `api-versions` and `version` commands is to ask the server for its API groups or versions, so we don't want to use cached data
pull/6/head
Kubernetes Submit Queue 2017-06-24 06:13:44 -07:00 committed by GitHub
commit a82c9ac2f2
2 changed files with 6 additions and 1 deletions

View File

@ -55,6 +55,9 @@ func RunApiVersions(f cmdutil.Factory, w io.Writer) error {
return err
}
// Always request fresh data from the server
discoveryclient.Invalidate()
groupList, err := discoveryclient.ServerGroups()
if err != nil {
return fmt.Errorf("Couldn't get available api versions from server: %v\n", err)

View File

@ -116,11 +116,13 @@ func RunVersion(f cmdutil.Factory, out io.Writer, cmd *cobra.Command) error {
func retrieveServerVersion(f cmdutil.Factory) (*apimachineryversion.Info, error) {
discoveryClient, err := f.DiscoveryClient()
if err != nil {
return nil, err
}
// Always request fresh data from the server
discoveryClient.Invalidate()
serverVersion, err := discoveryClient.ServerVersion()
if err != nil {
return nil, err