update github.com/containernetworking/cni (#1537)

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
This commit is contained in:
Evan Baker 2022-08-22 09:15:53 -07:00 коммит произвёл GitHub
Родитель 6ef6319dbd
Коммит 2417b7effc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
20 изменённых файлов: 46 добавлений и 56 удалений

Просмотреть файл

@ -13,10 +13,9 @@ import (
"github.com/Azure/azure-container-networking/ipam"
"github.com/Azure/azure-container-networking/log"
"github.com/Azure/azure-container-networking/platform"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
)
const ipamV6 = "azure-vnet-ipamv6"
@ -215,16 +214,10 @@ func (plugin *ipamPlugin) Add(args *cniSkel.CmdArgs) error {
return err
}
version := "4"
if ipAddress.IP.To4() == nil {
version = "6"
}
// Populate result.
result = &cniTypesCurr.Result{
IPs: []*cniTypesCurr.IPConfig{
{
Version: version,
Address: *ipAddress,
Gateway: apInfo.Gateway,
},

Просмотреть файл

@ -13,7 +13,7 @@ import (
"time"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
"github.com/google/uuid"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

Просмотреть файл

@ -6,7 +6,7 @@ import (
"github.com/Azure/azure-container-networking/cni"
"github.com/Azure/azure-container-networking/cns"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
)
// IPAMInvoker is used by the azure-vnet CNI plugin to call different sources for IPAM.

Просмотреть файл

@ -15,7 +15,7 @@ import (
"github.com/Azure/azure-container-networking/platform"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
)
type AzureIPAMInvoker struct {

Просмотреть файл

@ -11,7 +11,7 @@ import (
"github.com/Azure/azure-container-networking/network"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
"github.com/stretchr/testify/require"
)

Просмотреть файл

@ -15,7 +15,7 @@ import (
"github.com/Azure/azure-container-networking/network/networkutils"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
"github.com/pkg/errors"
)
@ -119,7 +119,6 @@ func (invoker *CNSIPAMInvoker) Add(addConfig IPAMAddConfig) (IPAMAddResult, erro
addResult.ipv4Result = &cniTypesCurr.Result{
IPs: []*cniTypesCurr.IPConfig{
{
Version: "4",
Address: resultIPnet,
Gateway: ncgw,
},

Просмотреть файл

@ -11,7 +11,7 @@ import (
"github.com/Azure/azure-container-networking/network"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
"github.com/stretchr/testify/require"
)
@ -97,7 +97,6 @@ func TestCNSIPAMInvoker_Add(t *testing.T) {
want: &cniTypesCurr.Result{
IPs: []*cniTypesCurr.IPConfig{
{
Version: "4",
Address: *getCIDRNotationForAddress("10.0.1.10/24"),
Gateway: net.ParseIP("10.0.0.1"),
},

Просмотреть файл

@ -6,7 +6,7 @@ import (
"github.com/Azure/azure-container-networking/cni"
"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
)
const (
@ -53,7 +53,7 @@ func (invoker *MockIpamInvoker) Add(opt IPAMAddConfig) (ipamAddResult IPAMAddRes
ip := net.ParseIP(ipv4Str)
ipnet := net.IPNet{IP: ip, Mask: net.CIDRMask(subnetBits, ipv4Bits)}
gwIP := net.ParseIP("10.240.0.1")
ipConfig := &current.IPConfig{Address: ipnet, Gateway: gwIP, Version: "4"}
ipConfig := &current.IPConfig{Address: ipnet, Gateway: gwIP}
ipamAddResult.ipv4Result = &current.Result{}
ipamAddResult.ipv4Result.IPs = append(ipamAddResult.ipv4Result.IPs, ipConfig)
invoker.ipMap[ipnet.String()] = true
@ -70,7 +70,7 @@ func (invoker *MockIpamInvoker) Add(opt IPAMAddConfig) (ipamAddResult IPAMAddRes
ip := net.ParseIP(ipv6Str)
ipnet := net.IPNet{IP: ip, Mask: net.CIDRMask(subnetv6Bits, ipv6Bits)}
gwIP := net.ParseIP("fc00::1")
ipConfig := &current.IPConfig{Address: ipnet, Gateway: gwIP, Version: "6"}
ipConfig := &current.IPConfig{Address: ipnet, Gateway: gwIP}
ipamAddResult.ipv6Result = &current.Result{}
ipamAddResult.ipv6Result.IPs = append(ipamAddResult.ipv6Result.IPs, ipConfig)
invoker.ipMap[ipnet.String()] = true

Просмотреть файл

@ -18,7 +18,7 @@ import (
"github.com/Azure/azure-container-networking/log"
"github.com/Azure/azure-container-networking/network"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
)
const (
@ -243,10 +243,8 @@ func convertToCniResult(networkConfig *cns.GetNetworkContainerResponse, ifName s
ipAddr := net.ParseIP(ipconfig.IPSubnet.IPAddress)
if ipAddr.To4() != nil {
resultIpconfig.Version = "4"
resultIpconfig.Address = net.IPNet{IP: ipAddr, Mask: net.CIDRMask(int(ipconfig.IPSubnet.PrefixLength), 32)}
} else {
resultIpconfig.Version = "6"
resultIpconfig.Address = net.IPNet{IP: ipAddr, Mask: net.CIDRMask(int(ipconfig.IPSubnet.PrefixLength), 128)}
}

Просмотреть файл

@ -8,7 +8,7 @@ import (
"github.com/Azure/azure-container-networking/cni"
"github.com/Azure/azure-container-networking/cns"
"github.com/Azure/azure-container-networking/network"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
)
type MockMultitenancy struct {
@ -46,7 +46,8 @@ func (m *MockMultitenancy) GetContainerNetworkConfiguration(
ctx context.Context,
nwCfg *cni.NetworkConfig,
podName string,
podNamespace string) (*cns.GetNetworkContainerResponse, net.IPNet, error) {
podNamespace string,
) (*cns.GetNetworkContainerResponse, net.IPNet, error) {
if m.fail {
return nil, net.IPNet{}, errMockMulAdd
}

Просмотреть файл

@ -10,7 +10,7 @@ import (
"github.com/Azure/azure-container-networking/cns"
"github.com/Azure/azure-container-networking/network"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
"github.com/stretchr/testify/require"
)
@ -304,7 +304,6 @@ func TestGetMultiTenancyCNIResult(t *testing.T) {
},
IPs: []*cniTypesCurr.IPConfig{
{
Version: "4",
Address: getIPNet(net.IPv4(10, 1, 0, 5), net.CIDRMask(16, 32)),
Gateway: net.ParseIP("10.1.0.1"),
},
@ -354,7 +353,6 @@ func TestGetMultiTenancyCNIResult(t *testing.T) {
want3: &cniTypesCurr.Result{
IPs: []*cniTypesCurr.IPConfig{
{
Version: "4",
Address: net.IPNet{
IP: net.ParseIP("10.240.0.5"),
Mask: net.CIDRMask(24, 32),

Просмотреть файл

@ -30,7 +30,7 @@ import (
"github.com/Azure/azure-container-networking/telemetry"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
"github.com/pkg/errors"
)
@ -38,7 +38,6 @@ const (
dockerNetworkOption = "com.docker.network.generic"
opModeTransparent = "transparent"
// Supported IP version. Currently support only IPv4
ipVersion = "4"
ipamV6 = "azure-vnet-ipamv6"
defaultRequestTimeout = 15 * time.Second
)
@ -841,7 +840,6 @@ func (plugin *NetPlugin) Get(args *cniSkel.CmdArgs) error {
for _, ipAddresses := range epInfo.IPAddresses {
ipConfig := &cniTypesCurr.IPConfig{
Version: ipVersion,
Interface: &epInfo.IfIndex,
Address: ipAddresses,
}
@ -1224,7 +1222,6 @@ func convertNnsToCniResult(
ipConfig := &cniTypesCurr.IPConfig{
Address: *ipNet,
Gateway: gateway,
Version: ip.Version,
Interface: &intIndex,
}

Просмотреть файл

@ -11,7 +11,7 @@ import (
"github.com/Azure/azure-container-networking/network/policy"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
)
const (
@ -23,7 +23,8 @@ const snatConfigFileName = "/tmp/snatConfig"
// handleConsecutiveAdd is a dummy function for Linux platform.
func (plugin *NetPlugin) handleConsecutiveAdd(args *cniSkel.CmdArgs, endpointID string, networkID string,
nwInfo *network.NetworkInfo, nwCfg *cni.NetworkConfig) (*cniTypesCurr.Result, error) {
nwInfo *network.NetworkInfo, nwCfg *cni.NetworkConfig,
) (*cniTypesCurr.Result, error) {
return nil, nil
}
@ -87,8 +88,8 @@ func setupInfraVnetRoutingForMultitenancy(
nwCfg *cni.NetworkConfig,
azIpamResult *cniTypesCurr.Result,
epInfo *network.EndpointInfo,
result *cniTypesCurr.Result) {
result *cniTypesCurr.Result,
) {
if epInfo.EnableInfraVnet {
_, ipNet, _ := net.ParseCIDR(nwCfg.InfraVnetAddressSpace)
epInfo.Routes = append(epInfo.Routes, network.RouteInfo{Dst: *ipNet, Gw: azIpamResult.IPs[0].Gateway, DevName: infraInterface})

Просмотреть файл

@ -8,7 +8,7 @@ import (
"github.com/Azure/azure-container-networking/cns"
"github.com/Azure/azure-container-networking/network"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Просмотреть файл

@ -20,7 +20,7 @@ import (
hnsv2 "github.com/Microsoft/hcsshim/hcn"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
"github.com/pkg/errors"
"golang.org/x/sys/windows/registry"
)
@ -70,7 +70,6 @@ func (plugin *NetPlugin) handleConsecutiveAdd(args *cniSkel.CmdArgs, endpointId
result := &cniTypesCurr.Result{
IPs: []*cniTypesCurr.IPConfig{
{
Version: "4",
Address: address,
Gateway: net.ParseIP(hnsEndpoint.GatewayAddress),
},
@ -85,7 +84,6 @@ func (plugin *NetPlugin) handleConsecutiveAdd(args *cniSkel.CmdArgs, endpointId
if nwCfg.IPV6Mode != "" && len(epInfo.IPAddresses) > 1 {
ipv6Config := &cniTypesCurr.IPConfig{
Version: "6",
Address: epInfo.IPAddresses[1],
}

Просмотреть файл

@ -5,17 +5,17 @@ package network
import (
"fmt"
"github.com/Azure/azure-container-networking/network/hnswrapper"
"net"
"testing"
"github.com/Azure/azure-container-networking/cni"
"github.com/Azure/azure-container-networking/cns"
"github.com/Azure/azure-container-networking/network"
"github.com/Azure/azure-container-networking/network/hnswrapper"
"github.com/Azure/azure-container-networking/network/policy"
"github.com/Azure/azure-container-networking/telemetry"
"github.com/containernetworking/cni/pkg/skel"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -24,6 +24,7 @@ func init() {
network.Hnsv2 = hnswrapper.NewHnsv2wrapperFake()
network.Hnsv1 = hnswrapper.NewHnsv1wrapperFake()
}
// Test windows network policies is set
func TestAddWithRunTimeNetPolicies(t *testing.T) {
_, ipnetv4, _ := net.ParseCIDR("10.240.0.0/12")

Просмотреть файл

@ -17,7 +17,7 @@ import (
cniInvoke "github.com/containernetworking/cni/pkg/invoke"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypes "github.com/containernetworking/cni/pkg/types"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
cniVers "github.com/containernetworking/cni/pkg/version"
"github.com/pkg/errors"
)

2
go.mod
Просмотреть файл

@ -11,7 +11,7 @@ require (
github.com/Microsoft/hcsshim v0.8.23
github.com/avast/retry-go/v3 v3.1.1
github.com/billgraziano/dpapi v0.4.0
github.com/containernetworking/cni v0.8.1
github.com/containernetworking/cni v1.1.2
github.com/docker/libnetwork v0.8.0-dev.2.0.20210525090646-64b7a4574d14
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2

6
go.sum
Просмотреть файл

@ -231,6 +231,8 @@ github.com/containernetworking/cni v0.7.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ
github.com/containernetworking/cni v0.8.0/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
github.com/containernetworking/cni v0.8.1 h1:7zpDnQ3T3s4ucOuJ/ZCLrYBxzkg0AELFfII3Epo9TmI=
github.com/containernetworking/cni v0.8.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
github.com/containernetworking/cni v1.1.2 h1:wtRGZVv7olUHMOqouPpn3cXJWpJgM6+EUl31EQbXALQ=
github.com/containernetworking/cni v1.1.2/go.mod h1:sDpYKmGVENF3s6uvMvGgldDWeG8dMxakj/u+i9ht9vw=
github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHVlzhJpcY6TQxn/fUyDDM=
github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRDjeJr6FLK6vuiUwoH7P8=
github.com/containers/ocicrypt v1.0.1/go.mod h1:MeJDzk1RJHv89LjsH0Sp5KTY3ZYkjXO/C+bKAeWFIrc=
@ -365,6 +367,7 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh
github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5Fng=
github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
@ -462,6 +465,7 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@ -655,6 +659,7 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU=
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
github.com/onsi/gomega v1.10.0 h1:Gwkk+PTu/nfOwNMtUB/mRUv0X7ewW5dO4AERT1ThVKo=
github.com/onsi/gomega v1.10.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
@ -1219,6 +1224,7 @@ golang.org/x/tools v0.0.0-20200916195026-c9a70fc28ce3/go.mod h1:z6u4i615ZeAfBE4X
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=

Просмотреть файл

@ -10,11 +10,10 @@ import (
"testing"
"time"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
"github.com/Azure/azure-container-networking/common"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/Azure/azure-container-networking/common"
)
var (