X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fmanagers%2Fran_reconnection_manager.go;h=484b748c0bbc31f9486ea364a4ceaf45d9abeae5;hb=refs%2Fheads%2FPI3;hp=16614b171f38094abde4cf6af2c0395ac99c83f0;hpb=5660067626f34d1fac7753ea4eb5c5c99f93192e;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/managers/ran_reconnection_manager.go b/E2Manager/managers/ran_reconnection_manager.go index 16614b1..484b748 100644 --- a/E2Manager/managers/ran_reconnection_manager.go +++ b/E2Manager/managers/ran_reconnection_manager.go @@ -61,14 +61,15 @@ func (m *RanReconnectionManager) ReconnectRan(inventoryName string) error { m.logger.Infof("#RanReconnectionManager.ReconnectRan - RAN name: %s - RAN's connection status: %s, RAN's connection attempts: %d", nodebInfo.RanName, nodebInfo.ConnectionStatus, nodebInfo.ConnectionAttempts) if !m.canReconnectRan(nodebInfo) { - err := m.setConnectionStatusOfUnconnectableRan(nodebInfo) + e2tAddress := nodebInfo.AssociatedE2TInstanceAddress + err := m.updateUnconnectableRan(nodebInfo) if err != nil { return err } if m.isRanExceededConnectionAttempts(nodebInfo) { - return m.e2tInstancesManager.DeassociateRan(nodebInfo.RanName, nodebInfo.AssociatedE2TInstanceAddress) + return m.e2tInstancesManager.DissociateRan(nodebInfo.RanName, e2tAddress) } return nil @@ -90,39 +91,41 @@ func (m *RanReconnectionManager) canReconnectRan(nodebInfo *entities.NodebInfo) int(nodebInfo.GetConnectionAttempts()) < m.config.MaxConnectionAttempts } -func (m *RanReconnectionManager) updateNodebInfoStatus(nodebInfo *entities.NodebInfo, connectionStatus entities.ConnectionStatus) error { - if nodebInfo.ConnectionStatus == connectionStatus { - return nil - } +func (m *RanReconnectionManager) updateNodebInfo(nodebInfo *entities.NodebInfo, connectionStatus entities.ConnectionStatus, resetE2tAddress bool) error { nodebInfo.ConnectionStatus = connectionStatus; + + if resetE2tAddress { + nodebInfo.AssociatedE2TInstanceAddress = "" + } + err := m.rnibDataService.UpdateNodebInfo(nodebInfo) if err != nil { - m.logger.Errorf("#RanReconnectionManager.updateNodebInfoStatus - RAN name: %s - Failed updating RAN's connection status to %s in rNib. Error: %v", nodebInfo.RanName, connectionStatus, err) + m.logger.Errorf("#RanReconnectionManager.updateNodebInfo - RAN name: %s - Failed updating RAN's connection status to %s in rNib. Error: %v", nodebInfo.RanName, connectionStatus, err) return err } - m.logger.Infof("#RanReconnectionManager.updateNodebInfoStatus - RAN name: %s - Successfully updated rNib. RAN's current connection status: %s", nodebInfo.RanName, nodebInfo.ConnectionStatus) + m.logger.Infof("#RanReconnectionManager.updateNodebInfo - RAN name: %s - Successfully updated rNib. RAN's current connection status: %s", nodebInfo.RanName, nodebInfo.ConnectionStatus) return nil } -func (m *RanReconnectionManager) setConnectionStatusOfUnconnectableRan(nodebInfo *entities.NodebInfo) error { +func (m *RanReconnectionManager) updateUnconnectableRan(nodebInfo *entities.NodebInfo) error { connectionStatus := nodebInfo.GetConnectionStatus() if connectionStatus == entities.ConnectionStatus_SHUT_DOWN { - m.logger.Warnf("#RanReconnectionManager.ReconnectRan - RAN name: %s - Cannot reconnect RAN. Reason: connection status is SHUT_DOWN", nodebInfo.RanName) + m.logger.Warnf("#RanReconnectionManager.updateUnconnectableRan - RAN name: %s - Cannot reconnect RAN. Reason: connection status is SHUT_DOWN", nodebInfo.RanName) return nil } if connectionStatus == entities.ConnectionStatus_SHUTTING_DOWN { - m.logger.Warnf("#RanReconnectionManager.ReconnectRan - RAN name: %s - Cannot reconnect RAN. Reason: connection status is SHUTTING_DOWN", nodebInfo.RanName) - return m.updateNodebInfoStatus(nodebInfo, entities.ConnectionStatus_SHUT_DOWN) + m.logger.Warnf("#RanReconnectionManager.updateUnconnectableRan - RAN name: %s - Cannot reconnect RAN. Reason: connection status is SHUTTING_DOWN", nodebInfo.RanName) + return m.updateNodebInfo(nodebInfo, entities.ConnectionStatus_SHUT_DOWN, false) } if m.isRanExceededConnectionAttempts(nodebInfo) { - m.logger.Warnf("#RanReconnectionManager.ReconnectRan - RAN name: %s - Cannot reconnect RAN. Reason: RAN's connection attempts exceeded the limit (%d)", nodebInfo.RanName, m.config.MaxConnectionAttempts) - return m.updateNodebInfoStatus(nodebInfo, entities.ConnectionStatus_DISCONNECTED) + m.logger.Warnf("#RanReconnectionManager.updateUnconnectableRan - RAN name: %s - Cannot reconnect RAN. Reason: RAN's connection attempts exceeded the limit (%d)", nodebInfo.RanName, m.config.MaxConnectionAttempts) + return m.updateNodebInfo(nodebInfo, entities.ConnectionStatus_DISCONNECTED, true) } return nil