Skip to content

Commit 9f3c1f3

Browse files
committed
Addressed feedback
1 parent e7bc1ea commit 9f3c1f3

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

cns/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const (
1818
GetIPAddressUtilizationPath = "/network/ip/utilization"
1919
GetUnhealthyIPAddressesPath = "/network/ipaddresses/unhealthy"
2020
GetHealthReportPath = "/network/health"
21-
NumberOfCPUCoresPath = "/network/hostcpucores"
21+
NumberOfCPUCoresPath = "/hostcpucores"
2222
V1Prefix = "/v0.1"
2323
V2Prefix = "/v0.2"
2424
)
@@ -140,7 +140,7 @@ type Response struct {
140140
Message string
141141
}
142142

143-
// getNumberOfCPUCores describes reponse that returns the host local IP Address.
143+
// getNumberOfCPUCores describes reponse that returns num of cpu cores present on host.
144144
type NumOfCPUCoresResponse struct {
145145
Response Response
146146
NumOfCPUCores int

cns/restserver/restserver.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,22 +1580,22 @@ func (service *HTTPRestService) getNetPluginDetails() *networkcontainers.NetPlug
15801580
// Retrieves the number of logic processors on a node. It will be primarily
15811581
// used to enforce per VM delegated NIC limit by DNC.
15821582
func (service *HTTPRestService) getNumberOfCPUCores(w http.ResponseWriter, r *http.Request) {
1583-
log.Printf("[Azure CNS] getNumberOfCPUCores")
1583+
log.Printf("[Azure-CNS] getNumberOfCPUCores")
15841584
log.Request(service.Name, "getNumberOfCPUCores", nil)
15851585

1586-
var num = 0
1587-
var returnCode = 0
1588-
var errmsg string
1586+
var num int
1587+
var returnCode int
1588+
var errMsg string
15891589

15901590
switch r.Method {
15911591
case "GET":
15921592
num = runtime.NumCPU()
15931593
default:
1594-
errmsg = "[Azure-CNS] getNumberOfCPUCores API expects a GET."
1594+
errMsg = "[Azure-CNS] getNumberOfCPUCores API expects a GET."
15951595
returnCode = UnsupportedVerb
15961596
}
15971597

1598-
resp := cns.Response{ReturnCode: returnCode, Message: errmsg}
1598+
resp := cns.Response{ReturnCode: returnCode, Message: errMsg}
15991599
numOfCPUCoresResp := cns.NumOfCPUCoresResponse{
16001600
Response: resp,
16011601
NumOfCPUCores: num,

cns/restserver/restserver_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,12 +693,15 @@ func TestGetInterfaceForNetworkContainer(t *testing.T) {
693693
func TestGetNumOfCPUCores(t *testing.T) {
694694
fmt.Println("Test: getNumberOfCPUCores")
695695

696-
req, err := http.NewRequest(http.MethodGet, cns.NumberOfCPUCoresPath, nil)
696+
var err error
697+
var req *http.Request
698+
req, err = http.NewRequest(http.MethodGet, cns.NumberOfCPUCoresPath, nil)
697699
if err != nil {
698700
t.Fatal(err)
699701
}
700702

701-
w := httptest.NewRecorder()
703+
var w *httptest.ResponseRecorder
704+
w = httptest.NewRecorder()
702705
mux.ServeHTTP(w, req)
703706
var numOfCoresResponse cns.NumOfCPUCoresResponse
704707

0 commit comments

Comments
 (0)