From: naman.gupta Date: Thu, 20 Apr 2023 12:37:11 +0000 (+0530) Subject: Delete all subscriptions when Ran is under reset. X-Git-Tag: 0.9.6~2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=ric-plt%2Fsubmgr.git;a=commitdiff_plain;h=fc67b036d8944c372715b7306f892d2ddfb4684f Delete all subscriptions when Ran is under reset. Delete all subscriptions for the Ran when Ran is under reset state. Signed-off-by: naman.gupta Change-Id: I86c488c67c1dc20cfdd958ad65d0ad67a5390be3 --- diff --git a/go.mod b/go.mod index aef4a74..432ba85 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ replace gerrit.o-ran-sc.org/r/ric-plt/e2ap => ./e2ap/ require ( gerrit.o-ran-sc.org/r/ric-plt/e2ap v0.0.0-00010101000000-000000000000 - gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1 + gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.8 gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.8.0 gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.0.0-00010101000000-000000000000 github.com/go-openapi/runtime v0.19.4 diff --git a/go.sum b/go.sum index a75d8f1..9efd6d6 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,7 @@ gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1 h1:3FFbXx55BODThXfyWA gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1 h1:8Z60JRsPgcS1Ona4fEh6d0/03nLq1WHoZcNnBsni5+g= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1/go.mod h1:YaQ+XEI4PcAoISxp9wUpUr2TP0J7JihpQTD0G1Lpd4A= +gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.8/go.mod h1:8NTND7RCHfHPQtx1xk9oclqF/7usqDAX9aYBzt3Hynk= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1 h1:BG3kste8PLVTG0m8CRB/VP2tAV5JImKueBGuOsUNcR8= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1/go.mod h1:zX8rW6YEsagHrRGVW5YO50Ku/Csrpzsuvblhr4DbYi4= gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.8.0 h1:H7GtCRC+pGn6oOxYalUZr7LinQX5jQCVa+ConX7PB5Q= diff --git a/pkg/control/e2if_state.go b/pkg/control/e2if_state.go index b86ef81..5f7eb35 100644 --- a/pkg/control/e2if_state.go +++ b/pkg/control/e2if_state.go @@ -22,9 +22,10 @@ package control import ( "encoding/json" "fmt" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" "strings" "sync" + + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" ) type XappRnibIf struct { @@ -117,6 +118,18 @@ func (e *E2IfState) NotificationCb(ch string, events ...string) { delete(e.NbIdMap, nbId) e.control.registry.DeleteAllE2Subscriptions(nbId, e.control) } + } else if strings.Contains(events[0], "_UNDER_RESET") { + xapp.Logger.Debug("NotificationCb UNDER_RESET len(nbId) == 0 ") + e.control.UpdateCounter(cE2StateUnderReset) + nbId, err := ExtractNbiIdFromString(events[0]) + if err != nil { + xapp.Logger.Error("NotificationCb _UNDER_RESET %v ", err) + return + } + xapp.Logger.Debug("E2 Under Reset. NbId=%s", nbId) + if _, ok := e.NbIdMap[nbId]; ok { + e.control.registry.DeleteAllE2Subscriptions(nbId, e.control) + } } } @@ -197,6 +210,9 @@ func ExtractNbiIdFromString(s string) (string, error) { } else if strings.Contains(s, "_DISCONNECTED") { splitStringTbl := strings.Split(s, "_DISCONNECTED") nbId = splitStringTbl[0] + } else if strings.Contains(s, "_UNDER_RESET") { + splitStringTbl := strings.Split(s, "_UNDER_RESET") + nbId = splitStringTbl[0] } if len(nbId) == 0 { return "", fmt.Errorf("ExtractNbiIdFromString(): len(nbId) == 0 ") diff --git a/pkg/control/e2if_state_test.go b/pkg/control/e2if_state_test.go index e4ee848..09ee212 100644 --- a/pkg/control/e2if_state_test.go +++ b/pkg/control/e2if_state_test.go @@ -71,6 +71,7 @@ func TestMock(t *testing.T) { xappRnibMock.CreateGnb("gnb_369_11105_aaaaa3", entities.ConnectionStatus_SHUTTING_DOWN) xappRnibMock.CreateGnb("gnb_369_11105_aaaaa3", entities.ConnectionStatus_SHUT_DOWN) xappRnibMock.CreateGnb("gnb_369_11105_aaaaa3", entities.ConnectionStatus_DISCONNECTED) + xappRnibMock.CreateGnb("gnb_369_11105_aaaaa3", entities.ConnectionStatus_UNDER_RESET) mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib() mainCtrl.c.e2IfState.SubscribeChannels() @@ -92,6 +93,9 @@ func TestMock(t *testing.T) { if err := xappRnibMock.XappRnibStoreAndPublish("RAN_CONNECTION_STATUS_CHANGE", "gnb_369_11105_aaaaa3_DISCONNECTED", "key1", "data1"); err != nil { t.Errorf("XappRnibStoreAndPublish failed: %v", err) } + if err := xappRnibMock.XappRnibStoreAndPublish("RAN_CONNECTION_STATUS_CHANGE", "gnb_369_11105_aaaaa3_UNDER_RESET", "key1", "data1"); err != nil { + t.Errorf("XappRnibStoreAndPublish failed: %v", err) + } } func (x *XappRnibMock) CreateGnb(gnbId string, connectionStatus entities.ConnectionStatus) { @@ -237,6 +241,10 @@ func ExtratNbIdAndConnectionStatus(s string) (string, entities.ConnectionStatus, connectionStatus = entities.ConnectionStatus_SHUT_DOWN splitStringTbl := strings.Split(s, "_SHUT_DOWN") nbId = splitStringTbl[0] + } else if strings.Contains(s, "_UNDER_RESET") { + connectionStatus = entities.ConnectionStatus_UNDER_RESET + splitStringTbl := strings.Split(s, "_UNDER_RESET") + nbId = splitStringTbl[0] } else { return "", 0, fmt.Errorf("XappRnibMock: Invalid connection status. %s", s) } diff --git a/pkg/control/metrics.go b/pkg/control/metrics.go index 4b1b12e..3c875ca 100644 --- a/pkg/control/metrics.go +++ b/pkg/control/metrics.go @@ -43,6 +43,7 @@ const ( cSDLRemoveFailure string = "SDLRemoveFailure" cE2StateChangedToUp string = "E2StateChangedToUp" cE2StateChangedToDown string = "E2StateChangedToDown" + cE2StateUnderReset string = "E2StateChangedToUnderReset" ) func GetMetricsOpts() []xapp.CounterOpts { @@ -93,6 +94,7 @@ func GetMetricsOpts() []xapp.CounterOpts { // E2 interface state counters {Name: cE2StateChangedToUp, Help: "The total number of E2 interface change connected state"}, {Name: cE2StateChangedToDown, Help: "The total number of E2 interface change disconnected state"}, + {Name: cE2StateUnderReset, Help: "The total number of E2 interface change under reset state"}, } } diff --git a/pkg/control/metrics_test.go b/pkg/control/metrics_test.go index bf44a62..485f395 100644 --- a/pkg/control/metrics_test.go +++ b/pkg/control/metrics_test.go @@ -64,6 +64,7 @@ func TestAddAllCountersOnce(t *testing.T) { Counter{cSDLRemoveFailure, 1}, Counter{cE2StateChangedToUp, 1}, Counter{cE2StateChangedToDown, 1}, + Counter{cE2StateUnderReset, 1}, }) mainCtrl.c.UpdateCounter(cSubReqFromXapp) @@ -103,6 +104,7 @@ func TestAddAllCountersOnce(t *testing.T) { mainCtrl.c.UpdateCounter(cSDLRemoveFailure) mainCtrl.c.UpdateCounter(cE2StateChangedToUp) mainCtrl.c.UpdateCounter(cE2StateChangedToDown) + mainCtrl.c.UpdateCounter(cE2StateUnderReset) mainCtrl.VerifyCounterValues(t) }