mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Add deprecated metric for requests to deprecated custom resource versions
This commit is contained in:
parent
f03290c390
commit
a17e297245
@ -142,6 +142,9 @@ type crdInfo struct {
|
|||||||
spec *apiextensionsv1.CustomResourceDefinitionSpec
|
spec *apiextensionsv1.CustomResourceDefinitionSpec
|
||||||
acceptedNames *apiextensionsv1.CustomResourceDefinitionNames
|
acceptedNames *apiextensionsv1.CustomResourceDefinitionNames
|
||||||
|
|
||||||
|
// Deprecated per version
|
||||||
|
deprecated map[string]bool
|
||||||
|
|
||||||
// Warnings per version
|
// Warnings per version
|
||||||
warnings map[string][]string
|
warnings map[string][]string
|
||||||
|
|
||||||
@ -329,6 +332,7 @@ func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecated := crdInfo.deprecated[requestInfo.APIVersion]
|
||||||
for _, w := range crdInfo.warnings[requestInfo.APIVersion] {
|
for _, w := range crdInfo.warnings[requestInfo.APIVersion] {
|
||||||
warning.AddWarning(req.Context(), "", w)
|
warning.AddWarning(req.Context(), "", w)
|
||||||
}
|
}
|
||||||
@ -370,7 +374,7 @@ func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if handlerFunc != nil {
|
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 := genericfilters.WithWaitGroup(handlerFunc, longRunningFilter, crdInfo.waitGroup)
|
||||||
handler.ServeHTTP(w, req)
|
handler.ServeHTTP(w, req)
|
||||||
return
|
return
|
||||||
@ -620,6 +624,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
|
|||||||
storages := map[string]customresource.CustomResourceStorage{}
|
storages := map[string]customresource.CustomResourceStorage{}
|
||||||
statusScopes := map[string]*handlers.RequestScope{}
|
statusScopes := map[string]*handlers.RequestScope{}
|
||||||
scaleScopes := map[string]*handlers.RequestScope{}
|
scaleScopes := map[string]*handlers.RequestScope{}
|
||||||
|
deprecated := map[string]bool{}
|
||||||
warnings := map[string][]string{}
|
warnings := map[string][]string{}
|
||||||
|
|
||||||
equivalentResourceRegistry := runtime.NewEquivalentResourceRegistry()
|
equivalentResourceRegistry := runtime.NewEquivalentResourceRegistry()
|
||||||
@ -881,6 +886,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
|
|||||||
statusScopes[v.Name] = &statusScope
|
statusScopes[v.Name] = &statusScope
|
||||||
|
|
||||||
if v.Deprecated {
|
if v.Deprecated {
|
||||||
|
deprecated[v.Name] = true
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.WarningHeaders) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.WarningHeaders) {
|
||||||
if v.DeprecationWarning != nil {
|
if v.DeprecationWarning != nil {
|
||||||
warnings[v.Name] = append(warnings[v.Name], *v.DeprecationWarning)
|
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,
|
requestScopes: requestScopes,
|
||||||
scaleRequestScopes: scaleScopes,
|
scaleRequestScopes: scaleScopes,
|
||||||
statusRequestScopes: statusScopes,
|
statusRequestScopes: statusScopes,
|
||||||
|
deprecated: deprecated,
|
||||||
warnings: warnings,
|
warnings: warnings,
|
||||||
storageVersion: storageVersion,
|
storageVersion: storageVersion,
|
||||||
waitGroup: &utilwaitgroup.SafeWaitGroup{},
|
waitGroup: &utilwaitgroup.SafeWaitGroup{},
|
||||||
|
Loading…
Reference in New Issue
Block a user