From 9b1c93e5cb50e298aa20d9530b645b0a4124a5b1 Mon Sep 17 00:00:00 2001 From: Huanyu He <552483776@qq.com> Date: Wed, 17 Nov 2021 17:11:46 +0800 Subject: [PATCH 1/4] Merge pull request #118 from hhyasdf/bugfix/ipv6-addr-calculate-error bugfix: fix ipv6 addr calculate error --- go.mod | 1 + go.sum | 2 ++ pkg/daemon/utils/ip_range.go | 44 ++++++----------------- pkg/daemon/utils/ip_range_test.go | 58 +++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 33 deletions(-) diff --git a/go.mod b/go.mod index eea9ff0d..63880d92 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/mdlayher/ethernet v0.0.0-20190606142754-0394541c37b7 github.com/mdlayher/ndp v0.0.0-20200602162440-17ab9e3e5567 github.com/mdlayher/raw v0.0.0-20190606142536-fef19f00fc18 + github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721 github.com/parnurzeal/gorequest v0.2.16 github.com/pkg/errors v0.8.1 github.com/prometheus/client_golang v1.0.0 diff --git a/go.sum b/go.sum index 0bd13a8f..39ef63d1 100644 --- a/go.sum +++ b/go.sum @@ -415,6 +415,8 @@ github.com/mesos/mesos-go v0.0.9/go.mod h1:kPYCMQ9gsOXVAle1OsoY4I1+9kPu8GHkf88aV github.com/mholt/certmagic v0.6.2-0.20190624175158-6a42ef9fe8c2/go.mod h1:g4cOPxcjV0oFq3qwpjSA30LReKD8AoIfwAY9VvG35NY= github.com/miekg/dns v1.1.3/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.4/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721 h1:RlZweED6sbSArvlE924+mUcZuXKLBHA35U7LN621Bws= +github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721/go.mod h1:Ickgr2WtCLZ2MDGd4Gr0geeCH5HybhRJbonOgQpvSxc= github.com/mindprince/gonvml v0.0.0-20190828220739-9ebdce4bb989/go.mod h1:2eu9pRWp8mo84xCg6KswZ+USQHjwgRhNp06sozOdsTY= github.com/mistifyio/go-zfs v2.1.1+incompatible/go.mod h1:8AuVvqP/mXw1px98n46wfvcGfQ4ci2FwoAjKYxuo3Z4= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= diff --git a/pkg/daemon/utils/ip_range.go b/pkg/daemon/utils/ip_range.go index 0a22dd99..50af491b 100644 --- a/pkg/daemon/utils/ip_range.go +++ b/pkg/daemon/utils/ip_range.go @@ -18,10 +18,11 @@ package utils import ( "fmt" - "math/big" "net" "sort" + "github.com/mikioh/ipaddr" + "github.com/containernetworking/plugins/pkg/ip" ) @@ -171,20 +172,16 @@ func (ir *IPRange) splitIPRangeToIPBlocks() []*net.IPNet { } func calculateIPLastZeroBits(ip net.IP) int { - zeroBits := 0 - for { - nextPossibleZeroBits := zeroBits + 1 - ipInt := ipToInt(ip) - ipUint64 := ipInt.Uint64() + testMaskBits := net.IPv4len * 8 + if ip.To4() == nil { + testMaskBits = net.IPv6len * 8 + } - if ipUint64 == (ipUint64>>nextPossibleZeroBits)< Date: Thu, 18 Nov 2021 14:25:02 +0800 Subject: [PATCH 2/4] Merge pull request #120 from alibaba/enhace/shortcircuit-terminating-pods controller: short-circuit terminating pods before enqueuing --- pkg/controller/ipam/pod.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/controller/ipam/pod.go b/pkg/controller/ipam/pod.go index 4e1dc0d7..7774f5a4 100644 --- a/pkg/controller/ipam/pod.go +++ b/pkg/controller/ipam/pod.go @@ -81,6 +81,12 @@ func (c *Controller) updatePod(oldObj, newObj interface{}) { return } + // short-circuit terminating pods because ip instances will be + // recycled asynchronously + if new.DeletionTimestamp != nil { + return + } + c.enqueuePod(new) } From 2a66ca2e840f4c35a69142f0e9b7e613904561ad Mon Sep 17 00:00:00 2001 From: Bruce Ma Date: Mon, 29 Nov 2021 20:57:01 +0800 Subject: [PATCH 3/4] Merge pull request #125 from hhyasdf/bugfix/fix-vlan-ensure-error bugfix: fix vlan interface ensure error --- pkg/daemon/containernetwork/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/daemon/containernetwork/utils.go b/pkg/daemon/containernetwork/utils.go index 6666abd9..810bd1ef 100644 --- a/pkg/daemon/containernetwork/utils.go +++ b/pkg/daemon/containernetwork/utils.go @@ -75,7 +75,7 @@ func EnsureVlanIf(nodeIfName string, vlanID *uint32) (string, error) { return "", fmt.Errorf("failed to ensure bridge: %v", err) } - // find the vlan interface to attach to bridge, create if not exist + // create the vlan interface if not exist var vlanIf netlink.Link if vlanIf, err = netlink.LinkByName(vlanIfName); err != nil { if vlanIfName == nodeIfName { @@ -90,7 +90,7 @@ func EnsureVlanIf(nodeIfName string, vlanID *uint32) (string, error) { vif.ParentIndex = nodeIf.Attrs().Index vif.Name = vlanIfName - err = netlink.LinkAdd(vlanIf) + err = netlink.LinkAdd(vif) if err != nil { return vlanIfName, err } From a5191cf5846296838c803ff369e330558ed2a10d Mon Sep 17 00:00:00 2001 From: hhyasdf <552483776@qq.com> Date: Tue, 30 Nov 2021 11:22:39 +0800 Subject: [PATCH 4/4] release: cherry-picks commits for v0.3.2 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45cc5fef..d37a78c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,3 +68,11 @@ All notable changes to this project will be documented in this file. ### Fixed Issues - Avoid permanent exit of arp proxy on large-scale clusters + +## v0.3.2 +### Improvements +- Short-circuit terminating pods before enqueuing in manager controller + +### Fixed Issues +- Fix ipv6 address range calculation error +- Fix nil point dereference error while creating a vlan interface