Skip to content
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

fix: SMF Crash when no CHF running #112

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions internal/sbi/consumer/chf_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ func (s *nchfService) buildConvergedChargingRequest(smContext *smf_context.SMCon
return req
}

func (s *nchfService) SendConvergedChargingRequest(smContext *smf_context.SMContext,
requestType smf_context.RequestType, multipleUnitUsage []models.MultipleUnitUsage,
) (*models.ChargingDataResponse, *models.ProblemDetails, error) {
func (s *nchfService) SendConvergedChargingRequest(
smContext *smf_context.SMContext,
requestType smf_context.RequestType,
multipleUnitUsage []models.MultipleUnitUsage,
) (
*models.ChargingDataResponse, *models.ProblemDetails, error,
) {
logger.ChargingLog.Info("Handle SendConvergedChargingRequest")

req := s.buildConvergedChargingRequest(smContext, multipleUnitUsage)
Expand All @@ -119,13 +123,22 @@ func (s *nchfService) SendConvergedChargingRequest(smContext *smf_context.SMCont
return nil, pd, err
}

if smContext.SelectedCHFProfile.NfServices == nil {
errMsg := "No CHF found"
return nil, openapi.ProblemDetailsDataNotFound(errMsg), fmt.Errorf(errMsg)
}

var client *Nchf_ConvergedCharging.APIClient
// Create Converged Charging Client for this SM Context
for _, service := range *smContext.SelectedCHFProfile.NfServices {
if service.ServiceName == models.ServiceName_NCHF_CONVERGEDCHARGING {
client = s.getConvergedChargingClient(service.ApiPrefix)
}
}
if client == nil {
errMsg := "No CONVERGEDCHARGING-CHF found"
return nil, openapi.ProblemDetailsDataNotFound(errMsg), fmt.Errorf(errMsg)
}

// select the appropriate converged charging service based on trigger type
switch requestType {
Expand Down
8 changes: 5 additions & 3 deletions internal/sbi/consumer/nrf_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,11 @@ func (s *nnrfService) CHFSelection(smContext *smf_context.SMContext) error {
}

// Select CHF from available CHF
smContext.SelectedCHFProfile = rsp.NfInstances[0]

return nil
if len(rsp.NfInstances) > 0 {
smContext.SelectedCHFProfile = rsp.NfInstances[0]
return nil
}
return fmt.Errorf("No CHF found in CHFSelection")
}

// PCFSelection will select PCF for this SM Context
Expand Down
Loading