Skip to content

Commit

Permalink
Merge pull request #110091 from azylinski/automated-cherry-pick-of-#1…
Browse files Browse the repository at this point in the history
…10009-upstream-release-1.23

Automated cherry pick of #110009: Fix requests scope classification

Kubernetes-commit: 3ed06b71e744dd2163d152b7bfbb08cb48509c24
  • Loading branch information
k8s-publishing-bot committed May 20, 2022
2 parents 495117a + 3faef53 commit 681b529
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/endpoints/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ func InstrumentHandlerFunc(verb, group, version, resource, subresource, scope, c

// CleanScope returns the scope of the request.
func CleanScope(requestInfo *request.RequestInfo) string {
if requestInfo.Name != "" {
if requestInfo.Name != "" || requestInfo.Verb == "create" {
return "resource"
}
if requestInfo.Namespace != "" {
Expand Down
9 changes: 9 additions & 0 deletions pkg/endpoints/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ func TestCleanScope(t *testing.T) {
},
expectedScope: "resource",
},
{
name: "POST resource scope",
requestInfo: &request.RequestInfo{
Verb: "create",
Namespace: "my-namespace",
IsResourceRequest: false,
},
expectedScope: "resource",
},
{
name: "namespace scope",
requestInfo: &request.RequestInfo{
Expand Down

0 comments on commit 681b529

Please sign in to comment.