Skip to content

Commit 5d9d16d

Browse files
authored
Add a new server with localhost handlers (#2635)
* add a new server with localhost handlers * remove server pointer for handlers * address linter issues * remove AKS localhost handlers * remove AKS localhost handlers of comments * fix a linter issue
1 parent 40b8446 commit 5d9d16d

File tree

6 files changed

+91
-47
lines changed

6 files changed

+91
-47
lines changed

cns/restserver/api.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,8 @@ func (service *HTTPRestService) getNetworkContainerByID(w http.ResponseWriter, r
877877
}
878878

879879
// the function is to get all network containers based on given OrchestratorContext
880-
func (service *HTTPRestService) getAllNetworkContainers(w http.ResponseWriter, r *http.Request) {
881-
logger.Printf("[Azure CNS] getAllNetworkContainers")
880+
func (service *HTTPRestService) GetAllNetworkContainers(w http.ResponseWriter, r *http.Request) {
881+
logger.Printf("[Azure CNS] GetAllNetworkContainers")
882882

883883
var req cns.GetNetworkContainerRequest
884884

@@ -919,8 +919,8 @@ func (service *HTTPRestService) getAllNetworkContainers(w http.ResponseWriter, r
919919
logger.Response(service.Name, resp, resp.Response.ReturnCode, err)
920920
}
921921

922-
func (service *HTTPRestService) getNetworkContainerByOrchestratorContext(w http.ResponseWriter, r *http.Request) {
923-
logger.Printf("[Azure CNS] getNetworkContainerByOrchestratorContext")
922+
func (service *HTTPRestService) GetNetworkContainerByOrchestratorContext(w http.ResponseWriter, r *http.Request) {
923+
logger.Printf("[Azure CNS] GetNetworkContainerByOrchestratorContext")
924924

925925
var req cns.GetNetworkContainerRequest
926926

@@ -1381,8 +1381,8 @@ func (service *HTTPRestService) unpublishNetworkContainer(w http.ResponseWriter,
13811381
logger.Response(service.Name, resp, resp.Response.ReturnCode, nil)
13821382
}
13831383

1384-
func (service *HTTPRestService) createHostNCApipaEndpoint(w http.ResponseWriter, r *http.Request) {
1385-
logger.Printf("[Azure-CNS] createHostNCApipaEndpoint")
1384+
func (service *HTTPRestService) CreateHostNCApipaEndpoint(w http.ResponseWriter, r *http.Request) {
1385+
logger.Printf("[Azure-CNS] CreateHostNCApipaEndpoint")
13861386

13871387
var (
13881388
err error
@@ -1440,8 +1440,8 @@ func (service *HTTPRestService) createHostNCApipaEndpoint(w http.ResponseWriter,
14401440
logger.Response(service.Name, response, response.Response.ReturnCode, err)
14411441
}
14421442

1443-
func (service *HTTPRestService) deleteHostNCApipaEndpoint(w http.ResponseWriter, r *http.Request) {
1444-
logger.Printf("[Azure-CNS] deleteHostNCApipaEndpoint")
1443+
func (service *HTTPRestService) DeleteHostNCApipaEndpoint(w http.ResponseWriter, r *http.Request) {
1444+
logger.Printf("[Azure-CNS] DeleteHostNCApipaEndpoint")
14451445

14461446
var (
14471447
err error

cns/restserver/ipam.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func (service *HTTPRestService) requestIPConfigHandlerHelper(ctx context.Context
9191
}, nil
9292
}
9393

94-
// requestIPConfigHandler requests an IPConfig from the CNS state
95-
func (service *HTTPRestService) requestIPConfigHandler(w http.ResponseWriter, r *http.Request) {
94+
// RequestIPConfigHandler requests an IPConfig from the CNS state
95+
func (service *HTTPRestService) RequestIPConfigHandler(w http.ResponseWriter, r *http.Request) {
9696
var ipconfigRequest cns.IPConfigRequest
9797
err := service.Listener.Decode(w, r, &ipconfigRequest)
9898
operationName := "requestIPConfigHandler"
@@ -166,8 +166,8 @@ func (service *HTTPRestService) requestIPConfigHandler(w http.ResponseWriter, r
166166
logger.ResponseEx(service.Name+operationName, ipconfigsRequest, reserveResp, reserveResp.Response.ReturnCode, err)
167167
}
168168

169-
// requestIPConfigsHandler requests multiple IPConfigs from the CNS state
170-
func (service *HTTPRestService) requestIPConfigsHandler(w http.ResponseWriter, r *http.Request) {
169+
// RequestIPConfigsHandler requests multiple IPConfigs from the CNS state
170+
func (service *HTTPRestService) RequestIPConfigsHandler(w http.ResponseWriter, r *http.Request) {
171171
var ipconfigsRequest cns.IPConfigsRequest
172172
err := service.Listener.Decode(w, r, &ipconfigsRequest)
173173
operationName := "requestIPConfigsHandler"
@@ -180,7 +180,7 @@ func (service *HTTPRestService) requestIPConfigsHandler(w http.ResponseWriter, r
180180
// Check if IPConfigsHandlerMiddleware is set
181181
if service.IPConfigsHandlerMiddleware != nil {
182182
// Wrap the default datapath handlers with the middleware
183-
wrappedHandler := service.IPConfigsHandlerMiddleware.IPConfigsRequestHandlerWrapper(service.requestIPConfigHandlerHelper, service.releaseIPConfigHandlerHelper)
183+
wrappedHandler := service.IPConfigsHandlerMiddleware.IPConfigsRequestHandlerWrapper(service.requestIPConfigHandlerHelper, service.ReleaseIPConfigHandlerHelper)
184184
ipConfigsResp, err = wrappedHandler(r.Context(), ipconfigsRequest)
185185
} else {
186186
ipConfigsResp, err = service.requestIPConfigHandlerHelper(r.Context(), ipconfigsRequest) // nolint:contextcheck // appease linter
@@ -260,8 +260,8 @@ func (service *HTTPRestService) updateEndpointState(ipconfigsRequest cns.IPConfi
260260
return nil
261261
}
262262

263-
// releaseIPConfigHandlerHelper validates the request and removes the endpoint associated with the pod
264-
func (service *HTTPRestService) releaseIPConfigHandlerHelper(ctx context.Context, ipconfigsRequest cns.IPConfigsRequest) (*cns.IPConfigsResponse, error) {
263+
// ReleaseIPConfigHandlerHelper validates the request and removes the endpoint associated with the pod
264+
func (service *HTTPRestService) ReleaseIPConfigHandlerHelper(ctx context.Context, ipconfigsRequest cns.IPConfigsRequest) (*cns.IPConfigsResponse, error) {
265265
podInfo, returnCode, returnMessage := service.validateIPConfigsRequest(ctx, ipconfigsRequest)
266266
if returnCode != types.Success {
267267
return &cns.IPConfigsResponse{
@@ -280,7 +280,7 @@ func (service *HTTPRestService) releaseIPConfigHandlerHelper(ctx context.Context
280280
Message: err.Error(),
281281
},
282282
}
283-
return resp, fmt.Errorf("releaseIPConfigHandlerHelper remove endpoint state failed : %v, release IP config info %+v", resp.Response.Message, ipconfigsRequest) //nolint:goerr113 // return error
283+
return resp, fmt.Errorf("ReleaseIPConfigHandlerHelper remove endpoint state failed : %v, release IP config info %+v", resp.Response.Message, ipconfigsRequest) //nolint:goerr113 // return error
284284
}
285285
}
286286

@@ -290,7 +290,7 @@ func (service *HTTPRestService) releaseIPConfigHandlerHelper(ctx context.Context
290290
ReturnCode: types.UnexpectedError,
291291
Message: err.Error(),
292292
},
293-
}, fmt.Errorf("releaseIPConfigHandlerHelper releaseIPConfigs failed : %v, release IP config info %+v", returnMessage, ipconfigsRequest) //nolint:goerr113 // return error
293+
}, fmt.Errorf("ReleaseIPConfigHandlerHelper releaseIPConfigs failed : %v, release IP config info %+v", returnMessage, ipconfigsRequest) //nolint:goerr113 // return error
294294
}
295295

296296
return &cns.IPConfigsResponse{
@@ -301,8 +301,8 @@ func (service *HTTPRestService) releaseIPConfigHandlerHelper(ctx context.Context
301301
}, nil
302302
}
303303

304-
// releaseIPConfigHandler frees the IP assigned to a pod from CNS
305-
func (service *HTTPRestService) releaseIPConfigHandler(w http.ResponseWriter, r *http.Request) {
304+
// ReleaseIPConfigHandler frees the IP assigned to a pod from CNS
305+
func (service *HTTPRestService) ReleaseIPConfigHandler(w http.ResponseWriter, r *http.Request) {
306306
var ipconfigRequest cns.IPConfigRequest
307307
err := service.Listener.Decode(w, r, &ipconfigRequest)
308308
logger.Request(service.Name+"releaseIPConfigHandler", ipconfigRequest, err)
@@ -342,7 +342,7 @@ func (service *HTTPRestService) releaseIPConfigHandler(w http.ResponseWriter, r
342342
Ifname: ipconfigRequest.Ifname,
343343
}
344344

345-
resp, err := service.releaseIPConfigHandlerHelper(r.Context(), ipconfigsRequest)
345+
resp, err := service.ReleaseIPConfigHandlerHelper(r.Context(), ipconfigsRequest)
346346
if err != nil {
347347
w.Header().Set(cnsReturnCode, resp.Response.ReturnCode.String())
348348
err = service.Listener.Encode(w, &resp)
@@ -354,8 +354,8 @@ func (service *HTTPRestService) releaseIPConfigHandler(w http.ResponseWriter, r
354354
logger.ResponseEx(service.Name, ipconfigRequest, resp, resp.Response.ReturnCode, err)
355355
}
356356

357-
// releaseIPConfigsHandler frees multiple IPConfigs from the CNS state
358-
func (service *HTTPRestService) releaseIPConfigsHandler(w http.ResponseWriter, r *http.Request) {
357+
// ReleaseIPConfigsHandler frees multiple IPConfigs from the CNS state
358+
func (service *HTTPRestService) ReleaseIPConfigsHandler(w http.ResponseWriter, r *http.Request) {
359359
var ipconfigsRequest cns.IPConfigsRequest
360360
err := service.Listener.Decode(w, r, &ipconfigsRequest)
361361
logger.Request(service.Name+"releaseIPConfigsHandler", ipconfigsRequest, err)
@@ -371,7 +371,7 @@ func (service *HTTPRestService) releaseIPConfigsHandler(w http.ResponseWriter, r
371371
return
372372
}
373373

374-
resp, err := service.releaseIPConfigHandlerHelper(r.Context(), ipconfigsRequest)
374+
resp, err := service.ReleaseIPConfigHandlerHelper(r.Context(), ipconfigsRequest)
375375
if err != nil {
376376
w.Header().Set(cnsReturnCode, resp.Response.ReturnCode.String())
377377
err = service.Listener.Encode(w, &resp)
@@ -560,7 +560,7 @@ func (service *HTTPRestService) GetPodIPConfigState() map[string]cns.IPConfigura
560560
return podIPConfigState
561561
}
562562

563-
func (service *HTTPRestService) handleDebugPodContext(w http.ResponseWriter, r *http.Request) {
563+
func (service *HTTPRestService) HandleDebugPodContext(w http.ResponseWriter, r *http.Request) { //nolint
564564
service.RLock()
565565
defer service.RUnlock()
566566
resp := cns.GetPodContextResponse{
@@ -570,7 +570,7 @@ func (service *HTTPRestService) handleDebugPodContext(w http.ResponseWriter, r *
570570
logger.Response(service.Name, resp, resp.Response.ReturnCode, err)
571571
}
572572

573-
func (service *HTTPRestService) handleDebugRestData(w http.ResponseWriter, r *http.Request) {
573+
func (service *HTTPRestService) HandleDebugRestData(w http.ResponseWriter, r *http.Request) { //nolint
574574
service.RLock()
575575
defer service.RUnlock()
576576
resp := GetHTTPServiceDataResponse{
@@ -583,7 +583,7 @@ func (service *HTTPRestService) handleDebugRestData(w http.ResponseWriter, r *ht
583583
logger.Response(service.Name, resp, resp.Response.ReturnCode, err)
584584
}
585585

586-
func (service *HTTPRestService) handleDebugIPAddresses(w http.ResponseWriter, r *http.Request) {
586+
func (service *HTTPRestService) HandleDebugIPAddresses(w http.ResponseWriter, r *http.Request) {
587587
var req cns.GetIPAddressesRequest
588588
if err := service.Listener.Decode(w, r, &req); err != nil {
589589
resp := cns.GetIPAddressStatusResponse{

cns/restserver/ipam_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ func TestIPAMReleaseSWIFTV2PodIPSuccess(t *testing.T) {
15601560
req.DesiredIPAddresses[0] = testIP1
15611561
req.DesiredIPAddresses[1] = testIP1v6
15621562
// Requesting release ip config for SWIFT V2 pod when mtpnc is not ready, should be a no-op
1563-
_, err := svc.releaseIPConfigHandlerHelper(context.TODO(), req)
1563+
_, err := svc.ReleaseIPConfigHandlerHelper(context.TODO(), req)
15641564
if err != nil {
15651565
t.Fatalf("Expected not to fail when requesting to release SWIFT V2 pod due to MTPNC not ready")
15661566
}
@@ -1611,7 +1611,7 @@ func TestIPAMGetK8sSWIFTv2IPSuccess(t *testing.T) {
16111611
req.DesiredIPAddresses[0] = testIP1
16121612
req.DesiredIPAddresses[1] = testIP1v6
16131613

1614-
wrappedHandler := svc.IPConfigsHandlerMiddleware.IPConfigsRequestHandlerWrapper(svc.requestIPConfigHandlerHelper, svc.releaseIPConfigHandlerHelper)
1614+
wrappedHandler := svc.IPConfigsHandlerMiddleware.IPConfigsRequestHandlerWrapper(svc.requestIPConfigHandlerHelper, svc.ReleaseIPConfigHandlerHelper)
16151615
resp, err := wrappedHandler(context.TODO(), req)
16161616
if err != nil {
16171617
t.Fatalf("Expected to not fail requesting IPs: %+v", err)
@@ -1667,7 +1667,7 @@ func TestIPAMGetK8sSWIFTv2IPFailure(t *testing.T) {
16671667
req.DesiredIPAddresses = make([]string, 2)
16681668
req.DesiredIPAddresses[0] = testIP1
16691669
req.DesiredIPAddresses[1] = testIP1v6
1670-
wrappedHandler := svc.IPConfigsHandlerMiddleware.IPConfigsRequestHandlerWrapper(svc.requestIPConfigHandlerHelper, svc.releaseIPConfigHandlerHelper)
1670+
wrappedHandler := svc.IPConfigsHandlerMiddleware.IPConfigsRequestHandlerWrapper(svc.requestIPConfigHandlerHelper, svc.ReleaseIPConfigHandlerHelper)
16711671
_, err := wrappedHandler(context.TODO(), req)
16721672
if err == nil {
16731673
t.Fatalf("Expected failing requesting IPs due to MTPNC not ready")

cns/restserver/metrics.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const (
2020
)
2121

2222
var (
23-
httpRequestLatency = prometheus.NewHistogramVec(
23+
HTTPRequestLatency = prometheus.NewHistogramVec(
2424
prometheus.HistogramOpts{
2525
Name: "http_request_latency_seconds",
2626
Help: "Request latency in seconds by endpoint, verb, and response code.",
@@ -106,7 +106,7 @@ var (
106106

107107
func init() {
108108
metrics.Registry.MustRegister(
109-
httpRequestLatency,
109+
HTTPRequestLatency,
110110
ipAssignmentLatency,
111111
ipConfigStatusStateTransitionTime,
112112
syncHostNCVersionCount,
@@ -123,7 +123,7 @@ func init() {
123123
// Hard tto do with middleware unless we derserialize the responses but making it an explit header works around it.
124124
// if that doesn't work we could have a separate countervec just for response codes.
125125

126-
func newHandlerFuncWithHistogram(handler http.HandlerFunc, histogram *prometheus.HistogramVec) http.HandlerFunc {
126+
func NewHandlerFuncWithHistogram(handler http.HandlerFunc, histogram *prometheus.HistogramVec) http.HandlerFunc {
127127
return func(w http.ResponseWriter, req *http.Request) {
128128
start := time.Now()
129129
defer func() {

cns/restserver/restserver.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,25 +249,25 @@ func (service *HTTPRestService) Init(config *common.ServiceConfig) error {
249249
listener.AddHandler(cns.DeleteNetworkContainer, service.deleteNetworkContainer)
250250
listener.AddHandler(cns.GetInterfaceForContainer, service.getInterfaceForContainer)
251251
listener.AddHandler(cns.SetOrchestratorType, service.setOrchestratorType)
252-
listener.AddHandler(cns.GetNetworkContainerByOrchestratorContext, service.getNetworkContainerByOrchestratorContext)
253-
listener.AddHandler(cns.GetAllNetworkContainers, service.getAllNetworkContainers)
252+
listener.AddHandler(cns.GetNetworkContainerByOrchestratorContext, service.GetNetworkContainerByOrchestratorContext)
253+
listener.AddHandler(cns.GetAllNetworkContainers, service.GetAllNetworkContainers)
254254
listener.AddHandler(cns.AttachContainerToNetwork, service.attachNetworkContainerToNetwork)
255255
listener.AddHandler(cns.DetachContainerFromNetwork, service.detachNetworkContainerFromNetwork)
256256
listener.AddHandler(cns.CreateHnsNetworkPath, service.createHnsNetwork)
257257
listener.AddHandler(cns.DeleteHnsNetworkPath, service.deleteHnsNetwork)
258258
listener.AddHandler(cns.NumberOfCPUCoresPath, service.getNumberOfCPUCores)
259-
listener.AddHandler(cns.CreateHostNCApipaEndpointPath, service.createHostNCApipaEndpoint)
260-
listener.AddHandler(cns.DeleteHostNCApipaEndpointPath, service.deleteHostNCApipaEndpoint)
259+
listener.AddHandler(cns.CreateHostNCApipaEndpointPath, service.CreateHostNCApipaEndpoint)
260+
listener.AddHandler(cns.DeleteHostNCApipaEndpointPath, service.DeleteHostNCApipaEndpoint)
261261
listener.AddHandler(cns.PublishNetworkContainer, service.publishNetworkContainer)
262262
listener.AddHandler(cns.UnpublishNetworkContainer, service.unpublishNetworkContainer)
263-
listener.AddHandler(cns.RequestIPConfig, newHandlerFuncWithHistogram(service.requestIPConfigHandler, httpRequestLatency))
264-
listener.AddHandler(cns.RequestIPConfigs, newHandlerFuncWithHistogram(service.requestIPConfigsHandler, httpRequestLatency))
265-
listener.AddHandler(cns.ReleaseIPConfig, newHandlerFuncWithHistogram(service.releaseIPConfigHandler, httpRequestLatency))
266-
listener.AddHandler(cns.ReleaseIPConfigs, newHandlerFuncWithHistogram(service.releaseIPConfigsHandler, httpRequestLatency))
263+
listener.AddHandler(cns.RequestIPConfig, NewHandlerFuncWithHistogram(service.RequestIPConfigHandler, HTTPRequestLatency))
264+
listener.AddHandler(cns.RequestIPConfigs, NewHandlerFuncWithHistogram(service.RequestIPConfigsHandler, HTTPRequestLatency))
265+
listener.AddHandler(cns.ReleaseIPConfig, NewHandlerFuncWithHistogram(service.ReleaseIPConfigHandler, HTTPRequestLatency))
266+
listener.AddHandler(cns.ReleaseIPConfigs, NewHandlerFuncWithHistogram(service.ReleaseIPConfigsHandler, HTTPRequestLatency))
267267
listener.AddHandler(cns.NmAgentSupportedApisPath, service.nmAgentSupportedApisHandler)
268-
listener.AddHandler(cns.PathDebugIPAddresses, service.handleDebugIPAddresses)
269-
listener.AddHandler(cns.PathDebugPodContext, service.handleDebugPodContext)
270-
listener.AddHandler(cns.PathDebugRestData, service.handleDebugRestData)
268+
listener.AddHandler(cns.PathDebugIPAddresses, service.HandleDebugIPAddresses)
269+
listener.AddHandler(cns.PathDebugPodContext, service.HandleDebugPodContext)
270+
listener.AddHandler(cns.PathDebugRestData, service.HandleDebugRestData)
271271
listener.AddHandler(cns.NetworkContainersURLPath, service.getOrRefreshNetworkContainers)
272272
listener.AddHandler(cns.GetHomeAz, service.getHomeAz)
273273
listener.AddHandler(cns.EndpointPath, service.EndpointHandlerAPI)
@@ -284,15 +284,15 @@ func (service *HTTPRestService) Init(config *common.ServiceConfig) error {
284284
listener.AddHandler(cns.V2Prefix+cns.DeleteNetworkContainer, service.deleteNetworkContainer)
285285
listener.AddHandler(cns.V2Prefix+cns.GetInterfaceForContainer, service.getInterfaceForContainer)
286286
listener.AddHandler(cns.V2Prefix+cns.SetOrchestratorType, service.setOrchestratorType)
287-
listener.AddHandler(cns.V2Prefix+cns.GetNetworkContainerByOrchestratorContext, service.getNetworkContainerByOrchestratorContext)
288-
listener.AddHandler(cns.V2Prefix+cns.GetAllNetworkContainers, service.getAllNetworkContainers)
287+
listener.AddHandler(cns.V2Prefix+cns.GetNetworkContainerByOrchestratorContext, service.GetNetworkContainerByOrchestratorContext)
288+
listener.AddHandler(cns.V2Prefix+cns.GetAllNetworkContainers, service.GetAllNetworkContainers)
289289
listener.AddHandler(cns.V2Prefix+cns.AttachContainerToNetwork, service.attachNetworkContainerToNetwork)
290290
listener.AddHandler(cns.V2Prefix+cns.DetachContainerFromNetwork, service.detachNetworkContainerFromNetwork)
291291
listener.AddHandler(cns.V2Prefix+cns.CreateHnsNetworkPath, service.createHnsNetwork)
292292
listener.AddHandler(cns.V2Prefix+cns.DeleteHnsNetworkPath, service.deleteHnsNetwork)
293293
listener.AddHandler(cns.V2Prefix+cns.NumberOfCPUCoresPath, service.getNumberOfCPUCores)
294-
listener.AddHandler(cns.V2Prefix+cns.CreateHostNCApipaEndpointPath, service.createHostNCApipaEndpoint)
295-
listener.AddHandler(cns.V2Prefix+cns.DeleteHostNCApipaEndpointPath, service.deleteHostNCApipaEndpoint)
294+
listener.AddHandler(cns.V2Prefix+cns.CreateHostNCApipaEndpointPath, service.CreateHostNCApipaEndpoint)
295+
listener.AddHandler(cns.V2Prefix+cns.DeleteHostNCApipaEndpointPath, service.DeleteHostNCApipaEndpoint)
296296
listener.AddHandler(cns.V2Prefix+cns.NmAgentSupportedApisPath, service.nmAgentSupportedApisHandler)
297297
listener.AddHandler(cns.V2Prefix+cns.GetHomeAz, service.getHomeAz)
298298
listener.AddHandler(cns.V2Prefix+cns.EndpointPath, service.EndpointHandlerAPI)

cns/restserver/v2/server.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package v2
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/Azure/azure-container-networking/cns"
7+
"github.com/Azure/azure-container-networking/cns/restserver"
8+
"github.com/labstack/echo/v4"
9+
"go.uber.org/zap"
10+
)
11+
12+
type Server struct {
13+
*restserver.HTTPRestService
14+
}
15+
16+
func New(s *restserver.HTTPRestService) *Server {
17+
return &Server{s}
18+
}
19+
20+
func (s Server) Start(log *zap.Logger, addr string) {
21+
e := echo.New()
22+
e.HideBanner = true
23+
e.GET(cns.RequestIPConfig, echo.WrapHandler(restserver.NewHandlerFuncWithHistogram(s.RequestIPConfigHandler, restserver.HTTPRequestLatency)))
24+
e.GET(cns.RequestIPConfigs, echo.WrapHandler(restserver.NewHandlerFuncWithHistogram(s.RequestIPConfigsHandler, restserver.HTTPRequestLatency)))
25+
e.GET(cns.ReleaseIPConfig, echo.WrapHandler(restserver.NewHandlerFuncWithHistogram(s.ReleaseIPConfigHandler, restserver.HTTPRequestLatency)))
26+
e.GET(cns.ReleaseIPConfigs, echo.WrapHandler(restserver.NewHandlerFuncWithHistogram(s.ReleaseIPConfigsHandler, restserver.HTTPRequestLatency)))
27+
e.GET(cns.PathDebugIPAddresses, echo.WrapHandler(http.HandlerFunc(s.HandleDebugIPAddresses)))
28+
e.GET(cns.PathDebugPodContext, echo.WrapHandler(http.HandlerFunc(s.HandleDebugPodContext)))
29+
e.GET(cns.PathDebugRestData, echo.WrapHandler(http.HandlerFunc(s.HandleDebugRestData)))
30+
e.GET(cns.GetNetworkContainerByOrchestratorContext, echo.WrapHandler(http.HandlerFunc(s.GetNetworkContainerByOrchestratorContext)))
31+
e.GET(cns.GetAllNetworkContainers, echo.WrapHandler(http.HandlerFunc(s.GetAllNetworkContainers)))
32+
e.GET(cns.CreateHostNCApipaEndpointPath, echo.WrapHandler(http.HandlerFunc(s.CreateHostNCApipaEndpoint)))
33+
e.GET(cns.DeleteHostNCApipaEndpointPath, echo.WrapHandler(http.HandlerFunc(s.DeleteHostNCApipaEndpoint)))
34+
35+
// for handlers 2.0
36+
e.GET(cns.V2Prefix+cns.GetNetworkContainerByOrchestratorContext, echo.WrapHandler(http.HandlerFunc(s.GetNetworkContainerByOrchestratorContext)))
37+
e.GET(cns.V2Prefix+cns.GetAllNetworkContainers, echo.WrapHandler(http.HandlerFunc(s.GetAllNetworkContainers)))
38+
e.GET(cns.V2Prefix+cns.CreateHostNCApipaEndpointPath, echo.WrapHandler(http.HandlerFunc(s.CreateHostNCApipaEndpoint)))
39+
e.GET(cns.V2Prefix+cns.DeleteHostNCApipaEndpointPath, echo.WrapHandler(http.HandlerFunc(s.DeleteHostNCApipaEndpoint)))
40+
41+
if err := e.Start(addr); err != nil {
42+
log.Error("failed to run server", zap.Error(err))
43+
}
44+
}

0 commit comments

Comments
 (0)