Skip to content

Commit

Permalink
change the name of host-addresses annotation to host-cidrs
Browse files Browse the repository at this point in the history
commit: 8847618 changed the
host-addresses annotation to include a subnet mask. This causes updates
to experiance a network disruption as masters and nodes expect different
data to be in the host-addresses annotation.

Changing the name of the host-addresses annotation to host-cidrs will
eliminate the network disruption because nodes updating will not remove
the host-addresses annotation and once upgraded masters will do the
right thing with the host-cidrs annotation

Signed-off-by: Jacob Tanenbaum <jtanenba@redhat.com>
  • Loading branch information
JacobTanenbaum committed Sep 21, 2023
1 parent 678d784 commit 70d8c71
Show file tree
Hide file tree
Showing 22 changed files with 216 additions and 216 deletions.
8 changes: 4 additions & 4 deletions go-controller/pkg/clustermanager/egressip_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ func (eIPC *egressIPClusterController) getCloudPrivateIPConfigMap(objs []interfa
// assign the egress IP to the node with the lowest amount of allocations every
// time, this does not guarantee complete balance, but mostly complete.
// For Egress IPs that are hosted by non-OVN managed networks, there must be at least
// one node that hosts the network and exposed via the nodes host-addresses annotation.
// one node that hosts the network and exposed via the nodes host-ciders annotation.
func (eIPC *egressIPClusterController) assignEgressIPs(name string, egressIPs []string) []egressipv1.EgressIPStatusItem {
eIPC.allocator.Lock()
defer eIPC.allocator.Unlock()
Expand Down Expand Up @@ -1387,12 +1387,12 @@ func (eIPC *egressIPClusterController) isEgressIPAddrConflict(egressIP net.IP) (
if err != nil {
return false, "", fmt.Errorf("failed to get nodes: %v", err)
}
// iterate through the nodes and ensure no host IP address conflicts with EIP. Note that host-addresses annotation
// iterate through the nodes and ensure no host IP address conflicts with EIP. Note that host-cidrs annotation
// does not contain EgressIPs that are assigned to interfaces.
for _, node := range nodes {
nodeHostAddressesSet, err := util.ParseNodeHostAddressesDropNetMask(node)
nodeHostAddressesSet, err := util.ParseNodeHostCIDRsDropNetMask(node)
if err != nil {
return false, "", fmt.Errorf("failed to parse node host addresses for node %s: %v", node.Name, err)
return false, "", fmt.Errorf("failed to parse node host cidrs for node %s: %v", node.Name, err)
}
if nodeHostAddressesSet.Has(egressIP.String()) {
return true, node.Name, nil
Expand Down
152 changes: 76 additions & 76 deletions go-controller/pkg/clustermanager/egressip_controller_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go-controller/pkg/clustermanager/egressip_event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (h *egressIPClusterControllerEventHandler) UpdateResource(oldObj, newObj in
isOldReady := h.eIPC.isEgressNodeReady(oldNode)
isNewReady := h.eIPC.isEgressNodeReady(newNode)
isNewReachable := h.eIPC.isEgressNodeReachable(newNode)
isHostAddrAltered := util.NodeHostAddressesAnnotationChanged(oldNode, newNode)
isHostAddrAltered := util.NodeHostCIDRsAnnotationChanged(oldNode, newNode)
h.eIPC.setNodeEgressReady(newNode.Name, isNewReady)
if !oldHadEgressLabel && newHasEgressLabel {
klog.Infof("Node: %s has been labeled, adding it for egress assignment", newNode.Name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ func getNodeObj(testNode testNode) corev1.Node {
Annotations: map[string]string{
"k8s.ovn.org/node-primary-ifaddr": fmt.Sprintf("{\"ipv4\": \"%s\", \"ipv6\": \"%s\"}",
node1OVNManagedNetworkV4, ""),
"k8s.ovn.org/host-addresses": fmt.Sprintf("[%s]", strings.Join(hostAddrs, ",")),
util.OVNNodeHostCIDRs: fmt.Sprintf("[%s]", strings.Join(hostAddrs, ",")),
}},
Status: corev1.NodeStatus{
Conditions: []corev1.NodeCondition{
Expand Down
20 changes: 10 additions & 10 deletions go-controller/pkg/node/node_ip_handler_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ func (c *addressManager) runInternal(stopChan <-chan struct{}, doneWg *sync.Wait
}

c.handleNodePrimaryAddrChange()
if addrChanged || !c.doesNodeHostAddressesMatch() {
klog.Infof("Host addresses changed to %v. Updating node address annotation.", c.addresses)
if addrChanged || !c.doNodeHostCIDRsMatch() {
klog.Infof("Host CIDRs changed to %v. Updating node address annotations.", c.addresses)
err := c.updateNodeAddressAnnotations()
if err != nil {
klog.Errorf("Address Manager failed to update node address annotations: %v", err)
Expand Down Expand Up @@ -220,7 +220,7 @@ func (c *addressManager) handleNodePrimaryAddrChange() {
}

// updateNodeAddressAnnotations updates all relevant annotations for the node including
// k8s.ovn.org/host-addresses, k8s.ovn.org/node-primary-ifaddr, k8s.ovn.org/l3-gateway-config.
// k8s.ovn.org/host-cidrs, k8s.ovn.org/node-primary-ifaddr, k8s.ovn.org/l3-gateway-config.
func (c *addressManager) updateNodeAddressAnnotations() error {
var err error
var ifAddrs []*net.IPNet
Expand All @@ -239,7 +239,7 @@ func (c *addressManager) updateNodeAddressAnnotations() error {
}
}

// update k8s.ovn.org/host-addresses
// update k8s.ovn.org/host-cidrs
if err = c.updateHostAddresses(node); err != nil {
return err
}
Expand Down Expand Up @@ -279,10 +279,10 @@ func (c *addressManager) updateHostAddresses(node *kapi.Node) error {
return err
}
nodeAddrSet := sets.New[string](nodeAddrStr)
return util.SetNodeHostAddresses(c.nodeAnnotator, nodeAddrSet)
return util.SetNodeHostCIDRs(c.nodeAnnotator, nodeAddrSet)
}

return util.SetNodeHostAddresses(c.nodeAnnotator, c.addresses)
return util.SetNodeHostCIDRs(c.nodeAnnotator, c.addresses)
}

func (c *addressManager) assignAddresses(nodeHostAddresses sets.Set[string]) bool {
Expand All @@ -296,7 +296,7 @@ func (c *addressManager) assignAddresses(nodeHostAddresses sets.Set[string]) boo
return true
}

func (c *addressManager) doesNodeHostAddressesMatch() bool {
func (c *addressManager) doNodeHostCIDRsMatch() bool {
c.Lock()
defer c.Unlock()

Expand All @@ -306,8 +306,8 @@ func (c *addressManager) doesNodeHostAddressesMatch() bool {
return false
}
// check to see if ips on the node differ from what we stored
// in host-address annotation
nodeHostAddresses, err := util.ParseNodeHostAddresses(node)
// in host-cidrs annotation
nodeHostAddresses, err := util.ParseNodeHostCIDRs(node)
if err != nil {
klog.Errorf("Unable to parse addresses from node host %s: %s", node.Name, err.Error())
return false
Expand Down Expand Up @@ -461,7 +461,7 @@ func (c *addressManager) sync() {

addrChanged := c.assignAddresses(currAddresses)
c.handleNodePrimaryAddrChange()
if addrChanged || !c.doesNodeHostAddressesMatch() {
if addrChanged || !c.doNodeHostCIDRsMatch() {
klog.Infof("Node address changed to %v. Updating annotations.", currAddresses)
err := c.updateNodeAddressAnnotations()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions go-controller/pkg/node/node_ip_handler_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func ipEvent(ipStr string, isAdd bool, addrChan chan netlink.AddrUpdate) *net.IP
func nodeHasAddress(fakeClient kubernetes.Interface, nodeName string, ipNet *net.IPNet) bool {
node, err := fakeClient.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
addrs, err := util.ParseNodeHostAddressesDropNetMask(node)
addrs, err := util.ParseNodeHostCIDRsDropNetMask(node)
Expect(err).NotTo(HaveOccurred())
return addrs.Has(ipNet.IP.String())
}
Expand Down Expand Up @@ -69,7 +69,7 @@ var _ = Describe("Node IP Handler tests", func() {
ObjectMeta: metav1.ObjectMeta{
Name: nodeName,
Annotations: map[string]string{
"k8s.ovn.org/host-addresses": `["10.1.1.10/24", "2001:db8::10/64"]`,
util.OVNNodeHostCIDRs: `["10.1.1.10/24", "2001:db8::10/64"]`,
"k8s.ovn.org/l3-gateway-config": `{"default":{"mac-address":"52:54:00:e2:ed:d0","ip-addresses":["192.168.122.14/24"],"ip-address":"192.168.122.14/24","next-hops":["192.168.122.1"],"next-hop":"192.168.122.1"}}`,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (c *Controller) onNodeUpdate(oldObj, newObj interface{}) {
// addresses
if labels.Equals(oldNodeLabels, newNodeLabels) &&
oldNodeReady == newNodeReady &&
!util.NodeHostAddressesAnnotationChanged(oldNode, newNode) {
!util.NodeHostCIDRsAnnotationChanged(oldNode, newNode) {
return
}

Expand Down
20 changes: 10 additions & 10 deletions go-controller/pkg/ovn/controller/services/node_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ type nodeInfo struct {
name string
// The list of physical IPs reported by the gatewayconf annotation
l3gatewayAddresses []net.IP
// The list of physical IPs the node has, as reported by the host-address annotation
hostAddresses []net.IP
// The list of physical IPs and subnet masks the node has, as reported by the host-cidrs annotation
hostCIDRs []net.IP
// The pod network subnet(s)
podSubnets []net.IPNet
// the name of the node's GatewayRouter, or "" of non-existent
Expand All @@ -60,8 +60,8 @@ type nodeInfo struct {
}

func (ni *nodeInfo) hostAddressesStr() []string {
out := make([]string, 0, len(ni.hostAddresses))
for _, ip := range ni.hostAddresses {
out := make([]string, 0, len(ni.hostCIDRs))
for _, ip := range ni.hostCIDRs {
out = append(out, ip.String())
}
return out
Expand All @@ -79,7 +79,7 @@ func (ni *nodeInfo) l3gatewayAddressesStr() []string {
// includes node IPs, still as a mask-1 net
func (ni *nodeInfo) nodeSubnets() []net.IPNet {
out := append([]net.IPNet{}, ni.podSubnets...)
for _, ip := range ni.hostAddresses {
for _, ip := range ni.hostCIDRs {
if ipv4 := ip.To4(); ipv4 != nil {
out = append(out, net.IPNet{
IP: ip,
Expand Down Expand Up @@ -137,7 +137,7 @@ func (nt *nodeTracker) Start(nodeInformer coreinformers.NodeInformer) (cache.Res
if util.NodeSubnetAnnotationChanged(oldObj, newObj) ||
util.NodeL3GatewayAnnotationChanged(oldObj, newObj) ||
oldObj.Name != newObj.Name ||
util.NodeHostAddressesAnnotationChanged(oldObj, newObj) ||
util.NodeHostCIDRsAnnotationChanged(oldObj, newObj) ||
util.NodeZoneAnnotationChanged(oldObj, newObj) ||
util.NodeMigratedZoneAnnotationChanged(oldObj, newObj) {
nt.updateNode(newObj)
Expand Down Expand Up @@ -166,11 +166,11 @@ func (nt *nodeTracker) Start(nodeInformer coreinformers.NodeInformer) (cache.Res
// updateNodeInfo updates the node info cache, and syncs all services
// if it changed.
func (nt *nodeTracker) updateNodeInfo(nodeName, switchName, routerName, chassisID string, l3gatewayAddresses,
hostAddresses []net.IP, podSubnets []*net.IPNet, zone string, migrated bool) {
hostCIDRs []net.IP, podSubnets []*net.IPNet, zone string, migrated bool) {
ni := nodeInfo{
name: nodeName,
l3gatewayAddresses: l3gatewayAddresses,
hostAddresses: hostAddresses,
hostCIDRs: hostCIDRs,
podSubnets: make([]net.IPNet, 0, len(podSubnets)),
gatewayRouterName: routerName,
switchName: switchName,
Expand Down Expand Up @@ -249,9 +249,9 @@ func (nt *nodeTracker) updateNode(node *v1.Node) {
}
chassisID = gwConf.ChassisID
}
hostAddresses, err := util.ParseNodeHostAddressesDropNetMask(node)
hostAddresses, err := util.ParseNodeHostCIDRsDropNetMask(node)
if err != nil {
klog.Warningf("Failed to get node host addresses for [%s]: %s", node.Name, err.Error())
klog.Warningf("Failed to get node host CIDRs for [%s]: %s", node.Name, err.Error())
hostAddresses = sets.New[string]()
}

Expand Down
12 changes: 6 additions & 6 deletions go-controller/pkg/ovn/controller/services/services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,10 @@ func (c *Controller) syncNodeInfos(nodeInfos []nodeInfo) {
}

if globalconfig.IPv4Mode {
ips, err := util.MatchIPFamily(false, nodeInfo.hostAddresses)
ips, err := util.MatchIPFamily(false, nodeInfo.hostCIDRs)
if err != nil {
klog.Warningf("Error while searching for IPv4 host addresses in %v for node[%s] : %v",
nodeInfo.hostAddresses, nodeInfo.name, err)
klog.Warningf("Error while searching for IPv4 host cidrs in %v for node[%s] : %v",
nodeInfo.hostCIDRs, nodeInfo.name, err)
continue
}

Expand All @@ -481,10 +481,10 @@ func (c *Controller) syncNodeInfos(nodeInfos []nodeInfo) {
}

if globalconfig.IPv6Mode {
ips, err := util.MatchIPFamily(true, nodeInfo.hostAddresses)
ips, err := util.MatchIPFamily(true, nodeInfo.hostCIDRs)
if err != nil {
klog.Warningf("Error while searching for IPv6 host addresses in %v for node[%s] : %v",
nodeInfo.hostAddresses, nodeInfo.name, err)
klog.Warningf("Error while searching for IPv6 host cidrs in %v for node[%s] : %v",
nodeInfo.hostCIDRs, nodeInfo.name, err)
continue
}

Expand Down
2 changes: 1 addition & 1 deletion go-controller/pkg/ovn/default_network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ func (h *defaultNetworkControllerEventHandler) UpdateResource(oldObj, newObj int
h.oc.eIPC.nodeZoneState.Store(newNode.Name, h.oc.isLocalZoneNode(newNode))
h.oc.eIPC.nodeZoneState.UnlockKey(newNode.Name)
// update the nodeIP in the defalt-reRoute (102 priority) destination address-set
if util.NodeHostAddressesAnnotationChanged(oldNode, newNode) {
if util.NodeHostCIDRsAnnotationChanged(oldNode, newNode) {
klog.Infof("Egress IP detected IP address change for node %s. Updating no re-route policies", newNode.Name)
err := h.oc.ensureDefaultNoRerouteNodePolicies()
if err != nil {
Expand Down

0 comments on commit 70d8c71

Please sign in to comment.