Skip to content

Commit

Permalink
node_tracker: Track node chassis IDs too.
Browse files Browse the repository at this point in the history
These will be used for per node NB configurations (e.g., load balancer
templates).

Signed-off-by: Dumitru Ceara <dceara@redhat.com>
  • Loading branch information
dceara committed Apr 5, 2023
1 parent b1fba8f commit 9ded3d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions go-controller/pkg/ovn/controller/services/node_tracker.go
Expand Up @@ -42,6 +42,8 @@ type nodeInfo struct {
gatewayRouterName string
// The name of the node's switch - never empty
switchName string
// The chassisID of the node (ovs.external-ids:system-id)
chassisID string
}

// returns a list of all ip blocks "assigned" to this node
Expand Down Expand Up @@ -96,7 +98,8 @@ func newNodeTracker(nodeInformer coreinformers.NodeInformer) (*nodeTracker, erro
// updateNode needs to be called only when hostSubnet annotation has changed or
// if L3Gateway annotation's ip addresses have changed or the name of the node (very rare)
// has changed. No need to trigger update for any other field change.
if util.NodeSubnetAnnotationChanged(oldObj, newObj) || util.NodeL3GatewayAnnotationChanged(oldObj, newObj) || oldObj.Name != newObj.Name {
if util.NodeSubnetAnnotationChanged(oldObj, newObj) || util.NodeL3GatewayAnnotationChanged(oldObj, newObj) ||
util.NodeChassisIDAnnotationChanged(oldObj, newObj) || oldObj.Name != newObj.Name {
nt.updateNode(newObj)
}
},
Expand Down Expand Up @@ -126,13 +129,14 @@ func newNodeTracker(nodeInformer coreinformers.NodeInformer) (*nodeTracker, erro

// updateNodeInfo updates the node info cache, and syncs all services
// if it changed.
func (nt *nodeTracker) updateNodeInfo(nodeName, switchName, routerName string, nodeIPs []string, podSubnets []*net.IPNet) {
func (nt *nodeTracker) updateNodeInfo(nodeName, switchName, routerName, chassisID string, nodeIPs []string, podSubnets []*net.IPNet) {
ni := nodeInfo{
name: nodeName,
nodeIPs: nodeIPs,
podSubnets: make([]net.IPNet, 0, len(podSubnets)),
gatewayRouterName: routerName,
switchName: switchName,
chassisID: chassisID,
}
for i := range podSubnets {
ni.podSubnets = append(ni.podSubnets, *podSubnets[i]) // de-pointer
Expand Down Expand Up @@ -187,6 +191,7 @@ func (nt *nodeTracker) updateNode(node *v1.Node) {
switchName := node.Name
grName := ""
ips := []string{}
chassisID := ""

// if the node has a gateway config, it will soon have a gateway router
// so, set the router name
Expand All @@ -200,12 +205,14 @@ func (nt *nodeTracker) updateNode(node *v1.Node) {
ips = append(ips, ip.IP.String())
}
}
chassisID = gwConf.ChassisID
}

nt.updateNodeInfo(
node.Name,
switchName,
grName,
chassisID,
ips,
hsn,
)
Expand Down
4 changes: 4 additions & 0 deletions go-controller/pkg/util/node_annotations.go
Expand Up @@ -308,6 +308,10 @@ func ParseNodeChassisIDAnnotation(node *kapi.Node) (string, error) {
return chassisID, nil
}

func NodeChassisIDAnnotationChanged(oldNode, newNode *kapi.Node) bool {
return oldNode.Annotations[ovnNodeChassisID] != newNode.Annotations[ovnNodeChassisID]
}

func SetNodeManagementPortMACAddress(nodeAnnotator kube.Annotator, macAddress net.HardwareAddr) error {
return nodeAnnotator.Set(ovnNodeManagementPortMacAddress, macAddress.String())
}
Expand Down

0 comments on commit 9ded3d8

Please sign in to comment.