Fix for two problems 72/8572/1
authorAnssi Mannila <anssi.mannila@nokia.com>
Thu, 16 Jun 2022 06:47:23 +0000 (09:47 +0300)
committerAnssi Mannila <anssi.mannila@nokia.com>
Thu, 16 Jun 2022 06:50:26 +0000 (09:50 +0300)
 - Submgr sent incorrect error information in response to xapp
   in completely successful case
 - Checking of received E2SubscriptionDirectives was also fixed

Change-Id: Ibd3347f9c8db0e931c95b349f7cbaa789fb24e98
Signed-off-by: Anssi Mannila <anssi.mannila@nokia.com>
pkg/control/control.go
pkg/control/e2ap.go

index 0c97afb..4c0cf9a 100755 (executable)
@@ -445,6 +445,12 @@ func (c *Control) RESTSubscriptionHandler(params interface{}) (*models.Subscript
                return nil, common.SubscribeBadRequestCode
        }
 
+       e2SubscriptionDirectives, err := c.GetE2SubscriptionDirectives(p)
+       if err != nil {
+               xapp.Logger.Error("%s", err)
+               c.UpdateCounter(cRestSubFailToXapp)
+               return nil, common.SubscribeBadRequestCode
+       }
        _, xAppRmrEndpoint, err := ConstructEndpointAddresses(*p.ClientEndpoint)
        if err != nil {
                xapp.Logger.Error("%s", err.Error())
@@ -484,12 +490,6 @@ func (c *Control) RESTSubscriptionHandler(params interface{}) (*models.Subscript
        }
 
        c.WriteRESTSubscriptionToDb(restSubId, restSubscription)
-       e2SubscriptionDirectives, err := c.GetE2SubscriptionDirectives(p)
-       if err != nil {
-               xapp.Logger.Error("%s", err)
-               c.registry.DeleteRESTSubscription(&restSubId)
-               return nil, common.SubscribeBadRequestCode
-       }
        go c.processSubscriptionRequests(restSubscription, &subReqList, p.ClientEndpoint, p.Meid, &restSubId, xAppRmrEndpoint, md5sum, e2SubscriptionDirectives)
 
        c.UpdateCounter(cRestSubRespToXapp)
@@ -698,11 +698,11 @@ func (c *Control) sendUnsuccesfullResponseNotification(restSubId *string, restSu
        restSubscription.SetProcessed(err)
        c.UpdateRESTSubscriptionInDB(*restSubId, restSubscription, false)
        if trans != nil {
-               xapp.Logger.Debug("Sending unsuccessful REST notification (Error cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
-                       errorInfo.ErrorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
+               xapp.Logger.Debug("Sending unsuccessful REST notification: ErrorCause:%s, ErrorSource:%s, TimeoutType:%s, to Endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
+                       errorInfo.ErrorCause, errorInfo.ErrorSource, errorInfo.TimeoutType, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
        } else {
-               xapp.Logger.Debug("Sending unsuccessful REST notification (Error cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v",
-                       errorInfo.ErrorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID)
+               xapp.Logger.Debug("Sending unsuccessful REST notification: ErrorCause:%s, ErrorSource:%s, TimeoutType:%s, to Endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v",
+                       errorInfo.ErrorCause, errorInfo.ErrorSource, errorInfo.TimeoutType, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID)
        }
 
        c.UpdateCounter(cRestSubFailNotifToXapp)
@@ -738,13 +738,8 @@ func (c *Control) sendSuccesfullResponseNotification(restSubId *string, restSubs
        // Mark REST subscription request processesd.
        restSubscription.SetProcessed(nil)
        c.UpdateRESTSubscriptionInDB(*restSubId, restSubscription, false)
-       if errorInfo.ErrorCause != " " {
-               xapp.Logger.Debug("Sending successful REST notification (Error cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
-                       errorInfo.ErrorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
-       } else {
-               xapp.Logger.Debug("Sending successful REST notification to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
-                       clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
-       }
+       xapp.Logger.Debug("Sending successful REST notification: ErrorCause:%s, ErrorSource:%s, TimeoutType:%s, to Endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
+               errorInfo.ErrorCause, errorInfo.ErrorSource, errorInfo.TimeoutType, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
        c.UpdateCounter(cRestSubNotifToXapp)
        xapp.Subscription.Notify(resp, *clientEndpoint)
 
index 1c10846..93bd42d 100644 (file)
@@ -128,6 +128,12 @@ func (e *E2ap) CheckActionNotAdmittedList(msgType int, actionNotAdmittedList e2a
                        actionNotAdmittedString = "ActionNotAdmittedList: " + string(jsonActionNotAdmittedList)
                }
        }
+
+       if msgType == xapp.RIC_SUB_FAILURE {
+               prefixString = "RICSubscriptionFailure"
+               err := fmt.Errorf("%s", prefixString)
+               errorInfo.SetInfo(err.Error(), models.SubscriptionInstanceErrorSourceE2Node, "")
+       }
        err := fmt.Errorf("%s %s", prefixString, actionNotAdmittedString)
        errorInfo.SetInfo(err.Error(), models.SubscriptionInstanceErrorSourceE2Node, "")
        return errorInfo