Skip to content

Commit

Permalink
Release cce-network-v1/1.4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
gola committed Feb 9, 2024
1 parent 9695192 commit d99300c
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 30 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.7
VERSION := v1.4.8
FELIX_VERSION := v3.5.8
K8S_VERSION := 1.18.9

Expand All @@ -41,7 +41,7 @@ EXTRALDFLAGS += -X $(GO_PACKAGE)/pkg/version.Version=$(VERSION)
# pro or dev
PROFILES := dev
IMAGE_TAG := registry.baidubce.com/cce-plugin-$(PROFILES)/cce-cni
PUSH_CNI_IMAGE_FLAGS = --load --push
PUSH_CNI_IMAGE_FLAGS = --push

# make, make all
all: prepare compile
Expand Down Expand Up @@ -72,13 +72,15 @@ cni_target := eni-ipam ipvlan macvlan bandwidth ptp sysctl unnumbered-ptp crossv
$(cni_target): fmt outdir
@echo "===> Building cni $@ <==="
$(GOBUILD) $(GOLDFLAGS) $(GOGCFLAGS) -o $(HOMEDIR)/$@ $(HOMEDIR)/cni/$@
strip $(HOMEDIR)/$@
mv $(HOMEDIR)/$@ $(OUTDIR)/cni-bin/

# Compile all container network programs
exec_target := cce-ipam cni-node-agent ip-masq-agent
$(exec_target): fmt outdir
@echo "===> Building cni $@ <==="
$(GOBUILD) $(GOLDFLAGS) $(GOGCFLAGS) -ldflags '$(EXTRALDFLAGS)' -o $(HOMEDIR)/$@ $(HOMEDIR)/cmd/$@
strip $(HOMEDIR)/$@
mv $(HOMEDIR)/$@ $(OUTDIR)

#make compile
Expand Down
4 changes: 2 additions & 2 deletions build/images/cce-cni/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.baidubce.com/cce-plugin-pro/cce-cni-base:v1.0.0
FROM registry.baidubce.com/cce-plugin-pro/cce-cni-base:v1.0.0-slim

LABEL maintainer="Chen Yaqi<[email protected]>"

Expand All @@ -21,4 +21,4 @@ COPY output/cni-node-agent /bin/cni-node-agent
# install cce node agent binary
COPY output/ip-masq-agent /bin/cce-ip-masq-agent

CMD ["/bin/bash", "/entrypoint.sh"]
CMD ["/bin/sh", "/entrypoint.sh"]
11 changes: 7 additions & 4 deletions build/images/cni-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
FROM cce-cni-debian-iptables:v1.0.0
FROM alpine:3.18

LABEL maintainer="Chen Yaqi<[email protected]>"

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk --no-cache add curl

# ensure cni bin from https://github.com/containernetworking/plugins/releases/download/v1.0.1/cni-plugins-linux-${arch}-v1.0.1.tgz
RUN arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \
curl -L -k --retry 5 https://github.com/containernetworking/plugins/releases/download/v1.0.1/cni-plugins-linux-${arch}-v1.0.1.tgz | tar -xz -C / ./loopback ./host-local ./portmap ./bridge

# install entrypoint.sh and uninstall-cni.sh
COPY build/images/cce-cni/entrypoint.sh /entrypoint.sh
COPY build/images/cce-cni/uninstall-cni.sh /uninstall-cni.sh
COPY entrypoint.sh /entrypoint.sh
COPY uninstall-cni.sh /uninstall-cni.sh

CMD ["/bin/bash", "/entrypoint.sh"]
CMD ["/bin/sh", "/entrypoint.sh"]
2 changes: 1 addition & 1 deletion build/images/cni-base/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -u -e

CNI_BINARY_DIR=/opt/cni/bin/
Expand Down
29 changes: 25 additions & 4 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
[容器网路组件小版本升级 SOP]()

