Skip to content

Commit

Permalink
[IPv6] Handle dual stack NodeSubnet for monitoring CRD
Browse files Browse the repository at this point in the history
To avoid duplicate CIDRs, this patch makes a new string slice for dual stack
node subnet instead of appending agentInfo.NodeSubnet directly.
  • Loading branch information
mengdie-song committed Aug 31, 2020
1 parent e34fd89 commit d1b941c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pkg/agent/querier/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,15 @@ func (aq agentQuerier) GetAgentInfo(agentInfo *v1beta1.AntreaAgentInfo, partial
agentInfo.Version = querier.GetVersion()
agentInfo.PodRef = querier.GetSelfPod()
agentInfo.NodeRef = querier.GetSelfNode(true, aq.nodeConfig.Name)
// Make a new string slice instead of appending agentInfo.NodeSubnet directly to avoid duplicate CIDRs.
nodeSubnet := make([]string, 0)
if aq.nodeConfig.PodIPv4CIDR != nil {
agentInfo.NodeSubnet = append(agentInfo.NodeSubnet, aq.nodeConfig.PodIPv4CIDR.String())
nodeSubnet = append(nodeSubnet, aq.nodeConfig.PodIPv4CIDR.String())
}
if aq.nodeConfig.PodIPv6CIDR != nil {
agentInfo.NodeSubnet = append(agentInfo.NodeSubnet, aq.nodeConfig.PodIPv6CIDR.String())
nodeSubnet = append(nodeSubnet, aq.nodeConfig.PodIPv6CIDR.String())
}
agentInfo.NodeSubnet = nodeSubnet
agentInfo.OVSInfo.BridgeName = aq.nodeConfig.OVSBridge
agentInfo.APIPort = aq.apiPort
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/querier/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestAgentQuerierGetAgentInfo(t *testing.T) {
expectedAgentInfo: &v1beta1.AntreaAgentInfo{
ObjectMeta: v1.ObjectMeta{Name: "foo"},
NodeRef: corev1.ObjectReference{Kind: "Node", Name: "foo"},
NodeSubnet: nil,
NodeSubnet: []string{},
OVSInfo: v1beta1.OVSInfo{
Version: ovsVersion,
BridgeName: "br-int",
Expand Down

0 comments on commit d1b941c

Please sign in to comment.