Skip to content

Commit

Permalink
Release cce-network-v1/1.6.12
Browse files Browse the repository at this point in the history
  • Loading branch information
gola committed Feb 9, 2024
1 parent b90e40c commit c042c85
Show file tree
Hide file tree
Showing 95 changed files with 10,828 additions and 2,296 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ GOMOD := $(GO) mod
GOARCH := $(shell $(GO) env GOARCH)
GOBUILD = CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) $(GO) build
GOTEST := $(GO) test
GOPKGS := $$($(GO) list ./...| grep -vE "vendor" | grep -vE "cmd" |grep -vE "test" |grep -v 'apis/networking'| grep -v 'generated')
GOPKGS := $$($(GO) list ./...| grep "pkg" |grep -v "vendor" | grep -v "cmd" |grep -v "test" | grep -v 'api' |grep -v "generated" | grep -v 'pkg/bce' | grep -v config | grep -v metric | grep -v rpc | grep -v version | grep -v wrapper | grep -v util)
GOGCFLAGS := -gcflags=all="-trimpath=$(GOPATH)" -asmflags=all="-trimpath=$(GOPATH)"
GOLDFLAGS := -ldflags '-s -w'
GO_PACKAGE := github.com/baidubce/baiducloud-cce-cni-driver
Expand All @@ -23,7 +23,7 @@ COVFUNC := $(HOMEDIR)/covfunc.txt # coverage profile information for each funct
COVHTML := $(HOMEDIR)/covhtml.html # HTML representation of coverage profile

# versions
VERSION := v1.5.4
VERSION := v1.6.12
FELIX_VERSION := v3.5.8
K8S_VERSION := 1.18.9

Expand Down Expand Up @@ -68,7 +68,7 @@ gomod: set-env
outdir:
mkdir -p $(OUTDIR)/cni-bin
# Compile all cni plug-ins
cni_target := eni-ipam ipvlan macvlan bandwidth ptp sysctl unnumbered-ptp crossvpc-eni rdma
cni_target := eni-ipam ipvlan macvlan bandwidth ptp sysctl unnumbered-ptp crossvpc-eni rdma eri
$(cni_target): fmt outdir
@echo "===> Building cni $@ <==="
$(GOBUILD) $(GOLDFLAGS) $(GOGCFLAGS) -o $(HOMEDIR)/$@ $(HOMEDIR)/cni/$@
Expand All @@ -90,7 +90,7 @@ build: compile
# make test, test your code
test: prepare test-case
test-case:
$(GOTEST) -v -cover $(GOPKGS)
$(GOTEST) -v -cover -parallel 16 $(GOPKGS)

debian-iptables-image:
@echo "===> Building debian iptables base image <==="
Expand Down
1 change: 1 addition & 0 deletions build/images/cce-cni/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ COPY output/cni-bin/eni-ipam /eni-ipam
COPY output/cni-bin/sysctl /sysctl
COPY output/cni-bin/crossvpc-eni /crossvpc-eni
COPY output/cni-bin/rdma /rdma
COPY output/cni-bin/eri /eri

# install cce ipam binary
COPY output/cce-ipam /bin/cce-ipam
Expand Down
2 changes: 1 addition & 1 deletion build/images/cce-cni/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -u -e

CNI_BINARY_DIR=/opt/cni/bin/
CNI_PLUGIN_LIST="bridge unnumbered-ptp ipvlan macvlan bandwidth loopback host-local ptp eni-ipam sysctl portmap crossvpc-eni rdma"
CNI_PLUGIN_LIST="bridge unnumbered-ptp ipvlan macvlan bandwidth loopback host-local ptp eni-ipam sysctl portmap crossvpc-eni rdma eri"

# mv cni binary to dest
for PLUGIN in $CNI_PLUGIN_LIST
Expand Down
2 changes: 1 addition & 1 deletion build/images/cni-base/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -u -e

CNI_BINARY_DIR=/opt/cni/bin/
CNI_PLUGIN_LIST="bridge unnumbered-ptp ipvlan macvlan bandwidth loopback host-local ptp eni-ipam sysctl portmap crossvpc-eni rdma"
CNI_PLUGIN_LIST="bridge unnumbered-ptp ipvlan macvlan bandwidth loopback host-local ptp eni-ipam sysctl portmap crossvpc-eni rdma eri"

# mv cni binary to dest
for PLUGIN in $CNI_PLUGIN_LIST
Expand Down
31 changes: 17 additions & 14 deletions cni/crossvpc-eni/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns"
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
"github.com/vishvananda/netlink"
"k8s.io/apimachinery/pkg/util/wait"

"github.com/baidubce/baiducloud-cce-cni-driver/pkg/cni"
"github.com/baidubce/baiducloud-cce-cni-driver/pkg/rpc"
Expand Down Expand Up @@ -163,6 +164,7 @@ func (p *crossVpcEniPlugin) cmdAdd(args *skel.CmdArgs) error {
ipam = NewCrossVpcEniIPAM(p.grpc, p.rpc)
netns ns.NetNS
err error
linkErr error
)

log.Infof(ctx, "====> CmdAdd Begins <====")
Expand Down Expand Up @@ -215,23 +217,24 @@ func (p *crossVpcEniPlugin) cmdAdd(args *skel.CmdArgs) error {
}
defer netns.Close()

// ENI 插入虚机后 driver 有时候需要 10s 才能识别到网卡设备,这里重试延长设备等待时间
const (
linkReadyRetryCount = 6
)

for i := 0; i < linkReadyRetryCount; i++ {
target, err = p.netutil.GetLinkByMacAddress(resp.GetCrossVPCENI().Mac)
if err != nil {
log.Errorf(ctx, "retry: host netns: %v", err)
// the kernel would take some time to detect eni insertion.
err = wait.ExponentialBackoff(wait.Backoff{
Duration: time.Millisecond * 500,
Factor: 1,
Steps: 6,
}, func() (done bool, err error) {
target, linkErr = p.netutil.GetLinkByMacAddress(resp.GetCrossVPCENI().Mac)
if linkErr != nil {
log.Warningf(ctx, "host netns: %v", linkErr)
} else {
break
log.Infof(ctx, "host netns: found link %v with mac address %v", target.Attrs().Name, resp.GetCrossVPCENI().Mac)
return true, nil
}
time.Sleep(time.Second * 2)
}

if err != nil {
return fmt.Errorf("host netns: %v", err)
return false, nil
})
if err != nil && err == wait.ErrWaitTimeout {
return fmt.Errorf("host netns: %v", linkErr)
}

if err = p.nlink.LinkSetNsFd(target, int(netns.Fd())); err != nil {
Expand Down
Loading

0 comments on commit c042c85

Please sign in to comment.