From f44377db11001585180cb1a41452a12bfd44546f Mon Sep 17 00:00:00 2001 From: Juha Hyttinen Date: Wed, 12 Feb 2020 10:18:40 +0200 Subject: [PATCH] Fixed subs release to be more robust Dockerfile to have version of rtmgr Change-Id: If539ca84a3a6cc61dc46f806c06fdeb37e8a40d4 Signed-off-by: Juha Hyttinen --- Dockerfile | 31 ++++++++++++++++------- api/routing_manager.yaml | 6 ++--- pkg/control/control.go | 4 +-- pkg/control/registry.go | 66 +++++++++++++++++++++++++----------------------- 4 files changed, 61 insertions(+), 46 deletions(-) diff --git a/Dockerfile b/Dockerfile index 057f4e8..89811c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,11 @@ # Abstract: Builds a container to compile Subscription Manager's code # Date: 28 May 2019 # -FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:3-u18.04-nng as submgrprebuild + +########################################################### +# +########################################################### +FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:3-u18.04-nng as submgrcore RUN apt update && apt install -y iputils-ping net-tools curl tcpdump gdb valgrind @@ -45,11 +49,12 @@ RUN /usr/local/go/bin/go get -u github.com/go-delve/delve/cmd/dlv WORKDIR /opt/submgr -RUN mkdir pkg - -# -# +########################################################### # +########################################################### +FROM submgrcore as submgre2apbuild + + ENV CFLAGS="-DASN_DISABLE_OER_SUPPORT" ENV CGO_CFLAGS="-DASN_DISABLE_OER_SUPPORT" @@ -80,7 +85,10 @@ RUN cd e2ap && test -z "$(/usr/local/go/bin/gofmt -l pkg/e2ap/*.go)" RUN cd e2ap && test -z "$(/usr/local/go/bin/gofmt -l pkg/e2ap/e2ap_tests/*.go)" -FROM submgrprebuild as submgrbuild +########################################################### +# +########################################################### +FROM submgre2apbuild as submgrbuild # # # @@ -92,13 +100,18 @@ RUN /usr/local/go/bin/go mod download # # # +RUN mkdir pkg COPY api api -# "Getting and generating routing managers api client" + +ARG RTMGRVERSION=cd7867c8f527f46fd8702b0b8d6b380a8e134bea + RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \ + && git -C "rtmgr" checkout $RTMGRVERSION \ && cp rtmgr/api/routing_manager.yaml api/ \ && rm -rf rtmgr + RUN mkdir -p /root/go && \ /usr/local/go/bin/swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client @@ -134,9 +147,9 @@ RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/teststube2ap/*.go)" RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/xapptweaks/*.go)" +########################################################### # -# -# +########################################################### FROM ubuntu:18.04 RUN apt update && apt install -y iputils-ping net-tools curl tcpdump diff --git a/api/routing_manager.yaml b/api/routing_manager.yaml index c2dacfa..c8a742b 100644 --- a/api/routing_manager.yaml +++ b/api/routing_manager.yaml @@ -177,7 +177,7 @@ paths: description: "Invalid data" 201: description: "Xapp list received" - /handles/v1/e2t: + /handles/e2t: post: tags: - "handle" @@ -226,7 +226,7 @@ paths: description: "Invalid data" 201: description: "new e2t instance is considered and platform routes are established" - /handles/v1/associate-ran-to-e2t: + /handles/associate-ran-to-e2t: post: tags: - "handle" @@ -251,7 +251,7 @@ paths: description: "Invalid data" 201: description: "e2t ran mapping recieved, platform routes" - /handles/v1/dissociate-ran: + /handles/dissociate-ran: post: tags: - "handle" diff --git a/pkg/control/control.go b/pkg/control/control.go index 1103727..094e020 100755 --- a/pkg/control/control.go +++ b/pkg/control/control.go @@ -232,7 +232,7 @@ func (c *Control) handleXAPPSubscriptionRequest(params *xapptweaks.RMRParams) { } } xapp.Logger.Info("XAPP-SubReq: failed %s", idstring(err, trans, subs)) - go c.registry.RemoveFromSubscription(subs, trans, 5*time.Second) + c.registry.RemoveFromSubscription(subs, trans, 5*time.Second) } //------------------------------------------------------------------- @@ -283,7 +283,7 @@ func (c *Control) handleXAPPSubscriptionDeleteRequest(params *xapptweaks.RMRPara c.rmrSendToXapp("", subs, trans) } - go c.registry.RemoveFromSubscription(subs, trans, 5*time.Second) + c.registry.RemoveFromSubscription(subs, trans, 5*time.Second) } //------------------------------------------------------------------- diff --git a/pkg/control/registry.go b/pkg/control/registry.go index c9abdb8..9cacd94 100644 --- a/pkg/control/registry.go +++ b/pkg/control/registry.go @@ -217,44 +217,46 @@ func (r *Registry) RemoveFromSubscription(subs *Subscription, trans *Transaction return nil } - r.mutex.Unlock() + go func() { + if waitRouteClean > 0 { + time.Sleep(waitRouteClean) + } - // - // Wait some time before really do route updates - // - if waitRouteClean > 0 { - subs.mutex.Unlock() - time.Sleep(waitRouteClean) subs.mutex.Lock() - } + defer subs.mutex.Unlock() + xapp.Logger.Info("CLEAN %s", subs.String()) - xapp.Logger.Info("CLEAN %s", subs.String()) + if epamount == 0 { + // + // Subscription route delete + // + tmpList := RmrEndpointList{} + tmpList.AddEndpoint(trans.GetEndpoint()) + subRouteAction := SubRouteInfo{tmpList, uint16(seqId)} + r.rtmgrClient.SubscriptionRequestDelete(subRouteAction) - // - // Subscription route updates - // - if epamount == 0 { - tmpList := RmrEndpointList{} - tmpList.AddEndpoint(trans.GetEndpoint()) - subRouteAction := SubRouteInfo{tmpList, uint16(seqId)} - r.rtmgrClient.SubscriptionRequestDelete(subRouteAction) - } else if subs.EpList.Size() > 0 { - subRouteAction := SubRouteInfo{subs.EpList, uint16(seqId)} - r.rtmgrClient.SubscriptionRequestUpdate(subRouteAction) - } + // + // Subscription release + // + r.mutex.Lock() + defer r.mutex.Unlock() - r.mutex.Lock() - // - // If last endpoint, release and free seqid - // - if epamount == 0 { - if _, ok := r.register[seqId]; ok { - xapp.Logger.Debug("RELEASE %s", subs.String()) - delete(r.register, seqId) - xapp.Logger.Debug("Registry: substable=%v", r.register) + if _, ok := r.register[seqId]; ok { + xapp.Logger.Debug("RELEASE %s", subs.String()) + delete(r.register, seqId) + xapp.Logger.Debug("Registry: substable=%v", r.register) + } + r.subIds = append(r.subIds, seqId) + + } else if subs.EpList.Size() > 0 { + // + // Subscription route updates + // + subRouteAction := SubRouteInfo{subs.EpList, uint16(seqId)} + r.rtmgrClient.SubscriptionRequestUpdate(subRouteAction) } - r.subIds = append(r.subIds, seqId) - } + + }() return nil } -- 2.16.6