Adds resiliency to sync delete calls for same endpoint, gofmt
This commit is contained in:
Родитель
19a382841d
Коммит
7ea1054d4b
|
@ -1,36 +0,0 @@
|
|||
pipeline {
|
||||
agent any
|
||||
options {
|
||||
skipDefaultCheckout true
|
||||
}
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
dir('src/github.com/Microsoft/windows-container-networking') {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
steps {
|
||||
bat '''
|
||||
set GO111MODULE=on
|
||||
set GOPATH=%cd%;C:\\users\\nathan\\go
|
||||
cd src/github.com/Microsoft/windows-container-networking
|
||||
make vendor
|
||||
make all
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
bat '''
|
||||
set GOPATH=%cd%
|
||||
go env
|
||||
cd src/github.com/Microsoft/windows-container-networking
|
||||
make test
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -106,7 +106,7 @@ type K8SPodEnvArgs struct {
|
|||
type OptionalFlags struct {
|
||||
LocalRoutePortMapping bool `json:"localRoutedPortMapping"`
|
||||
AllowAclPortMapping bool `json:"allowAclPortMapping"`
|
||||
ForceBridgeGateway bool `json:"forceBridgeGateway"` // Intended to be temporary workaround
|
||||
ForceBridgeGateway bool `json:"forceBridgeGateway"` // Intended to be temporary workaround
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) (resultError error) {
|
|||
|
||||
// Apply the Network Policy for Endpoint
|
||||
epInfo.Policies = append(epInfo.Policies, networkInfo.Policies...)
|
||||
|
||||
|
||||
epInfo, err = plugin.nm.CreateEndpoint(nwConfig.ID, epInfo, args.Netns)
|
||||
if err != nil {
|
||||
logrus.Errorf("[cni-net] Failed to create endpoint, error : %v.", err)
|
||||
|
@ -199,7 +199,7 @@ func allocateIpam(
|
|||
networkInfo *network.NetworkInfo,
|
||||
endpointInfo *network.EndpointInfo,
|
||||
cniConfig *cni.NetworkConfig,
|
||||
forceBridgeGateway bool) error {
|
||||
forceBridgeGateway bool) error {
|
||||
var result cniTypes.Result
|
||||
var resultImpl *cniTypesImpl.Result
|
||||
|
||||
|
@ -228,9 +228,9 @@ func allocateIpam(
|
|||
|
||||
if forceBridgeGateway == true {
|
||||
endpointInfo.Gateway = resultImpl.IP4.IP.IP.Mask(resultImpl.IP4.IP.Mask)
|
||||
endpointInfo.Gateway[3] = 2;
|
||||
endpointInfo.Gateway[3] = 2
|
||||
}
|
||||
|
||||
|
||||
endpointInfo.Subnet = resultImpl.IP4.IP
|
||||
|
||||
for _, route := range resultImpl.IP4.Routes {
|
||||
|
@ -320,8 +320,13 @@ func (plugin *netPlugin) Delete(args *cniSkel.CmdArgs) error {
|
|||
// Delete the endpoint.
|
||||
err = plugin.nm.DeleteEndpoint(endpointInfo.ID)
|
||||
if err != nil {
|
||||
logrus.Errorf("[cni-net] Failed to delete endpoint, err:%v", err)
|
||||
return err
|
||||
if hcn.IsNotFoundError(err) {
|
||||
logrus.Debugf("[cni-net] Endpoint was not found error, err:%v", err)
|
||||
return nil
|
||||
} else {
|
||||
logrus.Errorf("[cni-net] Failed to delete endpoint, err:%v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
logrus.Debugf("[cni-net] DEL succeeded.")
|
||||
return nil
|
||||
|
|
|
@ -160,13 +160,25 @@ func (nm *networkManager) DeleteEndpoint(endpointID string) error {
|
|||
if epNamespace != nil {
|
||||
err = hcn.RemoveNamespaceEndpoint(hcnEndpoint.HostComputeNamespace, hcnEndpoint.Id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error removing endpoint from namespace %v : endpoint %v", err, hcnEndpoint)
|
||||
if hcn.IsNotFoundError(err) {
|
||||
logrus.Debugf("[cni-net] Endpoint or Namespace was not found, err: %v", err)
|
||||
} else {
|
||||
return fmt.Errorf("error removing endpoint from namespace %v : endpoint %v", err, hcnEndpoint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = hcnEndpoint.Delete()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error deleting endpoint %v : endpoint %v", err, hcnEndpoint)
|
||||
// We retry this if the delete fails incase the endpoint was deleted between now
|
||||
// and when the endpoint was originally queried
|
||||
hcnEndpoint, nestedErr := hcn.GetEndpointByName(hcnEndpoint.Name)
|
||||
if nestedErr != nil {
|
||||
return nestedErr
|
||||
} else {
|
||||
logrus.Debugf("[cni-net] error deleting endpoint %v : endpoint %v", err, hcnEndpoint)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -27,7 +27,7 @@ const (
|
|||
ExpectedPingResult = "Packets: Sent = 4, Received = 4, Lost = 0"
|
||||
SecondaryPingResult = "Packets: Sent = 4, Received = 3, Lost = 1"
|
||||
ExpectedCurlResult = "HTTP/1.1 200 OK"
|
||||
SecondaryCurlResult = "HTTP/1.1 301 Moved Permanently"
|
||||
SecondaryCurlResult = "HTTP/1.1 301 Moved Permanently"
|
||||
)
|
||||
|
||||
func PingTest(c hcsshim.Container, ip string) error {
|
||||
|
@ -66,7 +66,7 @@ func CurlTest(c hcsshim.Container, host string) error {
|
|||
return nil
|
||||
} else if strings.Contains(result, SecondaryCurlResult) {
|
||||
return nil // not going to treat this as an error for now
|
||||
}else {
|
||||
} else {
|
||||
return fmt.Errorf("Curl Response Indicates Failure, Result: \n#####\n%v\n#####\n", result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,10 +49,10 @@ func getDefaultAddArgs(hostIp string) []cni.KVP {
|
|||
func getDefaultEndpointPolicies(hostIp string) []hcn.EndpointPolicy {
|
||||
outBoundNatPol := hcn.EndpointPolicy{
|
||||
Type: "OutBoundNAT",
|
||||
Settings: json.RawMessage(fmt.Sprintf(`{"Exceptions":["10.0.0.0/16", "%s/32"]}`, hostIp)),
|
||||
Settings: json.RawMessage(fmt.Sprintf(`{"Exceptions":["10.0.0.0/16","%s/32"]}`, hostIp)),
|
||||
}
|
||||
sdnRoutePol := hcn.EndpointPolicy{
|
||||
Type: "SdnRoute",
|
||||
Type: "SDNRoute",
|
||||
Settings: json.RawMessage(`{"DestinationPrefix":"11.0.0.0/8","NeedEncap":true}`),
|
||||
}
|
||||
paPol := hcn.EndpointPolicy{
|
||||
|
@ -173,7 +173,7 @@ func CreateGatewayEp(networkId string, ipAddress string) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("Route 2 Error: %v", err)
|
||||
}
|
||||
|
||||
|
||||
os.Unsetenv("vEthernet")
|
||||
os.Unsetenv("vNicName")
|
||||
return nil
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"github.com/Microsoft/hcsshim/hcn"
|
||||
"github.com/Microsoft/windows-container-networking/cni"
|
||||
cniSkel "github.com/containernetworking/cni/pkg/skel"
|
||||
"net"
|
||||
"strings"
|
||||
"testing"
|
||||
"net"
|
||||
)
|
||||
|
||||
type PluginUnitTest struct {
|
||||
|
@ -29,7 +29,7 @@ type PluginUnitTest struct {
|
|||
}
|
||||
|
||||
func (pt *PluginUnitTest) Create(netJson []byte, network *hcn.HostComputeNetwork, expectedPolicies []hcn.EndpointPolicy,
|
||||
expectedSearch []string, expectedNameservers []string, cid string, hostIp* net.IP) {
|
||||
expectedSearch []string, expectedNameservers []string, cid string, hostIp *net.IP) {
|
||||
pt.NetConfJson = netJson
|
||||
pt.Network = network
|
||||
pt.Policies = expectedPolicies
|
||||
|
@ -254,7 +254,6 @@ func (pt *PluginUnitTest) RunBasicConnectivityTest(t *testing.T, numContainers i
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
for _, ct := range ctList {
|
||||
err := pt.RunDelTest(t, ct)
|
||||
if err != nil {
|
||||
|
|
|
@ -2,12 +2,12 @@ package util
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/Microsoft/windows-container-networking/cni"
|
||||
"github.com/Microsoft/windows-container-networking/common"
|
||||
"github.com/Microsoft/windows-container-networking/common/core"
|
||||
cniSkel "github.com/containernetworking/cni/pkg/skel"
|
||||
"net"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const Interface = "Ethernet"
|
||||
|
|
Загрузка…
Ссылка в новой задаче