-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: propagate DG changes to all IMSIs #283
base: main
Are you sure you want to change the base?
feat: propagate DG changes to all IMSIs #283
Conversation
I created an issue to better understand the problem and the purpose of the PR. Please add the reference to it in the PR description. Would it be possible to capture a before and after of the DB content ? like this it would be clearer which fields we are talking about. |
What do you mean by "only subscribers that are added in the same API call of the Device Group update take the new information" ? if the update api call does not include the list of subscribers it means that we are overwriting that list |
ok, looking at the code I think I understood. But I am worried about the case in which you add a DG and add a reference to a Subscriber in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I thought I did not have permission to request changes. Please see the comments I added
updated Signed-off-by: Dario Faccin <[email protected]>
Signed-off-by: Dario Faccin <[email protected]>
240599b
to
cca215e
Compare
proto/server/configEvtHandler.go
Outdated
updateSmfSelectionProviosionedData(snssai, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, dnn, imsi) | ||
for _, imsi := range confData.Msg.DevGroup.Imsis { | ||
/* update only if the imsi is provisioned */ | ||
if imsiData[imsi] != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if imsiData
is kept in memory. What happens if we add Subscriber A, B , C. and they exist in the DevGroup.Imsis
. Then the pod dies and then we update the MBR ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue looks to me independent from this PR, as the same logic is already in place. I can try to fix it in this same PR or open a new one, I don't have a strong opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to me it's part of this PR. the fix would not be completed if we do not handle this edge case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I try to build I get the error:
proto/server/clientEvtHandler.go:978:21: undefined: imsiData
Signed-off-by: Dario Faccin <[email protected]>
Signed-off-by: Dario Faccin <[email protected]>
94b81a1
to
4e2bb9d
Compare
proto/server/configEvtHandler.go
Outdated
updateAmProvisionedData(snssai, confData.Msg.DevGroup.IpDomainExpanded.UeDnnQos, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, imsi) | ||
updateSmProvisionedData(snssai, confData.Msg.DevGroup.IpDomainExpanded.UeDnnQos, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, dnn, imsi) | ||
updateSmfSelectionProviosionedData(snssai, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, dnn, imsi) | ||
for _, imsi := range confData.Msg.DevGroup.Imsis { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is shared between the DELETE and the POST operation. In the delete operation confData.Msg.DevGroup is nil, so the program crashes if we try to delete a DG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These modifications change the initial behavior of the following workflow in the NMS:
- Create a NS
- DG is automatically created
- Create a Subscriber
Before
subscriptionData.provisionedData.amData
, subscriptionData.provisionedData.smData
, subscriptionData.provisionedData.smfSelectionSubscriptionData
are filled
Now
subscriptionData.provisionedData.amData
, subscriptionData.provisionedData.smData
, subscriptionData.provisionedData.smfSelectionSubscriptionData
are not filled
Signed-off-by: Dario Faccin <[email protected]>
Signed-off-by: Dario Faccin <[email protected]>
proto/server/configEvtHandler.go
Outdated
@@ -607,6 +631,7 @@ func Config5GUpdateHandle(confChan chan *Update5GSubscriberMsg) { | |||
/* is this devicegroup part of any existing slice */ | |||
slice := isDeviceGroupExistInSlice(confData) | |||
if slice != nil { | |||
provisionedSubscribers := getProvisionedSubscribers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would make this in line 646: after the if and before the loop. In case of delete operation we would unnecessarily retrieving the list of subscribers
return provisionedSubscribers | ||
} | ||
|
||
func getSubscriberAuthDataByUeId(ueId string) *models.AuthenticationSubscription { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would move this function to clientEvtHandler.go since it is only used there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In clientEvtHandler
we are not istantiating the DBClient, therefore moving this function there will increase the imports and in general the complexity. In the client handler we are also already importing getAddedImsisList()
func from configEvtHandler
func getProvisionedSubscribers() []string { | ||
rawProvisionedSubscribers, errGetMany := dbadapter.AuthDBClient.RestfulAPIGetMany(authSubsDataColl, nil) | ||
if errGetMany != nil { | ||
logger.DbLog.Warnln(errGetMany) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can inmmediately return here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, if we continue rawProvisionedSubscribers
might be uninitialized and return an nil pointer dereference
in line 405.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can return an empty slice.
filter := bson.M{"ueId": ueId} | ||
subscriberAuthDataInterface, errGetOne := dbadapter.AuthDBClient.RestfulAPIGetOne(authSubsDataColl, filter) | ||
if errGetOne != nil { | ||
logger.DbLog.Warnln(errGetOne) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can immediately return here
@@ -355,9 +348,10 @@ func getAddedImsisList(group, prevGroup *configmodels.DeviceGroups) (aimsis []st | |||
if group == nil { | |||
return | |||
} | |||
provisionedSubscribers := getProvisionedSubscribers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am concerned that here you are using the information in authSubsDataColl
but that table is only filled up in factory.WebUIConfig.Configuration.Mode5G
Do you know what happens in all the function in clientEvtHandler
that use getAddedImsisList
? are all of them used when factory.WebUIConfig.Configuration.Mode5G
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In clientEvtHandler
when 5GMode
is disabled there are other functions (in this case, postConfigHss
) that take care of the subscribers and these are using another functions (in this case, addedImsis()
and deletedImsis()
).
func getProvisionedSubscribers() []string { | ||
rawProvisionedSubscribers, errGetMany := dbadapter.AuthDBClient.RestfulAPIGetMany(authSubsDataColl, nil) | ||
if errGetMany != nil { | ||
logger.DbLog.Warnln(errGetMany) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, if we continue rawProvisionedSubscribers
might be uninitialized and return an nil pointer dereference
in line 405.
proto/server/configEvtHandler.go
Outdated
if !ok { | ||
logger.DbLog.Warnf("cannot retrieve ueId for subscriber: %v", rawProvisionedSubscriber) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if !ok { | |
logger.DbLog.Warnf("cannot retrieve ueId for subscriber: %v", rawProvisionedSubscriber) | |
} | |
if !ok { | |
logger.DbLog.Warnf("cannot retrieve ueId for subscriber: %v", rawProvisionedSubscriber) | |
continue | |
} |
If we can not get a proper ueId, we can skip it.
func getProvisionedSubscribers() []string { | ||
rawProvisionedSubscribers, errGetMany := dbadapter.AuthDBClient.RestfulAPIGetMany(authSubsDataColl, nil) | ||
if errGetMany != nil { | ||
logger.DbLog.Warnln(errGetMany) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can return an empty slice.
proto/server/configEvtHandler.go
Outdated
if err != nil { | ||
logger.DbLog.Errorf("could not unmarshall subscriber %v", subscriberAuthDataInterface) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err != nil { | |
logger.DbLog.Errorf("could not unmarshall subscriber %v", subscriberAuthDataInterface) | |
} | |
if err != nil { | |
logger.DbLog.Errorf("could not unmarshall subscriber %v", subscriberAuthDataInterface) | |
return nil | |
} |
We can return here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the point of adding return nil
here: in line 427 we are returning the pointer (return &subscriberAuthData
) which will already be nil
if the unmarshalling failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the project L978 this function is called like below:
authSubsData := getSubscriberAuthDataByUeId("imsi-" + imsi)
if authSubsData == nil {
client.clientLog.Infoln("SIM card details not found for IMSI ", imsi)
continue
}
They do a nil check to skip or continue to execution.
If json.Unmarshal
fails, &subscriberAuthData pointer will keep the location of an empty AuthenticationSubscription struct looking like:
{Opc:{...} PermanentKey:{...} SequenceNumber: ""}
And it will not be nil
. Execution continue and In L983 config.Opc = authSubsData.Opc.OpcValue
will cause a panic as OpcValue
is not reachable.
Hence, instead of returning a pointer of empty struct, we can return nil in L428.
@@ -616,14 +641,19 @@ func Config5GUpdateHandle(confChan chan *Update5GSubscriberMsg) { | |||
Sst: int32(sVal), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shoud return after line 637. If strconv.ParseUint fails, we can not calculate snssai properly.
updateSmProvisionedData(snssai, confData.Msg.DevGroup.IpDomainExpanded.UeDnnQos, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, dnn, imsi) | ||
updateSmfSelectionProviosionedData(snssai, slice.SiteInfo.Plmn.Mcc, slice.SiteInfo.Plmn.Mnc, dnn, imsi) | ||
/* skip delete case */ | ||
if confData.Msg.DevGroup != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move the first if clause outside of this block to increase readability.
if confData.Msg.DevGroup == nil {
logger.DbLog.Warn("DevGroup is nil in confData.Msg")
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If DevGroup
is nil we want to remove the subscribers data from the collections, but not update them. I don't fully understand the comment however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's talk about it. I will ping you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please disregard my comment.
Signed-off-by: Dario Faccin <[email protected]>
Signed-off-by: Dario Faccin <[email protected]>
@dariofaccin, I guess you have tested these changes, correct? I am asking this because I was running a test and I do not see these changes being used, or am I missing something? |
@gab-arrobo, these changes are used to update the subscriber data of a device group whenever the device group is updated. To see the changes the flow is the following:
Let me know, thanks |
@@ -975,7 +975,7 @@ func postConfigHss(client *clientNF, lastDevGroup *configmodels.DeviceGroups, la | |||
} | |||
config.StartImsi = uint64(num) | |||
config.EndImsi = uint64(num) | |||
authSubsData := imsiData[imsi] | |||
authSubsData := getSubscriberAuthDataByUeId("imsi-" + imsi) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this piece of code is executed by the 4G configuration , in which case the authSubsDataColl
used in getSubscriberAuthDataByUeId
will not be filled and authSubsData
will be nil
And it's not 100% clear to me if getAddedImsisList
if only used by 5G code since the code is shared between both configurations so I wouldn't touch it.
please do not merge these changes until thi is fixed
Is this ready for review? I see its in draft state. |
This PR aims to fix the issue for which Access Mobility Data, Session Management Data, SMF Selection Data and Policy Data for subscribers are not refreshed when the Device Group is updated.
Before this PR, only subscribers that are added in the same API call of the Device Group update take the new information. This PR extends the refresh to all the subscribers currently belonging to the DG.
Current behaviour
A device group is created and its representation (only relevant part) in database is the following:
The representation (only relevant part) of the subscriber associated to the device group is the following:
After updating the device group with new MBR data, the representation is the following:
But subscriber data in all the collections is not updated:
The example is taken from the
amData
collection, but it applies also tosmData
and the others.