From e9973979d05c2a63cc491a962d0d6e7b8fff3f0a Mon Sep 17 00:00:00 2001 From: Mike Spreitzer Date: Mon, 6 Feb 2023 16:20:34 -0500 Subject: [PATCH] Simplify construction of /metrics request --- test/e2e/apimachinery/flowcontrol.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/test/e2e/apimachinery/flowcontrol.go b/test/e2e/apimachinery/flowcontrol.go index 6b44a2b7a4d..835c7b9ac3f 100644 --- a/test/e2e/apimachinery/flowcontrol.go +++ b/test/e2e/apimachinery/flowcontrol.go @@ -23,7 +23,6 @@ import ( "fmt" "io" "net/http" - "strings" "sync" "sync/atomic" "time" @@ -275,14 +274,7 @@ func createPriorityLevel(ctx context.Context, f *framework.Framework, priorityLe } func getPriorityLevelNominalConcurrency(ctx context.Context, c clientset.Interface, priorityLevelName string) (int32, error) { - req := c.CoreV1().RESTClient().Get() - reqURL := req.URL() - // That URL will end with "/api/v1", because we asked for CoreV1 above. - // Replace that part with "/metrics" and leave everything before that unchanged - // because that is what routes to the server. - reqPathOrig := reqURL.EscapedPath() - reqPathMetrics := strings.TrimSuffix(reqPathOrig, "api/v1") + "metrics" - req = req.RequestURI(reqPathMetrics) + req := c.CoreV1().RESTClient().Get().AbsPath("/metrics") resp, err := req.DoRaw(ctx) if err != nil { return 0, fmt.Errorf("error requesting metrics; request=%#+v, request.URL()=%s: %w", req, req.URL(), err)