Skip to content

Commit

Permalink
chore: Use nrfcache from openapi repository (#281)
Browse files Browse the repository at this point in the history
* chore: Use nrfcache from openapi repository

This PR reduces the decrease the complexity of dependencies by using nrfcahce library from Openapi.

fix: Sove linting issues in the repository

Signed-off-by: gatici <[email protected]>

* fix: update go.mod file

Signed-off-by: gatici <[email protected]>

---------

Signed-off-by: gatici <[email protected]>
  • Loading branch information
gatici authored Aug 16, 2024
1 parent 10ca669 commit b3ce51c
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 18 deletions.
3 changes: 1 addition & 2 deletions amf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ func TestUpdateConfig(t *testing.T) {
}()

time.Sleep(2 * time.Second)
if factory.AmfConfig.Configuration.SupportTAIList != nil &&
len(factory.AmfConfig.Configuration.SupportTAIList) == 2 {
if len(factory.AmfConfig.Configuration.SupportTAIList) == 2 {
fmt.Printf("test passed")
} else {
t.Errorf("test failed")
Expand Down
6 changes: 3 additions & 3 deletions consumer/nf_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import (
amf_context "github.com/omec-project/amf/context"
"github.com/omec-project/amf/logger"
"github.com/omec-project/amf/util"
nrf_cache "github.com/omec-project/nrf/nrfcache"
"github.com/omec-project/openapi/Nnrf_NFDiscovery"
"github.com/omec-project/openapi/models"
nrfCache "github.com/omec-project/openapi/nrfcache"
)

func SendSearchNFInstances(nrfUri string, targetNfType, requestNfType models.NfType,
param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts,
) (models.SearchResult, error) {
if amf_context.AMF_Self().EnableNrfCaching {
return nrf_cache.SearchNFInstances(nrfUri, targetNfType, requestNfType, param)
return nrfCache.SearchNFInstances(nrfUri, targetNfType, requestNfType, param)
} else {
return SendNfDiscoveryToNrf(nrfUri, targetNfType, requestNfType, param)
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func SearchUdmSdmInstance(ue *amf_context.AmfUe, nrfUri string, targetNfType, re
ue.NudmSDMUri = sdmUri
if ue.NudmSDMUri == "" {
err := fmt.Errorf("AMF can not select an UDM by NRF")
logger.ConsumerLog.Errorf(err.Error())
logger.ConsumerLog.Errorln(err.Error())
return err
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion gmm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ func AuthenticationProcedure(ue *context.AmfUe, accessType models.AccessType) (b
}
if ausfUri == "" {
err = fmt.Errorf("AMF can not select an AUSF by NRF")
ue.GmmLog.Errorf(err.Error())
ue.GmmLog.Errorln(err.Error())
return false, err
}
ue.AusfUri = ausfUri
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ require (
github.com/omec-project/metricfunc v1.4.1
github.com/omec-project/nas v1.3.0
github.com/omec-project/ngap v1.2.2
github.com/omec-project/nrf v1.4.1
github.com/omec-project/openapi v1.2.0
github.com/omec-project/openapi v1.2.1
github.com/omec-project/util v1.1.0
github.com/prometheus/client_golang v1.19.1
github.com/sirupsen/logrus v1.9.3
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,8 @@ github.com/omec-project/nas v1.3.0 h1:zNqEQSNTsupT3qP6keSuOusOHKrqEYoC5ghKR8TpKE
github.com/omec-project/nas v1.3.0/go.mod h1:So4hpY95XZTpX0Joco/axIH4MlO0o13UT1rWQWZEuLQ=
github.com/omec-project/ngap v1.2.2 h1:TAeF2IvBL5FIBqJ/8HTRe63q9cAxjPBRhj3jodbxBhg=
github.com/omec-project/ngap v1.2.2/go.mod h1:sPvpU/ahwqoTvFi5IfnzHmJvIxQPnsVCmq7iU/L1lEo=
github.com/omec-project/nrf v1.4.1 h1:/5JaICgZ2URtTe7Bz9/xzEFgHaiaAHTbWcVGr9zek1I=
github.com/omec-project/nrf v1.4.1/go.mod h1:F4JBDAZ9uWUkSjk7fh1lvzuJs8Jxbn2CGIXK8SsiaDI=
github.com/omec-project/openapi v1.2.0 h1:7Wvi0HLvhvxMyQtqGcqtMCPC/0QCGAFP5htrXCfWxRc=
github.com/omec-project/openapi v1.2.0/go.mod h1:hjU13MB1m9MHTko87JfsUNCdeD6/m6VkNZDD8Vq5U9M=
github.com/omec-project/openapi v1.2.1 h1:7ccFadoGfoqZq4sw7twXatbRGmkg4pARe6sWmCVVmrs=
github.com/omec-project/openapi v1.2.1/go.mod h1:hjU13MB1m9MHTko87JfsUNCdeD6/m6VkNZDD8Vq5U9M=
github.com/omec-project/util v1.1.0 h1:TUuLmzqTLChIEXQlK9g5Ihgmw4FUm/UJnjfu0wT8Gz0=
github.com/omec-project/util v1.1.0/go.mod h1:BEv8nCokB4j0fgAQ6VVkKuQ2PSP3DJMEmz25pFMw5X8=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
Expand Down
2 changes: 1 addition & 1 deletion ngap/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ func HandleUplinkNasTransport(ran *context.AmfRan, message *ngapType.NGAPPDU) {
if amfUe == nil {
err := ranUe.Remove()
if err != nil {
ran.Log.Errorf(err.Error())
ran.Log.Errorln(err.Error())
}
ran.Log.Errorf("No UE Context of RanUe with RANUENGAPID[%d] AMFUENGAPID[%d] ",
rANUENGAPID.Value, aMFUENGAPID.Value)
Expand Down
4 changes: 2 additions & 2 deletions producer/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/omec-project/nas/nasConvert"
"github.com/omec-project/nas/nasMessage"
"github.com/omec-project/ngap/ngapType"
nrf_cache "github.com/omec-project/nrf/nrfcache"
"github.com/omec-project/openapi/models"
nrfCache "github.com/omec-project/openapi/nrfcache"
"github.com/omec-project/util/httpwrapper"
)

Expand Down Expand Up @@ -472,7 +472,7 @@ func NfSubscriptionStatusNotifyProcedure(notificationData models.NotificationDat
// This will force the amf to do nf discovery and get the updated nf profile from the nrf.
if notificationData.Event == models.NotificationEventType_DEREGISTERED {
if amf_context.AMF_Self().EnableNrfCaching {
ok := nrf_cache.RemoveNfProfileFromNrfCache(nfInstanceId)
ok := nrfCache.RemoveNfProfileFromNrfCache(nfInstanceId)
logger.ProducerLog.Tracef("nfinstance %v deleted from cache: %v", nfInstanceId, ok)
}
if subscriptionId, ok := amf_context.AMF_Self().NfStatusSubscriptions.Load(nfInstanceId); ok {
Expand Down
2 changes: 1 addition & 1 deletion producer/oam.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func HandleOAMPurgeUEContextRequest(supi, reqUri string, msg interface{}) (inter
ueFsmState := ue.State[models.AccessType__3_GPP_ACCESS].Current()
switch ueFsmState {
case context.Deregistered:
logger.ProducerLog.Info("Removing the UE : ", fmt.Sprintf(ue.Supi))
logger.ProducerLog.Info("Removing the UE : ", fmt.Sprintln(ue.Supi))
ue.Remove()
case context.Registered:
logger.ProducerLog.Info("Deregistration triggered for the UE : ", ue.Supi)
Expand Down
4 changes: 2 additions & 2 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import (
protos "github.com/omec-project/config5g/proto/sdcoreConfig"
nasLogger "github.com/omec-project/nas/logger"
ngapLogger "github.com/omec-project/ngap/logger"
nrf_cache "github.com/omec-project/nrf/nrfcache"
"github.com/omec-project/openapi/models"
nrfCache "github.com/omec-project/openapi/nrfcache"
"github.com/omec-project/util/fsm"
fsmLogger "github.com/omec-project/util/fsm/logger"
"github.com/omec-project/util/http2_util"
Expand Down Expand Up @@ -350,7 +350,7 @@ func (amf *AMF) Start() {

if self.EnableNrfCaching {
initLog.Infoln("Enable NRF caching feature")
nrf_cache.InitNrfCaching(self.NrfCacheEvictionInterval*time.Second, consumer.SendNfDiscoveryToNrf)
nrfCache.InitNrfCaching(self.NrfCacheEvictionInterval*time.Second, consumer.SendNfDiscoveryToNrf)
}

if self.EnableSctpLb {
Expand Down

0 comments on commit b3ce51c

Please sign in to comment.