diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go index 65745eef55f..36cc1982163 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go @@ -142,6 +142,9 @@ type crdInfo struct { spec *apiextensionsv1.CustomResourceDefinitionSpec acceptedNames *apiextensionsv1.CustomResourceDefinitionNames + // Deprecated per version + deprecated map[string]bool + // Warnings per version warnings map[string][]string @@ -329,6 +332,7 @@ func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } + deprecated := crdInfo.deprecated[requestInfo.APIVersion] for _, w := range crdInfo.warnings[requestInfo.APIVersion] { warning.AddWarning(req.Context(), "", w) } @@ -370,7 +374,7 @@ func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { } if handlerFunc != nil { - handlerFunc = metrics.InstrumentHandlerFunc(verb, requestInfo.APIGroup, requestInfo.APIVersion, resource, subresource, scope, metrics.APIServerComponent, false, "", handlerFunc) + handlerFunc = metrics.InstrumentHandlerFunc(verb, requestInfo.APIGroup, requestInfo.APIVersion, resource, subresource, scope, metrics.APIServerComponent, deprecated, "", handlerFunc) handler := genericfilters.WithWaitGroup(handlerFunc, longRunningFilter, crdInfo.waitGroup) handler.ServeHTTP(w, req) return @@ -620,6 +624,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd storages := map[string]customresource.CustomResourceStorage{} statusScopes := map[string]*handlers.RequestScope{} scaleScopes := map[string]*handlers.RequestScope{} + deprecated := map[string]bool{} warnings := map[string][]string{} equivalentResourceRegistry := runtime.NewEquivalentResourceRegistry() @@ -881,6 +886,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd statusScopes[v.Name] = &statusScope if v.Deprecated { + deprecated[v.Name] = true if utilfeature.DefaultFeatureGate.Enabled(features.WarningHeaders) { if v.DeprecationWarning != nil { warnings[v.Name] = append(warnings[v.Name], *v.DeprecationWarning) @@ -898,6 +904,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd requestScopes: requestScopes, scaleRequestScopes: scaleScopes, statusRequestScopes: statusScopes, + deprecated: deprecated, warnings: warnings, storageVersion: storageVersion, waitGroup: &utilwaitgroup.SafeWaitGroup{},