Skip to content

Commit

Permalink
feat(subscriberdb): Handle NW NGC config nil check correctly
Browse files Browse the repository at this point in the history
Signed-off-by: Moinuddin Khan <moinuddin.khan@wavelabs.ai>
  • Loading branch information
moinuddin1980 committed Jun 28, 2022
1 parent 321d740 commit 492c05a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 9 additions & 6 deletions lte/cloud/go/services/subscriberdb/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,19 @@ func LoadSuciProtos(ctx context.Context, networkID string) ([]*lte_protos.SuciPr
return nil, fmt.Errorf("network loading failed: %w", err)
}

suciProtos := []*lte_protos.SuciProfile{}

ngcModel := &lte_models.NetworkNgcConfigs{}
ngcConfig := ngcModel.GetFromNetwork(network).(*lte_models.NetworkNgcConfigs)
ngcConfig := ngcModel.GetFromNetwork(network)
if ngcConfig == nil {
return nil, fmt.Errorf("ngcConfig is nil: %w", err)
return suciProtos, fmt.Errorf("ngcConfig is nil: %w", err)
}

suciProfiles := ngcConfig.SuciProfiles
suciProtos := []*lte_protos.SuciProfile{}
for _, suciProfile := range suciProfiles {
suciProtos = append(suciProtos, ngcModel.ConvertSuciEntsToProtos(suciProfile))
if ngcConfig.(*lte_models.NetworkNgcConfigs) != nil {
suciProfiles := ngcConfig.(*lte_models.NetworkNgcConfigs).SuciProfiles
for _, suciProfile := range suciProfiles {
suciProtos = append(suciProtos, ngcModel.ConvertSuciEntsToProtos(suciProfile))
}
}

return suciProtos, nil
Expand Down
6 changes: 2 additions & 4 deletions lte/gateway/python/magma/subscriberdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ def __init__(

async def _run(self) -> None:

suciprofiles_info = await self._list_suciprofiles()
if suciprofiles_info is None:
return

in_sync = await self._check_subscribers_in_sync()
if in_sync:
return
Expand All @@ -130,6 +126,8 @@ async def _run(self) -> None:
self._update_root_digest(subscribers_info.root_digest)
self._update_leaf_digests(subscribers_info.leaf_digests)

await self._list_suciprofiles()

async def _check_subscribers_in_sync(self) -> bool:
"""
Check if the local subscriber data is up-to-date with the cloud by
Expand Down

0 comments on commit 492c05a

Please sign in to comment.