# 1.9
### 1.9.6 [20231116]
1. [bugfix] 修复IP容量特性下的IP容量计算错误(弹性网卡主IP不参与容器IP分配)
2. [Improvement] 容器网络组件瘦身,减少组件镜像大小
### 1.9.5 [20231025]
1. [bugfix] CNI兼容IAAS openAPI返回RDMA网卡MAC地址大写的问题
### 1.9.4 [20231007]
1. [bugfix] 修复创建 ippool 时获取到的 kind 为空的问题
## 1.9.3
Expand All @@ -18,32 +23,48 @@
1. [bugfix] 修复 vpc-eni 模式下,eni 辅助 IP 发生变更时,gc 会误释放已分配 ip 状态的问题

# 1.8
### 1.8.9 [20231116]
1. [bugfix] 修复IP容量特性下的IP容量计算错误(弹性网卡主IP不参与容器IP分配)
2. [Improvement] 容器网络组件瘦身,减少组件镜像大小
### 1.8.8 [20231007]
1. [bugfix] 修复创建 ippool 时获取到的 kind 为空的问题
## 1.8.7 [2023/09/25]
### patch
1. [bugfix] 修复 vpc-route 模式下,添加重名 node 概率出现 ippool cidr 过期的问题

## 1.8.6 [2023/09/22]
### patch
1. [bugfix] 修复 vpc-eni 模式下,eni 辅助 IP 发生变更时,gc 会误释放已分配 ip 状态的问题

## 1.7
### 1.7.9 [暂未发布]
### 1.7.10 [20231116]
1. [bugfix] 修复IP容量特性下的IP容量计算错误(弹性网卡主IP不参与容器IP分配)
2. [Improvement] 容器网络组件瘦身,减少组件镜像大小
### 1.7.9 [20231007]
1. [bugfix] 修复 vpc-eni 模式下,eni 辅助 IP 发生变更时,gc 会误释放已分配 ip 状态的问题
2. [bugfix] 修复 vpc-route 模式下,添加重名 node 概率出现 ippool cidr 过期的问题

## 1.6
### 1.6.11 [暂未发布]
### 1.6.12 [20231116]
1. [bugfix] 修复IP容量特性下的IP容量计算错误(弹性网卡主IP不参与容器IP分配)
2. [Improvement] 容器网络组件瘦身,减少组件镜像大小
### 1.6.11 [20231007]
1. [bugfix] 修复 vpc-eni 模式下,eni 辅助 IP 发生变更时,gc 会误释放已分配 ip 状态的问题
2. [bugfix] 修复 vpc-route 模式下,添加重名 node 概率出现 ippool cidr 过期的问题

## 1.5
### 1.5.3 [暂未发布]
### 1.5.4 [20231116]
1. [bugfix] 修复IP容量特性下的IP容量计算错误(弹性网卡主IP不参与容器IP分配)
2. [Improvement] 容器网络组件瘦身,减少组件镜像大小
3. [bugfix] 修复vpc-hybird模式bcc下仅支持1块弹性网卡40ip问题
### 1.5.3 [20231007]
1. [bugfix] 修复 vpc-eni 模式下,eni 辅助 IP 发生变更时,gc 会误释放已分配 ip 状态的问题
2. [bugfix] 修复 vpc-route 模式下,添加重名 node 概率出现 ippool cidr 过期的问题

