Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hot-fix] fix go report #312

Merged
merged 3 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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