diff --git a/pkg/southbound/synchronizer/deviceUpdate.go b/pkg/southbound/synchronizer/deviceUpdate.go index ccd09d8f7..0c5ee834f 100644 --- a/pkg/southbound/synchronizer/deviceUpdate.go +++ b/pkg/southbound/synchronizer/deviceUpdate.go @@ -32,7 +32,6 @@ func (s *Session) updateDevice(id topodevice.ID, connectivity topodevice.Connect log.Info("Update device state") topoDevice, err := s.deviceStore.Get(id) - st, ok := status.FromError(err) // If the device doesn't exist then we should not update its state diff --git a/pkg/southbound/synchronizer/sessionManager.go b/pkg/southbound/synchronizer/sessionManager.go index 1ca6fe1e9..6db03206c 100644 --- a/pkg/southbound/synchronizer/sessionManager.go +++ b/pkg/southbound/synchronizer/sessionManager.go @@ -182,6 +182,23 @@ func (sm *SessionManager) processDeviceEvent(event *topodevice.ListResponse) err return err } case topodevice.ListResponse_UPDATED: + session, ok := sm.sessions[event.Device.ID] + if !ok { + log.Error("Session for the device %v does not exist", event.Device.ID) + return nil + } + // If the address is changed, delete the current session and creates new one + if session.device.Address != event.Device.Address { + err := sm.deleteSession(event.Device) + if err != nil { + return err + } + err = sm.createSession(event.Device) + if err != nil { + return err + } + } + log.Info("Process device event updated") case topodevice.ListResponse_REMOVED: