Skip to content

Commit

Permalink
Silence casting warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Skrzypczak <[email protected]>
  • Loading branch information
sknat committed Nov 7, 2024
1 parent fc11c5b commit c0c8045
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
42 changes: 22 additions & 20 deletions calico-vpp-agent/connectivity/connectivity_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,28 +198,30 @@ func (s *ConnectivityServer) ServeConnectivity(t *tomb.Tomb) error {
s.updateAllIPConnectivity()
}
case common.PeerNodeStateChanged:
old, ok := evt.Old.(*common.LocalNodeSpec)
if !ok {
s.log.Errorf("evt.Old is not a *common.LocalNodeSpec %v", evt.Old)
}
new, ok := evt.New.(*common.LocalNodeSpec)
if !ok {
s.log.Errorf("evt.New is not a *common.LocalNodeSpec %v", evt.New)
}
if old != nil {
if old.IPv4Address != nil {
delete(s.nodeByAddr, old.IPv4Address.IP.String())
}
if old.IPv6Address != nil {
delete(s.nodeByAddr, old.IPv6Address.IP.String())
if evt.Old != nil {
old, ok := evt.Old.(*common.LocalNodeSpec)
if !ok {
s.log.Errorf("evt.Old is not a *common.LocalNodeSpec %v", evt.Old)
} else {
if old.IPv4Address != nil {
delete(s.nodeByAddr, old.IPv4Address.IP.String())
}
if old.IPv6Address != nil {
delete(s.nodeByAddr, old.IPv6Address.IP.String())
}
}
}
if new != nil {
if new.IPv4Address != nil {
s.nodeByAddr[new.IPv4Address.IP.String()] = *new
}
if new.IPv6Address != nil {
s.nodeByAddr[new.IPv6Address.IP.String()] = *new
if evt.New != nil {
new, ok := evt.New.(*common.LocalNodeSpec)
if !ok {
s.log.Errorf("evt.New is not a *common.LocalNodeSpec %v", evt.New)
} else {
if new.IPv4Address != nil {
s.nodeByAddr[new.IPv4Address.IP.String()] = *new
}
if new.IPv6Address != nil {
s.nodeByAddr[new.IPv6Address.IP.String()] = *new
}
}
}
case common.FelixConfChanged:
Expand Down
36 changes: 17 additions & 19 deletions calico-vpp-agent/watchers/uplink_route_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,42 +278,40 @@ func (r *RouteWatcher) WatchRoutes(t *tomb.Tomb) error {
}
}
case common.IpamConfChanged:
old, ok := event.Old.(*proto.IPAMPool)
if !ok {
r.log.Errorf("event.Old is not a (*proto.IPAMPool) %v", event.Old)
goto restart
}
new, ok := event.New.(*proto.IPAMPool)
if !ok {
r.log.Errorf("event.New is not a (*proto.IPAMPool) %v", event.New)
goto restart
}
r.log.Debugf("Received IPAM config update in route watcher old:%+v new:%+v", old, new)
if new == nil {
key := old.Cidr
routes, err := r.getNetworkRoute(key, "")
r.log.Debugf("Received IPAM config update in route watcher old:%+v new:%+v", event.Old, event.New)
if event.New == nil && event.Old != nil {
old, ok := event.Old.(*proto.IPAMPool)
if !ok {
r.log.Errorf("event.Old is not a (*proto.IPAMPool) %v", event.Old)
goto restart
}
routes, err := r.getNetworkRoute(old.Cidr, "")
if err != nil {
r.log.Error("Error getting route from ipam update:", err)
goto restart
}
for _, route := range routes {
err = r.DelRoute(route)
if err != nil {
r.log.Errorf("Cannot delete pool route %s through vpp tap: %v", key, err)
r.log.Errorf("Cannot delete pool route %s through vpp tap: %v", old.Cidr, err)
goto restart
}
}
} else {
key := new.Cidr
routes, err := r.getNetworkRoute(key, "")
} else if event.New != nil {
new, ok := event.New.(*proto.IPAMPool)
if !ok {
r.log.Errorf("event.New is not a (*proto.IPAMPool) %v", event.New)
goto restart
}
routes, err := r.getNetworkRoute(new.Cidr, "")
if err != nil {
r.log.Error("Error getting route from ipam update:", err)
goto restart
}
for _, route := range routes {
err = r.AddRoute(route)
if err != nil {
r.log.Errorf("Cannot add pool route %s through vpp tap: %v", key, err)
r.log.Errorf("Cannot add pool route %s through vpp tap: %v", new.Cidr, err)
goto restart
}
}
Expand Down

0 comments on commit c0c8045

Please sign in to comment.