Skip to content

Commit

Permalink
Fix agent panic because of nil NodeIP in pure IPv6 cluster
Browse files Browse the repository at this point in the history
The nodeConfig.NodeIPv4Addr is nil which would cause panic in agent,
when starting agent with Egress feature enabled in pure IPv6 cluster.

It also adds Egress IPv6 test cases in dual-stack and pure IPv6 cluster.

Related antrea-io#2196

Signed-off-by: Wenqi Qiu <[email protected]>
  • Loading branch information
wenqiq committed Sep 2, 2021
1 parent ff1bf06 commit 0a8b58f
Show file tree
Hide file tree
Showing 8 changed files with 419 additions and 229 deletions.
10 changes: 9 additions & 1 deletion cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,17 @@ func run(o *Options) error {
}

var egressController *egress.EgressController
var nodeIP net.IP
if nodeConfig.NodeIPv4Addr != nil {
nodeIP = nodeConfig.NodeIPv4Addr.IP
} else if nodeConfig.NodeIPv6Addr != nil {
nodeIP = nodeConfig.NodeIPv6Addr.IP
} else {
return fmt.Errorf("invalid NodeIPAddr in Node config: %v", nodeConfig)
}
if features.DefaultFeatureGate.Enabled(features.Egress) {
egressController, err = egress.NewEgressController(
ofClient, antreaClientProvider, crdClient, ifaceStore, routeClient, nodeConfig.Name, nodeConfig.NodeIPv4Addr.IP,
ofClient, antreaClientProvider, crdClient, ifaceStore, routeClient, nodeConfig.Name, nodeIP,
o.config.ClusterMembershipPort, egressInformer, nodeInformer, externalIPPoolInformer,
)
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions pkg/agent/memberlist/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,10 @@ func (c *Cluster) newClusterMember(node *corev1.Node) (string, error) {
return "", fmt.Errorf("obtain IP addresses from K8s Node failed: %v", err)
}
nodeAddr := nodeAddrs.IPv4
fmtStr := "%s:%d"
if nodeAddr == nil {
nodeAddr = nodeAddrs.IPv6
fmtStr = "[%s]:%d"
}
member := fmt.Sprintf(fmtStr, nodeAddr, c.bindPort)
return member, nil
return nodeAddr.String(), nil
}

func (c *Cluster) allClusterMembers() (clusterNodes []string, err error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/util/ndp/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package ndp contains functions to send NDP advertisement on Linux.
// Package ndp contains functions to send NDP neighbor advertisement on Linux.
package ndp
Loading

0 comments on commit 0a8b58f

Please sign in to comment.