## 1.4
### 1.4.8 [20231116]
1. [bugfix] 修复IP容量特性下的IP容量计算错误(弹性网卡主IP不参与容器IP分配)
2. [Improvement] 容器网络组件瘦身,减少组件镜像大小
3. [bugfix] 修复vpc-hybird模式bcc下仅支持1块弹性网卡40ip问题
### 1.4.7 [20231007]
1. [bugfix] 修复创建 ippool 时获取到的 kind 为空的问题
### 1.4.6 [20230928]
Expand Down
3 changes: 2 additions & 1 deletion pkg/nodeagent/controller/ippool/ip_resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func (manager *simpleIPResourceManager) patchENICapacityInfoToNode(ctx context.C

// update node capacity
needUpdateIPResourceFlag := true
maxIP := maxENINum * maxIPPerENI
// ENI primary IP is not used for container network IP allocation
maxIP := maxENINum * (maxIPPerENI - 1)
ipPathBody := fmt.Sprintf(patchCapacityBodyTemplate, patchAddOp, "ip", maxIP)
if ipRe, ok := node.Status.Capacity[networking.ResourceIPForNode]; ok {
if ipRe.Value() == int64(maxIP) {
Expand Down
6 changes: 5 additions & 1 deletion pkg/nodeagent/controller/ippool/ippool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ func (c *Controller) SyncNode(nodeKey string, nodeLister corelisters.NodeLister)
c.ipResourceManager = NewBCCIPResourceManager(c.kubeClient, c.preAttachedENINum, node, c.bccInstance)
return c.syncENISpec(ctx, nodeCopy)
case types.IsCCECNIModeBasedOnBBCSecondaryIP(c.cniMode):
c.ipResourceManager = NewBBCIPResourceManager(c.kubeClient, c.preAttachedENINum, node)
if c.instanceType == metadata.InstanceTypeExBBC {
c.ipResourceManager = NewBBCIPResourceManager(c.kubeClient, c.preAttachedENINum, node)
} else {
c.ipResourceManager = NewBCCIPResourceManager(c.kubeClient, c.preAttachedENINum, node, c.bccInstance)
}
e1 := c.syncENISpec(ctx, nodeCopy)
e2 := c.syncPodSubnetSpec(ctx, nodeCopy)
return utilerrors.NewAggregate([]error{e1, e2})
Expand Down
111 changes: 96 additions & 15 deletions pkg/nodeagent/controller/ippool/ippool_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ func (suite *IPPoolTestCase) mockCloudInterface() {
}, nil).AnyTimes()
}

func (suite *IPPoolTestCase) TestCreateIPRange() {
func (suite *IPPoolTestCase) TestIPv4CreateIPRange() {
c := suite.c
c.cniMode = types.CCEModeRouteVeth
node := mockNode(c.nodeName, c.instanceID)
node := mockIPv4Node(c.nodeName, c.instanceID)

c.kubeClient.CoreV1().Nodes().Create(suite.ctx, node, metav1.CreateOptions{})
suite.startInformer()
Expand All @@ -261,13 +261,44 @@ func (suite *IPPoolTestCase) TestCreateIPRange() {
suite.Assert().EqualValues(1, resource.Value(), "eni capacity")
resource, ok = node.Status.Capacity[networking.ResourceIPForNode]
suite.Assert().True(ok, "node status donot contains eni resource")
suite.Assert().EqualValues(256, resource.Value(), "eni capacity")
suite.Assert().EqualValues(255, resource.Value(), "eni capacity")
}

func (suite *IPPoolTestCase) TestIPv4IPv6CreateIPRange() {
c := suite.c
c.cniMode = types.CCEModeRouteVeth
node := mockIPv4IPv6Node(c.nodeName, c.instanceID)

c.kubeClient.CoreV1().Nodes().Create(suite.ctx, node, metav1.CreateOptions{})
suite.startInformer()
suite.mockCloudInterface()

// wait for cache sync
stopChan := make(chan struct{})
defer close(stopChan)
go func() {
suite.kubeInformer.Start(stopChan)
}()
cache.WaitForNamedCacheSync("controller-test", stopChan, suite.kubeInformer.Core().V1().Nodes().Informer().HasSynced)

err := c.SyncNode(c.nodeName, suite.kubeInformer.Core().V1().Nodes().Lister())
suite.NoError(err, "sync ip pool manager with ip range error")

node, err = c.kubeClient.CoreV1().Nodes().Get(suite.ctx, node.Name, metav1.GetOptions{})
suite.Assert().NoError(err, "get node error")

resource, ok := node.Status.Capacity[networking.ResourceENIForNode]
suite.Assert().True(ok, "node status donot contains eni resource")
suite.Assert().EqualValues(1, resource.Value(), "eni capacity")
resource, ok = node.Status.Capacity[networking.ResourceIPForNode]
suite.Assert().True(ok, "node status donot contains eni resource")
suite.Assert().EqualValues(9223372036854775806, resource.Value(), "eni capacity")
}

func (suite *IPPoolTestCase) TestCreateBCCENI() {
c := suite.c
c.cniMode = types.CCEModeSecondaryIPVeth
node := mockNode(c.nodeName, c.instanceID)
node := mockIPv4Node(c.nodeName, c.instanceID)

c.kubeClient.CoreV1().Nodes().Create(suite.ctx, node, metav1.CreateOptions{})
suite.startInformer()
Expand All @@ -292,13 +323,13 @@ func (suite *IPPoolTestCase) TestCreateBCCENI() {
suite.Assert().EqualValues(8, resource.Value(), "eni capacity")
resource, ok = node.Status.Capacity[networking.ResourceIPForNode]
suite.Assert().True(ok, "node status donot contains eni resource")
suite.Assert().EqualValues(240, resource.Value(), "eni capacity")
suite.Assert().EqualValues(232, resource.Value(), "eni capacity")
}

func (suite *IPPoolTestCase) TestEmptyIPPool() {
c := suite.c
c.cniMode = types.CCEModeSecondaryIPVeth
node := mockNode(c.nodeName, c.instanceID)
node := mockIPv4Node(c.nodeName, c.instanceID)

c.kubeClient.CoreV1().Nodes().Create(suite.ctx, node, metav1.CreateOptions{})
suite.startInformer()
Expand Down Expand Up @@ -340,13 +371,13 @@ func (suite *IPPoolTestCase) TestEmptyIPPool() {
suite.Assert().EqualValues(8, resource.Value(), "eni capacity")
resource, ok = node.Status.Capacity[networking.ResourceIPForNode]
suite.Assert().True(ok, "node status donot contains eni resource")
suite.Assert().EqualValues(240, resource.Value(), "eni capacity")
suite.Assert().EqualValues(232, resource.Value(), "eni capacity")
}

func (suite *IPPoolTestCase) TestCreateBBCENI() {
c := suite.c
c.cniMode = types.CCEModeBBCSecondaryIPVeth
node := mockNode(c.nodeName, c.instanceID)
node := mockIPv4Node(c.nodeName, c.instanceID)

c.kubeClient.CoreV1().Nodes().Create(suite.ctx, node, metav1.CreateOptions{})
suite.startInformer()
Expand All @@ -372,13 +403,45 @@ func (suite *IPPoolTestCase) TestCreateBBCENI() {
suite.Assert().EqualValues(1, resource.Value(), "eni capacity")
resource, ok = node.Status.Capacity[networking.ResourceIPForNode]
suite.Assert().True(ok, "node status donot contains eni resource")
suite.Assert().EqualValues(40, resource.Value(), "eni capacity")
suite.Assert().EqualValues(39, resource.Value(), "eni capacity")
}

func (suite *IPPoolTestCase) TestCreateBCCENIonVPCHybird() {
c := suite.c
c.cniMode = types.CCEModeBBCSecondaryIPVeth
node := mockIPv4Node(c.nodeName, c.instanceID)

c.kubeClient.CoreV1().Nodes().Create(suite.ctx, node, metav1.CreateOptions{})
suite.startInformer()
suite.mockCloudInterface()
c.instanceType = metadata.InstanceTypeExBCC

// wait for cache sync
stopChan := make(chan struct{})
defer close(stopChan)
go func() {
suite.kubeInformer.Start(stopChan)
}()
cache.WaitForNamedCacheSync("controller-test", stopChan, suite.kubeInformer.Core().V1().Nodes().Informer().HasSynced)

err := c.SyncNode(c.nodeName, suite.kubeInformer.Core().V1().Nodes().Lister())
suite.NoError(err, "sync ip pool manager with ip range error")

node, err = c.kubeClient.CoreV1().Nodes().Get(suite.ctx, node.Name, metav1.GetOptions{})
suite.Assert().NoError(err, "get node error")

resource, ok := node.Status.Capacity[networking.ResourceENIForNode]
suite.Assert().True(ok, "node status donot contains eni resource")
suite.Assert().EqualValues(8, resource.Value(), "eni capacity")
resource, ok = node.Status.Capacity[networking.ResourceIPForNode]
suite.Assert().True(ok, "node status donot contains eni resource")
suite.Assert().EqualValues(232, resource.Value(), "eni capacity")
}

func (suite *IPPoolTestCase) TestCreateBBCENIWithCustomerMaxIP() {
func (suite *IPPoolTestCase) TestCreateBBCENIonHybirdWithCustomerMaxIP() {
c := suite.c
c.cniMode = types.CCEModeBBCSecondaryIPVeth
node := mockNode(c.nodeName, c.instanceID)
node := mockIPv4Node(c.nodeName, c.instanceID)

customerMaxIPPerENI = 100
customerMaxENINum = 10
Expand Down Expand Up @@ -407,13 +470,13 @@ func (suite *IPPoolTestCase) TestCreateBBCENIWithCustomerMaxIP() {
suite.Assert().EqualValues(10, resource.Value(), "eni capacity")
resource, ok = node.Status.Capacity[networking.ResourceIPForNode]
suite.Assert().True(ok, "node status donot contains eni resource")
suite.Assert().EqualValues(1000, resource.Value(), "eni capacity")
suite.Assert().EqualValues(990, resource.Value(), "eni capacity")
}

func (suite *IPPoolTestCase) TestCreateCrossVPCEni() {
c := suite.c
c.cniMode = types.CCEModeExclusiveCrossVPCEni
node := mockNode(c.nodeName, c.instanceID)
node := mockIPv4Node(c.nodeName, c.instanceID)

c.kubeClient.CoreV1().Nodes().Create(suite.ctx, node, metav1.CreateOptions{})
suite.startInformer()
Expand All @@ -434,7 +497,7 @@ func (suite *IPPoolTestCase) TestCreateCrossVPCEni() {
func (suite *IPPoolTestCase) TestUnknownMode() {
c := suite.c
c.cniMode = "foo"
node := mockNode(c.nodeName, c.instanceID)
node := mockIPv4Node(c.nodeName, c.instanceID)

c.kubeClient.CoreV1().Nodes().Create(suite.ctx, node, metav1.CreateOptions{})
suite.startInformer()
Expand All @@ -452,7 +515,7 @@ func (suite *IPPoolTestCase) TestUnknownMode() {
suite.Error(err)
}

func mockNode(name, instance string) *v1.Node {
func mockIPv4Node(name, instance string) *v1.Node {
return &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -470,6 +533,24 @@ func mockNode(name, instance string) *v1.Node {
}
}

func mockIPv4IPv6Node(name, instance string) *v1.Node {
return &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: v1.NodeSpec{
PodCIDRs: []string{"192.168.1.0/24", "2002::1234:abcd:ffff:c0a8:101/64"},
ProviderID: "cce://i-QGUcXDdM",
},
Status: v1.NodeStatus{
Phase: v1.NodeRunning,
Capacity: v1.ResourceList{
v1.ResourceCPU: *resource.NewQuantity(1, resource.DecimalSI),
},
},
}
}

func TestSyncNode(t *testing.T) {
suite.Run(t, new(IPPoolTestCase))
}

0 comments on commit d99300c

Please sign in to comment.