Skip to content

Commit

Permalink
Bump up containernetworking libraries version
Browse files Browse the repository at this point in the history
1. Bump up github.com/containernetworking/cni version to v1.1.2
2. Bump up github.com/containernetworking/plugins v1.1.1

Signed-off-by: wenyingd <wenyingd@vmware.com>
  • Loading branch information
wenyingd committed Jan 19, 2023
1 parent bd683b0 commit 1259688
Show file tree
Hide file tree
Showing 27 changed files with 357 additions and 239 deletions.
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/ClickHouse/clickhouse-go v1.5.4
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/Mellanox/sriovnet v1.1.0
github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331
github.com/Microsoft/hcsshim v0.8.9
github.com/Microsoft/go-winio v0.4.17
github.com/Microsoft/hcsshim v0.8.20
github.com/TomCodeLV/OVSDB-golang-lib v0.0.0-20200116135253-9bbdfadcd881
github.com/awalterschulze/gographviz v2.0.1+incompatible
github.com/aws/aws-sdk-go-v2 v1.16.10
Expand All @@ -19,8 +19,8 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/cheggaaa/pb/v3 v3.1.0
github.com/confluentinc/bincover v0.1.0
github.com/containernetworking/cni v0.8.1
github.com/containernetworking/plugins v0.8.7
github.com/containernetworking/cni v1.1.1
github.com/containernetworking/plugins v1.1.1
github.com/coreos/go-iptables v0.6.0
github.com/fsnotify/fsnotify v1.6.0
github.com/gammazero/deque v0.1.2
Expand All @@ -31,7 +31,7 @@ require (
github.com/google/btree v1.1.2
github.com/google/uuid v1.3.0
github.com/hashicorp/memberlist v0.5.0
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.1.1
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.3.0
github.com/k8snetworkplumbingwg/sriov-cni v2.1.0+incompatible
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd
github.com/lithammer/dedent v1.1.0
Expand Down Expand Up @@ -120,7 +120,7 @@ require (
github.com/cenkalti/rpc2 v0.0.0-20180727162946-9642ea02d0aa // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59 // indirect
github.com/containerd/cgroups v1.0.1 // indirect
github.com/contiv/libovsdb v0.0.0-20170227191248-d0061a53e358 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
Expand Down Expand Up @@ -173,11 +173,11 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8 // indirect
github.com/safchain/ethtool v0.0.0-20210803160452-9aa261dae9b1 // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/streamrail/concurrent-map v0.0.0-20160823150647-8bf1e9bacbf6 // indirect
github.com/ti-mo/netfilter v0.3.1 // indirect
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae // indirect
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f // indirect
go.etcd.io/etcd/api/v3 v3.5.1 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.1 // indirect
Expand Down
308 changes: 290 additions & 18 deletions go.sum

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions pkg/agent/cniserver/interface_configuration_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/Mellanox/sriovnet"
cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ip"
"github.com/containernetworking/plugins/pkg/ipam"
"github.com/containernetworking/plugins/pkg/ns"
Expand All @@ -37,7 +37,6 @@ import (
"antrea.io/antrea/pkg/agent/util/ndp"
cnipb "antrea.io/antrea/pkg/apis/cni/v1beta1"
"antrea.io/antrea/pkg/ovs/ovsconfig"
cniip "antrea.io/antrea/third_party/containernetworking/ip"
)

// NetDeviceType type Enum
Expand Down Expand Up @@ -258,7 +257,7 @@ func (ic *ifConfigurator) configureContainerLinkVeth(
podMAC := util.GenerateRandomMAC()
if err := ns.WithNetNSPath(containerNetNS, func(hostNS ns.NetNS) error {
klog.V(2).Infof("Creating veth devices (%s, %s) for container %s", containerIfaceName, hostIfaceName, containerID)
hostVeth, containerVeth, err := cniip.SetupVethWithName(containerIfaceName, hostIfaceName, mtu, podMAC.String(), hostNS)
hostVeth, containerVeth, err := ip.SetupVethWithName(containerIfaceName, hostIfaceName, mtu, podMAC.String(), hostNS)
if err != nil {
return fmt.Errorf("failed to create veth devices for container %s: %v", containerID, err)
}
Expand Down Expand Up @@ -304,9 +303,9 @@ func (ic *ifConfigurator) advertiseContainerAddr(containerNetNS string, containe
}
var targetIPv4, targetIPv6 net.IP
for _, ipc := range result.IPs {
if ipc.Version == "4" {
if ipc.Address.IP.To4() != nil {
targetIPv4 = ipc.Address.IP
} else if ipc.Version == "6" {
} else {
targetIPv6 = ipc.Address.IP
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/cniserver/interface_configuration_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/Microsoft/hcsshim"
"github.com/Microsoft/hcsshim/hcn"
cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"

Expand Down Expand Up @@ -89,7 +89,7 @@ func (ic *ifConfigurator) delEndpoint(name string) {
// findContainerIPConfig finds a valid IPv4 address since IPv6 is not supported for Windows at this stage.
func findContainerIPConfig(ips []*current.IPConfig) (*current.IPConfig, error) {
for _, ipc := range ips {
if ipc.Version == "4" {
if ipc.Address.IP.To4() != nil {
return ipc, nil
}
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/agent/cniserver/ipam/antrea_ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/containernetworking/cni/pkg/invoke"
cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"

Expand Down Expand Up @@ -81,15 +81,13 @@ func getAllocationOwner(args *invoke.Args, k8sArgs *types.K8sArgs, reservedOwner

// Helper to generate IP config and default route, taking IP version into account
func generateIPConfig(ip net.IP, prefixLength int, gwIP net.IP) (*current.IPConfig, *cnitypes.Route) {
ipVersion := "4"
ipAddrBits := 32
dstNet := net.IPNet{
IP: net.ParseIP("0.0.0.0"),
Mask: net.CIDRMask(0, ipAddrBits),
}

if ip.To4() == nil {
ipVersion = "6"
ipAddrBits = 128

dstNet = net.IPNet{
Expand All @@ -103,7 +101,6 @@ func generateIPConfig(ip net.IP, prefixLength int, gwIP net.IP) (*current.IPConf
GW: gwIP,
}
ipConfig := current.IPConfig{
Version: ipVersion,
Address: net.IPNet{IP: ip, Mask: net.CIDRMask(int(prefixLength), ipAddrBits)},
Gateway: gwIP,
}
Expand Down Expand Up @@ -266,8 +263,7 @@ func (d *AntreaIPAM) secondaryNetworkAdd(args *invoke.Args, k8sArgs *types.K8sAr
for _, a := range ipamConf.Addresses {
result.IPs = append(result.IPs, &current.IPConfig{
Address: a.IPNet,
Gateway: a.Gateway,
Version: a.Version})
Gateway: a.Gateway})
}

// Copy routes and DNS from the input IPAM configuration.
Expand Down
3 changes: 2 additions & 1 deletion pkg/agent/cniserver/ipam/antrea_ipam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/containernetworking/cni/pkg/invoke"
cnitypes "github.com/containernetworking/cni/pkg/types"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -51,7 +52,7 @@ var (
testNoAnnotation = "empty"
testJunkAnnotation = "junk"

testCNIVersion = "0.4.0"
testCNIVersion = current.ImplementedSpecVersion
)

func createIPPools(crdClient *fakepoolclient.IPPoolClientset) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/ipam/ipam_delegator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/containernetworking/cni/pkg/invoke"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/klog/v2"

argtypes "antrea.io/antrea/pkg/agent/cniserver/types"
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/ipam/ipam_delegator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/containernetworking/cni/pkg/invoke"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
"github.com/stretchr/testify/assert"

Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/ipam/ipam_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"sync"

"github.com/containernetworking/cni/pkg/invoke"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"

"antrea.io/antrea/pkg/agent/cniserver/types"
cnipb "antrea.io/antrea/pkg/apis/cni/v1beta1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/ipam/ipam_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/containernetworking/cni/pkg/invoke"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/stretchr/testify/assert"

argtypes "antrea.io/antrea/pkg/agent/cniserver/types"
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/cniserver/ipam/testing/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"strings"

"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
)

func GenerateIPAMResult(cniVersion string, ipConfig []string, routeConfig []string, dnsConfig []string) *current.Result {
Expand Down Expand Up @@ -65,7 +65,7 @@ func parseIPs(ips []string) []*current.IPConfig {
func parseIPConfig(ipAddress string, gw string, version string) *current.IPConfig {
ip, ipv4Net, _ := net.ParseCIDR(ipAddress)
ipv4Net.IP = ip
ipConfig := &current.IPConfig{Version: version, Address: *ipv4Net}
ipConfig := &current.IPConfig{Address: *ipv4Net}
if gw != "" {
gateway := net.ParseIP(gw)
ipConfig.Gateway = gateway
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/cniserver/pod_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net"
"strings"

"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -385,7 +385,7 @@ func (pc *podConfigurator) validateOVSInterfaceConfig(containerID string, contai
}

for _, ipc := range ips {
if ipc.Version == "4" {
if ipc.Address.IP.To4() != nil {
ipv4Addr := util.GetIPv4Addr(containerConfig.IPs)
if ipv4Addr != nil && ipv4Addr.Equal(ipc.Address.IP) {
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/pod_configuration_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package cniserver

import (
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/klog/v2"

"antrea.io/antrea/pkg/agent/interfacestore"
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/pod_configuration_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package cniserver
import (
"fmt"

"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/klog/v2"

"antrea.io/antrea/pkg/agent/interfacestore"
Expand Down
15 changes: 9 additions & 6 deletions pkg/agent/cniserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"time"

cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
"github.com/containernetworking/plugins/pkg/ip"
"google.golang.org/grpc"
Expand Down Expand Up @@ -176,7 +176,7 @@ func updateResultIfaceConfig(result *current.Result, defaultIPv4Gateway net.IP,
}
}

func resultToResponse(result *current.Result) *cnipb.CniCmdResponse {
func resultToResponse(result cnitypes.Result) *cnipb.CniCmdResponse {
var resultBytes bytes.Buffer
_ = result.PrintTo(&resultBytes)
return &cnipb.CniCmdResponse{CniResult: resultBytes.Bytes()}
Expand Down Expand Up @@ -358,6 +358,7 @@ func (s *CNIServer) parsePrevResultFromRequest(networkConfig *types.NetworkConfi
klog.Errorf("Failed to construct prevResult using previous network configuration")
return nil, s.unsupportedFieldResponse("prevResult", networkConfig.PrevResult)
}
prevResult.CNIVersion = networkConfig.CNIVersion
return prevResult, nil
}

Expand Down Expand Up @@ -395,8 +396,9 @@ func (s *CNIServer) ipamAdd(cniConfig *CNIConfig) (*cnipb.CniCmdResponse, error)
if err != nil {
return s.ipamFailureResponse(err), nil
}
cniResult, _ := ipamResult.GetAsVersion(cniConfig.CNIVersion)
klog.InfoS("Allocated IP addresses", "container", cniConfig.ContainerId, "result", ipamResult)
return resultToResponse(ipamResult), nil
return resultToResponse(cniResult), nil
}

func (s *CNIServer) ipamDel(cniConfig *CNIConfig) (*cnipb.CniCmdResponse, error) {
Expand Down Expand Up @@ -438,8 +440,7 @@ func (s *CNIServer) CmdAdd(ctx context.Context, request *cnipb.CniCmdRequest) (*
case <-s.networkReadyCh:
}

cniVersion := cniConfig.CNIVersion
result := &ipam.IPAMResult{Result: current.Result{CNIVersion: cniVersion}}
result := &ipam.IPAMResult{Result: current.Result{CNIVersion: current.ImplementedSpecVersion}}
netNS := s.hostNetNsPath(cniConfig.Netns)
isInfraContainer := isInfraContainer(netNS)

Expand Down Expand Up @@ -512,6 +513,8 @@ func (s *CNIServer) CmdAdd(ctx context.Context, request *cnipb.CniCmdRequest) (*
klog.Errorf("Failed to configure interfaces for container %s: %v", cniConfig.ContainerId, err)
return s.configInterfaceFailureResponse(err), nil
}
cniVersion := cniConfig.CNIVersion
cniResult, _ := result.Result.GetAsVersion(cniVersion)

klog.Infof("CmdAdd for container %v succeeded", cniConfig.ContainerId)
// mark success as true to avoid rollback
Expand All @@ -525,7 +528,7 @@ func (s *CNIServer) CmdAdd(ctx context.Context, request *cnipb.CniCmdRequest) (*
s.podConfigurator.podInfoStore.AddCNIConfigInfo(cniInfo)
}

return resultToResponse(&result.Result), nil
return resultToResponse(cniResult), nil
}

func (s *CNIServer) CmdDel(_ context.Context, request *cnipb.CniCmdRequest) (
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/server_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package cniserver

import "github.com/containernetworking/cni/pkg/types/current"
import current "github.com/containernetworking/cni/pkg/types/100"

// updateResultDNSConfig updates the DNS config from CNIConfig.
func updateResultDNSConfig(result *current.Result, cniConfig *CNIConfig) {
Expand Down
11 changes: 5 additions & 6 deletions pkg/agent/cniserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"testing"

cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestIPAMService(t *testing.T) {

// Test IPAM_Failure cases
cxt := context.Background()
networkCfg := generateNetworkConfiguration("", "0.4.0", "", testIpamType)
networkCfg := generateNetworkConfiguration("", supportedCNIVersion, "", testIpamType)
requestMsg, _ := newRequest(args, networkCfg, "", t)

t.Run("Error on ADD", func(t *testing.T) {
Expand Down Expand Up @@ -241,18 +241,17 @@ func TestIPAMServiceMultiDriver(t *testing.T) {

// Test IPAM_Failure cases
cxt := context.Background()
networkCfg := generateNetworkConfiguration("", "0.4.0", "", testIpamType2)
networkCfg := generateNetworkConfiguration("", supportedCNIVersion, "", testIpamType2)

argsPodA := cniservertest.GenerateCNIArgs(testPodNameA, testPodNamespace, testPodInfraContainerID)
argsPodB := cniservertest.GenerateCNIArgs(testPodNameB, testPodNamespace, testPodInfraContainerID)
requestMsgA, _ := newRequest(argsPodA, networkCfg, "", t)
requestMsgB, _ := newRequest(argsPodB, networkCfg, "", t)

cniVersion := "0.4.0"
ips := []string{"10.1.2.100/24,10.1.2.1,4"}
routes := []string{"10.0.0.0/8,10.1.2.1", "0.0.0.0/0,10.1.2.1"}
dns := []string{"192.168.100.1"}
ipamResult := &ipam.IPAMResult{Result: *ipamtest.GenerateIPAMResult(cniVersion, ips, routes, dns)}
ipamResult := &ipam.IPAMResult{Result: *ipamtest.GenerateIPAMResult(supportedCNIVersion, ips, routes, dns)}

t.Run("Error on ADD for first registered driver", func(t *testing.T) {
mockDriverA.EXPECT().Add(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil, fmt.Errorf("IPAM add error"))
Expand Down Expand Up @@ -442,7 +441,7 @@ func TestValidateRequestMessage(t *testing.T) {

func TestValidatePrevResult(t *testing.T) {
cniServer := newCNIServer(t)
cniVersion := "0.4.0"
cniVersion := supportedCNIVersion
networkCfg := generateNetworkConfiguration("", cniVersion, "", testIpamType)
k8sPodArgs := &types.K8sArgs{}
cnitypes.LoadArgs(args, k8sPodArgs)
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/server_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package cniserver
import (
"strings"

"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/sriov.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"path"
"time"

"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"google.golang.org/grpc"
grpcinsecure "google.golang.org/grpc/credentials/insecure"
"k8s.io/klog/v2"
Expand Down
Loading

0 comments on commit 1259688

Please sign in to comment.