mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Simplify construction of /metrics request
This commit is contained in:
parent
daf0d8d14f
commit
e9973979d0
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user