Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence casting warnings #707

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading