Skip to content
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
1 change: 0 additions & 1 deletion network/bridge_endpointclient_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func NewLinuxBridgeEndpointClient(
nl netlink.NetlinkInterface,
plc platform.ExecClient,
) *LinuxBridgeEndpointClient {

client := &LinuxBridgeEndpointClient{
bridgeName: extIf.BridgeName,
hostPrimaryIfName: extIf.Name,
Expand Down
5 changes: 1 addition & 4 deletions network/endpoint_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func ConstructEndpointID(containerID string, netNsPath string, ifName string) (s

// newEndpointImpl creates a new endpoint in the network.
func (nw *network) newEndpointImpl(cli apipaClient, _ netlink.NetlinkInterface, _ platform.ExecClient, epInfo *EndpointInfo) (*endpoint, error) {

if useHnsV2, err := UseHnsV2(epInfo.NetNsPath); useHnsV2 {
if err != nil {
return nil, err
Expand Down Expand Up @@ -115,7 +114,6 @@ func (nw *network) newEndpointImplHnsV1(epInfo *EndpointInfo) (*endpoint, error)
}

hnsResponse, err := Hnsv1.CreateEndpoint(hnsEndpoint, "")

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -290,8 +288,7 @@ func (nw *network) createHostNCApipaEndpoint(cli apipaClient, epInfo *EndpointIn
log.Printf("[net] Creating HostNCApipaEndpoint for host container connectivity for NC: %s",
epInfo.NetworkContainerID)

if hostNCApipaEndpointID, err =
cli.CreateHostNCApipaEndpoint(context.TODO(), epInfo.NetworkContainerID); err != nil {
if hostNCApipaEndpointID, err = cli.CreateHostNCApipaEndpoint(context.TODO(), epInfo.NetworkContainerID); err != nil {
return err
}

Expand Down
5 changes: 0 additions & 5 deletions network/endpoint_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestNewAndDeleteEndpointImplHnsV2(t *testing.T) {
MacAddress: net.HardwareAddr("00:00:5e:00:53:01"),
}
endpoint, err := nw.newEndpointImplHnsV2(nil, epInfo)

if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
Expand Down Expand Up @@ -89,7 +88,6 @@ func TestNewEndpointImplHnsv2Timesout(t *testing.T) {
if err == nil {
t.Fatal("Failed to timeout HNS calls for creating endpoint")
}

}

func TestDeleteEndpointImplHnsv2Timeout(t *testing.T) {
Expand All @@ -113,7 +111,6 @@ func TestDeleteEndpointImplHnsv2Timeout(t *testing.T) {
MacAddress: net.HardwareAddr("00:00:5e:00:53:01"),
}
endpoint, err := nw.newEndpointImplHnsV2(nil, epInfo)

if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
Expand Down Expand Up @@ -167,7 +164,6 @@ func TestCreateEndpointImplHnsv1Timeout(t *testing.T) {
if err == nil {
t.Fatal("Failed to timeout HNS calls for creating endpoint")
}

}

func TestDeleteEndpointImplHnsv1Timeout(t *testing.T) {
Expand All @@ -191,7 +187,6 @@ func TestDeleteEndpointImplHnsv1Timeout(t *testing.T) {
MacAddress: net.HardwareAddr("00:00:5e:00:53:01"),
}
endpoint, err := nw.newEndpointImplHnsV1(epInfo)

if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
Expand Down
7 changes: 5 additions & 2 deletions network/hnsendpoint_mock_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package network

import (
"errors"

"github.com/Microsoft/hcsshim"
)

Expand All @@ -12,9 +13,11 @@ type MockHNSEndpoint struct {
}

func NewMockHNSEndpoint(isAttached bool, hotAttachFailure bool) *MockHNSEndpoint {
return &MockHNSEndpoint{HnsIDMap: make(map[string]*hcsshim.HNSEndpoint),
return &MockHNSEndpoint{
HnsIDMap: make(map[string]*hcsshim.HNSEndpoint),
IsAttachedFlag: isAttached,
HotAttachFailure: hotAttachFailure}
HotAttachFailure: hotAttachFailure,
}
}

func (az *MockHNSEndpoint) GetHNSEndpointByName(endpointName string) (*hcsshim.HNSEndpoint, error) {
Expand Down
6 changes: 1 addition & 5 deletions network/hnswrapper/hnsv1wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
"github.com/Microsoft/hcsshim"
)

type Hnsv1wrapper struct {
}
type Hnsv1wrapper struct{}

func (Hnsv1wrapper) CreateEndpoint(endpoint *hcsshim.HNSEndpoint, path string) (*hcsshim.HNSEndpoint, error) {
// Marshal the request.
Expand All @@ -35,13 +34,11 @@ func (Hnsv1wrapper) CreateEndpoint(endpoint *hcsshim.HNSEndpoint, path string) (

func (Hnsv1wrapper) DeleteEndpoint(endpointId string) (*hcsshim.HNSEndpoint, error) {
hnsResponse, err := hcsshim.HNSEndpointRequest("DELETE", endpointId, "")

if err != nil {
return nil, err
}

return hnsResponse, err

}

func (Hnsv1wrapper) CreateNetwork(network *hcsshim.HNSNetwork, path string) (*hcsshim.HNSNetwork, error) {
Expand All @@ -66,7 +63,6 @@ func (Hnsv1wrapper) CreateNetwork(network *hcsshim.HNSNetwork, path string) (*hc

func (Hnsv1wrapper) DeleteNetwork(networkId string) (*hcsshim.HNSNetwork, error) {
hnsResponse, err := hcsshim.HNSNetworkRequest("DELETE", networkId, "")

if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion network/hnswrapper/hnsv1wrapperwithtimeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package hnswrapper

import (
"context"
"time"

"github.com/Microsoft/hcsshim"
"github.com/pkg/errors"
"time"
)

type Hnsv1wrapperwithtimeout struct {
Expand Down
3 changes: 1 addition & 2 deletions network/hnswrapper/hnsv2wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
"github.com/Microsoft/hcsshim/hcn"
)

type Hnsv2wrapper struct {
}
type Hnsv2wrapper struct{}

func (Hnsv2wrapper) CreateEndpoint(endpoint *hcn.HostComputeEndpoint) (*hcn.HostComputeEndpoint, error) {
return endpoint.Create()
Expand Down
4 changes: 2 additions & 2 deletions network/network_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ var Hnsv1 hnswrapper.HnsV1WrapperInterface = hnswrapper.Hnsv1wrapper{}

func EnableHnsV2Timeout(timeoutValue int) {
if _, ok := Hnsv2.(hnswrapper.Hnsv2wrapperwithtimeout); !ok {
var timeoutDuration = time.Duration(timeoutValue) * time.Second
timeoutDuration := time.Duration(timeoutValue) * time.Second
Hnsv2 = hnswrapper.Hnsv2wrapperwithtimeout{Hnsv2: hnswrapper.Hnsv2wrapper{}, HnsCallTimeout: timeoutDuration}
}
}

func EnableHnsV1Timeout(timeoutValue int) {
if _, ok := Hnsv1.(hnswrapper.Hnsv1wrapperwithtimeout); !ok {
var timeoutDuration = time.Duration(timeoutValue) * time.Second
timeoutDuration := time.Duration(timeoutValue) * time.Second
Hnsv1 = hnswrapper.Hnsv1wrapperwithtimeout{Hnsv1: hnswrapper.Hnsv1wrapper{}, HnsCallTimeout: timeoutDuration}
}
}
Expand Down
3 changes: 0 additions & 3 deletions network/network_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestNewAndDeleteNetworkImplHnsV2(t *testing.T) {
}

network, err := nm.newNetworkImplHnsV2(nwInfo, extInterface)

if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
Expand Down Expand Up @@ -137,7 +136,6 @@ func TestDeleteNetworkImplHnsV2WithTimeout(t *testing.T) {
Hnsv2 = hnswrapper.NewHnsv2wrapperFake()

network, err := nm.newNetworkImplHnsV2(nwInfo, extInterface)

if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
Expand Down Expand Up @@ -210,7 +208,6 @@ func TestDeleteNetworkImplHnsV1WithTimeout(t *testing.T) {
Hnsv1 = hnswrapper.NewHnsv1wrapperFake()

network, err := nm.newNetworkImplHnsV1(nwInfo, extInterface)

if err != nil {
fmt.Printf("+%v", err)
t.Fatal(err)
Expand Down
3 changes: 2 additions & 1 deletion network/ovs_networkclient_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ func (client *OVSNetworkClient) AddRoutes(nwInfo *NetworkInfo, interfaceName str
}

func NewOVSClient(bridgeName, hostInterfaceName string, ovsctlClient ovsctl.OvsInterface,
nl netlink.NetlinkInterface, plc platform.ExecClient) *OVSNetworkClient {
nl netlink.NetlinkInterface, plc platform.ExecClient,
) *OVSNetworkClient {
ovsClient := &OVSNetworkClient{
bridgeName: bridgeName,
hostInterfaceName: hostInterfaceName,
Expand Down
8 changes: 4 additions & 4 deletions network/ovsinfravnet/infravnet_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (client *OVSInfraVnetClient) CreateInfraVnetRules(
bridgeName string,
infraIP net.IPNet,
hostPrimaryMac string,
hostPort string) error {

hostPort string,
) error {
ovs := ovsctl.NewOvsctl()

infraContainerPort, err := ovs.GetOVSPortNumber(client.hostInfraVethName)
Expand Down Expand Up @@ -132,8 +132,8 @@ func (client *OVSInfraVnetClient) ConfigureInfraVnetContainerInterface(infraIP n
func (client *OVSInfraVnetClient) DeleteInfraVnetRules(
bridgeName string,
infraIP net.IPNet,
hostPort string) {

hostPort string,
) {
ovs := ovsctl.NewOvsctl()

log.Printf("[ovs] Deleting MAC DNAT rule for infravnet IP address %v", infraIP.IP.String())
Expand Down
1 change: 0 additions & 1 deletion network/transparent_endpointclient_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func NewTransparentEndpointClient(
nl netlink.NetlinkInterface,
plc platform.ExecClient,
) *TransparentEndpointClient {

client := &TransparentEndpointClient{
bridgeName: extIf.BridgeName,
hostPrimaryIfName: extIf.Name,
Expand Down