Skip to content

Commit efb7500

Browse files
committed
xpum sidecar: add support to https
Signed-off-by: Tuomas Katila <[email protected]>
1 parent e34e93b commit efb7500

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

cmd/xpumanager_sidecar/main.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"bufio"
1919
"bytes"
2020
"context"
21+
"crypto/tls"
2122
"flag"
2223
"fmt"
2324
"io"
@@ -65,6 +66,7 @@ type xpuManagerSidecar struct {
6566
xpumPort uint64
6667
laneCount uint64
6768
allowSubdevicelessLinks bool
69+
useHTTPS bool
6870
}
6971

7072
func (e *invalidEntryErr) Error() string {
@@ -76,6 +78,14 @@ func (xms *xpuManagerSidecar) getMetricsDataFromXPUM() []byte {
7678
Timeout: 5 * time.Second,
7779
}
7880

81+
if xms.useHTTPS {
82+
customTransport := http.DefaultTransport.(*http.Transport).Clone()
83+
//#nosec
84+
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
85+
86+
client.Transport = customTransport
87+
}
88+
7989
ctx := context.Background()
8090

8191
req, err := http.NewRequestWithContext(ctx, http.MethodGet, xms.url, http.NoBody)
@@ -369,6 +379,7 @@ func main() {
369379
flag.Uint64Var(&xms.laneCount, "lane-count", 4, "minimum lane count for xelink")
370380
flag.StringVar(&xms.labelNamespace, "label-namespace", "gpu.intel.com", "namespace for the labels")
371381
flag.BoolVar(&xms.allowSubdevicelessLinks, "allow-subdeviceless-links", false, "allow xelinks that are not tied to subdevices (=1 tile GPUs)")
382+
flag.BoolVar(&xms.useHTTPS, "use-https", false, "Use HTTPS protocol to connect to xpumanager")
372383
klog.InitFlags(nil)
373384

374385
flag.Parse()
@@ -377,7 +388,12 @@ func main() {
377388
klog.Fatal("zero interval won't work, set it to at least 1")
378389
}
379390

380-
xms.url = fmt.Sprintf("http://127.0.0.1:%d/metrics", xms.xpumPort)
391+
protocol := "http"
392+
if xms.useHTTPS {
393+
protocol = "https"
394+
}
395+
396+
xms.url = fmt.Sprintf("%s://127.0.0.1:%d/metrics", protocol, xms.xpumPort)
381397

382398
keepIterating := true
383399

0 commit comments

Comments
 (0)