Delete all subscriptions when Ran is under reset. 62/10962/5
authornaman.gupta <naman.gupta@samsung.com>
Thu, 20 Apr 2023 12:37:11 +0000 (18:07 +0530)
committernaman.gupta <naman.gupta@samsung.com>
Mon, 29 May 2023 07:37:42 +0000 (13:07 +0530)
Delete all subscriptions for the Ran when Ran is under reset state.

Signed-off-by: naman.gupta <naman.gupta@samsung.com>
Change-Id: I86c488c67c1dc20cfdd958ad65d0ad67a5390be3

go.mod
go.sum
pkg/control/e2if_state.go
pkg/control/e2if_state_test.go
pkg/control/metrics.go
pkg/control/metrics_test.go

diff --git a/go.mod b/go.mod
index aef4a74..432ba85 100644 (file)
--- 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 (file)
--- 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=
index b86ef81..5f7eb35 100644 (file)
@@ -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 ")
index e4ee848..09ee212 100644 (file)
@@ -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)
        }
index 4b1b12e..3c875ca 100644 (file)
@@ -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"},
        }
 }
 
index bf44a62..485f395 100644 (file)
@@ -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)
 }