Skip to content

Commit

Permalink
include nil check in wrapper in indexer_servicer.go
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander zur Bonsen <alexander.zur.bonsen@tngtech.com>
  • Loading branch information
alexzurbonsen committed May 10, 2022
1 parent c8df06a commit eac469a
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,15 @@ func setSecondaryStates(ctx context.Context, networkID string, states state_type
errs := &multierror.Error{}
if len(sessionIDToIMSI) != 0 {
err := directoryd.MapSessionIDsToIMSIs(ctx, networkID, sessionIDToIMSI)
if err != nil {
errs = multierror.Append(errs, fmt.Errorf("failed to update directoryd mapping of session IDs to IMSIs %+v %v", sessionIDToIMSI, err))
}
errs = errsAppend(errs, "failed to update directoryd mapping of session IDs to IMSIs %+v %v", sessionIDToIMSI, err)
}
if len(cTeidToHwId) != 0 {
err := directoryd.MapSgwCTeidToHWID(ctx, networkID, cTeidToHwId)
if err != nil {
errs = multierror.Append(errs, fmt.Errorf("failed to update directoryd mapping of control plane teid To HwID %+v %v", sessionIDToIMSI, err))
}
errs = errsAppend(errs, "failed to update directoryd mapping of control plane teid To HwID %+v %v", sessionIDToIMSI, err)
}
if len(uTeidToHwId) != 0 {
err := directoryd.MapSgwUTeidToHWID(ctx, networkID, uTeidToHwId)
if err != nil {
errs = multierror.Append(errs, fmt.Errorf("failed to update directoryd mapping of user plane teid To HwID %+v %v", sessionIDToIMSI, err))
}
errs = errsAppend(errs, "failed to update directoryd mapping of user plane teid To HwID %+v %v", sessionIDToIMSI, err)
}

// errs will only be nil if both updates succeeded
Expand Down Expand Up @@ -282,3 +276,11 @@ func getTeidToHwIdPair(tType teidType, record *directoryd_types.DirectoryRecord)
}
return teids, hwid, err
}

// errsAppend concatenates message, sessionIDToIMSI and err into a new error message and appends to errs
func errsAppend(errs *multierror.Error, message string, sessionIDToIMSI map[string]string, err error) *multierror.Error {
if err != nil {
errs = multierror.Append(errs, fmt.Errorf(message, sessionIDToIMSI, err))
}
return errs
}

0 comments on commit eac469a

Please sign in to comment.