Refactor http server and register leaderelection health check
- Needed to start the http server outside of pkg/metric - We needed this because we want to add other endpoints to the server Signed-off-by: Grant Griffiths <ggriffiths@purestorage.com>
This commit is contained in:
@@ -19,7 +19,7 @@ package common_controller
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
"net/http"
|
||||
"reflect"
|
||||
sysruntime "runtime"
|
||||
"strconv"
|
||||
@@ -29,6 +29,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
|
||||
crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
|
||||
clientset "github.com/kubernetes-csi/external-snapshotter/client/v4/clientset/versioned"
|
||||
"github.com/kubernetes-csi/external-snapshotter/client/v4/clientset/versioned/fake"
|
||||
@@ -737,9 +739,14 @@ func newTestController(kubeClient kubernetes.Interface, clientset clientset.Inte
|
||||
|
||||
coreFactory := coreinformers.NewSharedInformerFactory(kubeClient, utils.NoResyncPeriodFunc())
|
||||
metricsManager := metrics.NewMetricsManager()
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
metricsManager.StartMetricsEndpoint("/metrics", "localhost:0", nil, wg)
|
||||
mux := http.NewServeMux()
|
||||
metricsManager.PrepareMetricsPath(mux, "/metrics", nil)
|
||||
go func() {
|
||||
err := http.ListenAndServe("localhost:0", mux)
|
||||
if err != nil {
|
||||
t.Errorf("failed to prepare metrics path: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
ctrl := NewCSISnapshotCommonController(
|
||||
clientset,
|
||||
|
Reference in New Issue
Block a user