func (c *bgpNodeUpdateProcessor) OnSyncerStarting() {
	log.Debug("Sync starting called on BGP node update processor")
}
Sync is restarting - nothing to do for this processor.
package updateprocessors
import (
	"errors"
	log "github.com/sirupsen/logrus"
	libapiv3 "github.com/projectcalico/libcalico-go/lib/apis/v3"
	"github.com/projectcalico/libcalico-go/lib/backend/model"
	"github.com/projectcalico/libcalico-go/lib/backend/watchersyncer"
	"github.com/projectcalico/libcalico-go/lib/net"
	cnet "github.com/projectcalico/libcalico-go/lib/net"
)
func NewBGPNodeUpdateProcessor(usePodCIDR bool) watchersyncer.SyncerUpdateProcessor {
	return &bgpNodeUpdateProcessor{
		usePodCIDR:      usePodCIDR,
		nodeCIDRTracker: newNodeCIDRTracker(),
	}
}
type bgpNodeUpdateProcessor struct {
	usePodCIDR      bool
	nodeCIDRTracker nodeCIDRTracker
}
func (c *bgpNodeUpdateProcessor) Process(kvp *model.KVPair) ([]*model.KVPair, error) {
	name, err := c.extractName(kvp.Key)
	if err != nil {
		return nil, err
	}
	var asNum, ipv4, netv4, ipv6, netv6, rrClusterID interface{}
	var node *libapiv3.Node
	var ok bool
	if kvp.Value != nil {
		node, ok = kvp.Value.(*libapiv3.Node)
		if !ok {
			return nil, errors.New("Incorrect value type - expecting resource of kind Node")
		}
		ipv4 = ""
		ipv6 = ""
		rrClusterID = ""
		if bgp := node.Spec.BGP; bgp != nil {
			if len(bgp.IPv4Address) != 0 {
				ip, cidr, perr := net.ParseCIDROrIP(bgp.IPv4Address)
				if perr == nil {
					ipv4 = ip.String()
					netv4 = cidr.Network().String()
				} else {
					err = perr
				}
			}
			if len(bgp.IPv6Address) != 0 {
				ip, cidr, perr := net.ParseCIDROrIP(bgp.IPv6Address)
				if perr == nil {
					ipv6 = ip.String()
					netv6 = cidr.Network().String()
				} else if err == nil {
					err = perr
				}
			}
			if bgp.ASNumber != nil {
				asNum = bgp.ASNumber.String()
			}
			rrClusterID = bgp.RouteReflectorClusterID
		}
	}
	kvps := []*model.KVPair{
		{
			Key: model.NodeBGPConfigKey{
				Nodename: name,
				Name:     "ip_addr_v4",
			},
			Value:    ipv4,
			Revision: kvp.Revision,
		},
		{
			Key: model.NodeBGPConfigKey{
				Nodename: name,
				Name:     "ip_addr_v6",
			},
			Value:    ipv6,
			Revision: kvp.Revision,
		},
		{
			Key: model.NodeBGPConfigKey{
				Nodename: name,
				Name:     "network_v4",
			},
			Value:    netv4,
			Revision: kvp.Revision,
		},
		{
			Key: model.NodeBGPConfigKey{
				Nodename: name,
				Name:     "network_v6",
			},
			Value:    netv6,
			Revision: kvp.Revision,
		},
		{
			Key: model.NodeBGPConfigKey{
				Nodename: name,
				Name:     "as_num",
			},
			Value:    asNum,
			Revision: kvp.Revision,
		},
		{
			Key: model.NodeBGPConfigKey{
				Nodename: name,
				Name:     "rr_cluster_id",
			},
			Value:    rrClusterID,
			Revision: kvp.Revision,
		},
	}
	if c.usePodCIDR {
		var currentPodCIDRs []string
		if node != nil {
			currentPodCIDRs = node.Status.PodCIDRs
		}
		toRemove := c.nodeCIDRTracker.SetNodeCIDRs(name, currentPodCIDRs)
		for _, c := range toRemove {
			_, cidr, err := cnet.ParseCIDR(c)
			if err != nil {
				log.WithError(err).WithField("CIDR", c).Warn("Failed to parse Node PodCIDR")
				continue
			}
			kvps = append(kvps, &model.KVPair{
				Key:      model.BlockAffinityKey{Host: name, CIDR: *cidr},
				Value:    nil,
				Revision: kvp.Revision,
			})
		}
		for _, c := range currentPodCIDRs {
			_, cidr, err := cnet.ParseCIDR(c)
			if err != nil {
				log.WithError(err).WithField("CIDR", c).Warn("Failed to parse Node PodCIDR")
				continue
			}
			kvps = append(kvps, &model.KVPair{
				Key:      model.BlockAffinityKey{Host: name, CIDR: *cidr},
				Value:    &model.BlockAffinity{State: model.StateConfirmed},
				Revision: kvp.Revision,
			})
		}
	}
	return kvps, err
}