Skip to content

Commit

Permalink
Release cce-network-v2/2.11.7
Browse files Browse the repository at this point in the history
  • Loading branch information
gola committed Nov 22, 2024
1 parent c7d2b5a commit af0b2fe
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cce-network-v2/GO_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
go version go1.23.2 darwin/arm64
go version go1.23.2 linux/amd64
2 changes: 1 addition & 1 deletion cce-network-v2/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.11.6
2.11.7
3 changes: 3 additions & 0 deletions cce-network-v2/docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ v2 版本新架构,支持VPC-ENI 辅助IP和vpc路由。版本发布历史如
新特性功能:
1. 新特性:容器内支持分配 RDMA 子网卡及 RDMA 辅助IP。

#### 2.11.7 [20241031]
1. [Optimize] 增加 ENI 主 IP 获取流程,避免新节点缺少主 IP 无法就绪的问题

#### 2.11.6 [20241023]
1. [Bug] 修复 ENI 同步不支持 EHC 的问题

Expand Down
46 changes: 45 additions & 1 deletion cce-network-v2/pkg/bce/bcesync/eni.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/record"

"github.com/baidubce/baiducloud-cce-cni-driver/cce-network-v2/api/v1/models"
operatorOption "github.com/baidubce/baiducloud-cce-cni-driver/cce-network-v2/operator/option"
"github.com/baidubce/baiducloud-cce-cni-driver/cce-network-v2/pkg/bce/api/cloud"
"github.com/baidubce/baiducloud-cce-cni-driver/cce-network-v2/pkg/bce/option"
Expand Down Expand Up @@ -212,6 +213,7 @@ func (es *eniSyncher) handleENIUpdate(resource *ccev2.ENI, scopeLog *logrus.Entr
es: es,
ctx: ctx,
resource: newObj,
scopeLog: scopeLog,
}

err = machine.start()
Expand Down Expand Up @@ -312,12 +314,39 @@ type eniStateMachine struct {
ctx context.Context
resource *ccev2.ENI
vpceni *enisdk.Eni
scopeLog *logrus.Entry
}

// Start state machine flow
func (esm *eniStateMachine) start() error {
var err error
if esm.resource.Status.VPCStatus != ccev2.VPCENIStatusInuse && esm.resource.Status.VPCStatus != ccev2.VPCENIStatusDeleted {
if esm.resource.Status.VPCStatus == ccev2.VPCENIStatusInuse {
if len(esm.resource.Spec.PrivateIPSet) == 0 {
esm.vpceni, err = esm.es.remoteSyncer.statENI(esm.ctx, esm.resource.Name)
if err != nil {
return fmt.Errorf("eni state machine failed to get inuse eni(%s): %v", esm.resource.Name, err)
}
esm.resource.Spec.ENI.ID = esm.vpceni.EniId
esm.resource.Spec.ENI.Name = esm.vpceni.Name
esm.resource.Spec.ENI.MacAddress = esm.vpceni.MacAddress
esm.resource.Spec.ENI.SecurityGroupIds = esm.vpceni.SecurityGroupIds
esm.resource.Spec.ENI.EnterpriseSecurityGroupIds = esm.vpceni.EnterpriseSecurityGroupIds
esm.resource.Spec.ENI.Description = esm.vpceni.Description
esm.resource.Spec.ENI.VpcID = esm.vpceni.VpcId
esm.resource.Spec.ENI.ZoneName = esm.vpceni.ZoneName
esm.resource.Spec.ENI.SubnetID = esm.vpceni.SubnetId
esm.resource.Spec.ENI.PrivateIPSet = toModelPrivateIP(esm.vpceni.PrivateIpSet, esm.vpceni.VpcId, esm.vpceni.SubnetId)
esm.resource.Spec.ENI.IPV6PrivateIPSet = toModelPrivateIP(esm.vpceni.Ipv6PrivateIpSet, esm.vpceni.VpcId, esm.vpceni.SubnetId)
ElectENIIPv6PrimaryIP(esm.resource)
// update spec
_, updateError := esm.es.updater.Update(esm.resource)
if updateError != nil {
esm.scopeLog.WithError(updateError).Error("update eni spec failed")
return updateError
}
esm.scopeLog.Info("update eni spec success")
}
} else if esm.resource.Status.VPCStatus != ccev2.VPCENIStatusDeleted {
// refresh status of ENI
esm.vpceni, err = esm.es.remoteSyncer.statENI(esm.ctx, esm.resource.Name)
if cloud.IsErrorReasonNoSuchObject(err) {
Expand Down Expand Up @@ -452,3 +481,18 @@ func ElectENIIPv6PrimaryIP(newObj *ccev2.ENI) {
}
}
}

// toModelPrivateIP convert private ip to model
func toModelPrivateIP(ipset []enisdk.PrivateIp, vpcID, subnetID string) []*models.PrivateIP {
var pIPSet []*models.PrivateIP
for _, pip := range ipset {
newPIP := &models.PrivateIP{
PublicIPAddress: pip.PublicIpAddress,
PrivateIPAddress: pip.PrivateIpAddress,
Primary: pip.Primary,
}
newPIP.SubnetID = SearchSubnetID(vpcID, subnetID, pip.PrivateIpAddress)
pIPSet = append(pIPSet, newPIP)
}
return pIPSet
}
11 changes: 11 additions & 0 deletions cce-network-v2/pkg/bce/vpceni/node_ebc.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ func (n *ebcNode) createPrimaryENIOnCluster(ctx context.Context, scopedLog *logr
Type: ccev2.ENIType(resource.Spec.ENI.InstanceType),
},
}

// use bcc api to get primary ips of primary ENI
for _, nicip := range bccInfo.NicInfo.Ips {
eni.Spec.ENI.PrivateIPSet = append(eni.Spec.ENI.PrivateIPSet, &models.PrivateIP{
SubnetID: bccInfo.NicInfo.SubnetId,
Primary: nicip.Primary == "true",
PrivateIPAddress: nicip.PrivateIp,
PublicIPAddress: nicip.Eip,
})
}

eni, err = k8s.CCEClient().CceV2().ENIs().Create(ctx, eni, metav1.CreateOptions{})
if err != nil {
scopedLog.Errorf("failed to create primary ENI %s with secondary IP: %v", eni.Name, err)
Expand Down

0 comments on commit af0b2fe

Please sign in to comment.