Skip to content

Commit

Permalink
feat(subscriberdb): Handle NW NGC config nil check correctly (magma#1…
Browse files Browse the repository at this point in the history
…3081)

Signed-off-by: Moinuddin Khan <moinuddin.khan@wavelabs.ai>
  • Loading branch information
moinuddin1980 authored and emakeev committed Aug 5, 2022
1 parent 4d55bef commit 60cf6a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 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
29 changes: 10 additions & 19 deletions lte/gateway/python/magma/subscriberdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,17 @@ 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

resync = await self._sync_subscribers()
if not resync:
return

subscribers_info = await self._get_all_subscribers()
if subscribers_info is None:
return

# failure between the calls
self._process_subscribers(subscribers_info.subscribers)
self._update_root_digest(subscribers_info.root_digest)
self._update_leaf_digests(subscribers_info.leaf_digests)
if not in_sync:
resync = await self._sync_subscribers()
if resync:
subscribers_info = await self._get_all_subscribers()
if subscribers_info:
# failure between the calls
self._process_subscribers(subscribers_info.subscribers)
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:
"""
Expand Down

0 comments on commit 60cf6a0

Please sign in to comment.