diff --git a/applyconfigurations/meta/v1/unstructured.go b/applyconfigurations/meta/v1/unstructured.go index 45349665..8368a4df 100644 --- a/applyconfigurations/meta/v1/unstructured.go +++ b/applyconfigurations/meta/v1/unstructured.go @@ -58,17 +58,14 @@ func (c *gvkParserCache) objectTypeForGVK(gvk schema.GroupVersionKind) (*typed.P c.mu.Lock() defer c.mu.Unlock() // if the ttl on the openAPISchema has expired, - // recheck the discovery client to see if the Open API schema has changed + // regenerate the gvk parser if time.Now().After(c.lastChecked.Add(openAPISchemaTTL)) { c.lastChecked = time.Now() - if c.discoveryClient.HasOpenAPISchemaChanged() { - // the schema has changed, regenerate the parser - parser, err := regenerateGVKParser(c.discoveryClient) - if err != nil { - return nil, err - } - c.gvkParser = parser + parser, err := regenerateGVKParser(c.discoveryClient) + if err != nil { + return nil, err } + c.gvkParser = parser } return c.gvkParser.Type(gvk), nil } diff --git a/discovery/cached/disk/cached_discovery.go b/discovery/cached/disk/cached_discovery.go index c44bdd02..6a35dcc6 100644 --- a/discovery/cached/disk/cached_discovery.go +++ b/discovery/cached/disk/cached_discovery.go @@ -240,11 +240,6 @@ func (d *CachedDiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error) { return d.delegate.OpenAPISchema() } -// HasOpenAPISchemaChanged checks wether the open API schema being served is cached or not. -func (d *CachedDiscoveryClient) HasOpenAPISchemaChanged() bool { - return d.delegate.HasOpenAPISchemaChanged() -} - // Fresh is supposed to tell the caller whether or not to retry if the cache // fails to find something (false = retry, true = no need to retry). func (d *CachedDiscoveryClient) Fresh() bool { diff --git a/discovery/cached/memory/memcache.go b/discovery/cached/memory/memcache.go index 5d54092f..9de389fa 100644 --- a/discovery/cached/memory/memcache.go +++ b/discovery/cached/memory/memcache.go @@ -149,10 +149,6 @@ func (d *memCacheClient) OpenAPISchema() (*openapi_v2.Document, error) { return d.delegate.OpenAPISchema() } -func (d *memCacheClient) HasOpenAPISchemaChanged() bool { - return d.delegate.HasOpenAPISchemaChanged() -} - func (d *memCacheClient) Fresh() bool { d.lock.RLock() defer d.lock.RUnlock() diff --git a/discovery/discovery_client.go b/discovery/discovery_client.go index 1aefdb86..87de3297 100644 --- a/discovery/discovery_client.go +++ b/discovery/discovery_client.go @@ -121,15 +121,10 @@ type ServerVersionInterface interface { ServerVersion() (*version.Info, error) } -// OpenAPISchemaInterface has a method to retrieve the open API schema -// and a method to check whether the open API schema has changed. +// OpenAPISchemaInterface has a method to retrieve the open API schema. type OpenAPISchemaInterface interface { // OpenAPISchema retrieves and parses the swagger API schema the server supports. OpenAPISchema() (*openapi_v2.Document, error) - - // HasOpenAPISchema changed checks whether the API schema being served - // by the apiserver is cached (and thus has not changed). - HasOpenAPISchemaChanged() bool } // DiscoveryClient implements the functions that discover server-supported API groups, @@ -424,12 +419,6 @@ func (d *DiscoveryClient) ServerVersion() (*version.Info, error) { return &info, nil } -// HasOpenAPISchemaChanged checks whether a HEAD request to openapi endpoint returns -// a 304 StatusNotModified meaning it has not changed. -func (d *DiscoveryClient) HasOpenAPISchemaChanged() bool { - return !d.restClient.Verb("HEAD").AbsPath("/openapi/v2").SetHeader("Accept", mimePb).Do(context.TODO()).FromCache() -} - // OpenAPISchema fetches the open api schema using a rest client and parses the proto. func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error) { data, err := d.restClient.Get().AbsPath("/openapi/v2").SetHeader("Accept", mimePb).Do(context.TODO()).Raw() diff --git a/discovery/fake/discovery.go b/discovery/fake/discovery.go index 9ed51dc7..f0cc2dbf 100644 --- a/discovery/fake/discovery.go +++ b/discovery/fake/discovery.go @@ -153,11 +153,6 @@ func (c *FakeDiscovery) OpenAPISchema() (*openapi_v2.Document, error) { return &openapi_v2.Document{}, nil } -// HasOpenAPISchemaChanged checks wether the open API schema being served is cached or not. -func (c *FakeDiscovery) HasOpenAPISchemaChanged() bool { - return true -} - // RESTClient returns a RESTClient that is used to communicate with API server // by this client implementation. func (c *FakeDiscovery) RESTClient() restclient.Interface { diff --git a/rest/request.go b/rest/request.go index 37d1a24e..e5a8100b 100644 --- a/rest/request.go +++ b/rest/request.go @@ -1140,21 +1140,12 @@ func (r *Request) transformResponse(resp *http.Response, req *http.Request) Resu } } - // store the X-From-Cache header so that we can - // return it as part of the result - var fromCache bool - xFromCacheHeader, ok := resp.Header["X-From-Cache"] - if ok { - fromCache = len(xFromCacheHeader) == 1 && xFromCacheHeader[0] == "1" - } - return Result{ body: body, contentType: contentType, statusCode: resp.StatusCode, decoder: decoder, warnings: handleWarnings(resp.Header, r.warningHandler), - fromCache: fromCache, } } @@ -1281,7 +1272,6 @@ type Result struct { contentType string err error statusCode int - fromCache bool decoder runtime.Decoder } @@ -1318,11 +1308,6 @@ func (r Result) Get() (runtime.Object, error) { return out, nil } -// FromCache returns whether the response was returned from the cache. -func (r Result) FromCache() bool { - return r.fromCache -} - // StatusCode returns the HTTP status code of the request. (Only valid if no // error was returned.) func (r Result) StatusCode(statusCode *int) Result {