Skip to content

Commit

Permalink
Merge pull request #312 from linkernetworks/johnlin/fix-go-report
Browse files Browse the repository at this point in the history
[Hot-fix] fix go report
  • Loading branch information
John-Lin authored Sep 4, 2018
2 parents 57d1117 + 60b3d41 commit 61bcfac
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/kubernetes/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func (kc *KubeCtl) GetPods(namespace string) ([]*corev1.Pod, error) {
if err != nil {
return pods, err
}
for i, _ := range podsList.Items {

for i := 0; i < len(podsList.Items); i++ {
pods = append(pods, &podsList.Items[i])
}
return pods, nil
Expand Down
2 changes: 1 addition & 1 deletion src/networkcontroller/network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (nc *NetworkController) DeleteOVSNetwork(bridgeName string) error {
return nil
}

// DumpOVSPorts will dump ports infromation of the target ovs
// DumpOVSPorts will dump ports information of the target ovs
func (nc *NetworkController) DumpOVSPorts(bridgeName string) ([]*pb.PortInfo, error) {
data, err := nc.ClientCtl.DumpPorts(
nc.Context,
Expand Down
3 changes: 3 additions & 0 deletions src/ovscontroller/ovs_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func DumpPorts(sp *serviceprovider.Container, nodeName string, bridgeName string

nodeAddr := net.JoinHostPort(nodeIP, networkcontroller.DEFAULT_CONTROLLER_PORT)
nc, err := networkcontroller.New(nodeAddr)
if err != nil {
return nil, err
}

//Get the information of OVS ports
retPorts, err := nc.DumpOVSPorts(bridgeName)
Expand Down
3 changes: 1 addition & 2 deletions src/server/handler_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ func getContainerLogsHandler(ctx *web.Context) {

result, err := container.GetLogDetails(sp, namespace, podID, containerID, logSelector, usePreviousLogs)
if err != nil {
fmt.Errorf("failed to get the details of node: %v", err)
response.BadRequest(req.Request, resp.ResponseWriter, err)
response.BadRequest(req.Request, resp.ResponseWriter, fmt.Errorf("failed to get the details of node: %v", err))
return
}
resp.WriteHeaderAndEntity(http.StatusOK, result)
Expand Down
10 changes: 3 additions & 7 deletions src/server/handler_ovs_test.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
package server

import (
_ "encoding/json"
"math/rand"
"net/http"
"net/http/httptest"

"testing"
"time"

restful "github.com/emicklei/go-restful"
"github.com/linkernetworks/mongo"
"github.com/linkernetworks/vortex/src/config"
"github.com/linkernetworks/vortex/src/entity"
"github.com/linkernetworks/vortex/src/serviceprovider"
_ "github.com/moby/moby/pkg/namesgenerator"
"github.com/stretchr/testify/suite"
_ "gopkg.in/mgo.v2/bson"
//corev1 "k8s.io/api/core/v1"

"testing"
)

func init() {
Expand Down Expand Up @@ -63,11 +57,13 @@ func (suite *OVSTestSuite) TestGetOVSPortStatsFail() {
assertResponseCode(suite.T(), http.StatusBadRequest, httpWriter)

httpRequest, err = http.NewRequest("GET", "http://localhost:7890/v1/ovs/portinfos?nodeName=11", nil)
suite.NoError(err)
httpWriter = httptest.NewRecorder()
suite.wc.Dispatch(httpWriter, httpRequest)
assertResponseCode(suite.T(), http.StatusBadRequest, httpWriter)

httpRequest, err = http.NewRequest("GET", "http://localhost:7890/v1/ovs/portinfos?nodeName=11&&bridgeName=111", nil)
suite.NoError(err)
httpWriter = httptest.NewRecorder()
suite.wc.Dispatch(httpWriter, httpRequest)
assertResponseCode(suite.T(), http.StatusInternalServerError, httpWriter)
Expand Down

0 comments on commit 61bcfac

Please sign in to comment.