Skip to content

Commit

Permalink
fix: return error when no frontend is found
Browse files Browse the repository at this point in the history
  • Loading branch information
danimo authored and Sebastian Neuser committed Jul 8, 2024
1 parent 1f1493f commit 95db19f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ func (o *B3ScaleOperator) innerReconcile(ctx context.Context, op *skop.Operator,
}

if bbbFrontend.Spec.FrontendID == nil || *bbbFrontend.Spec.FrontendID == "" {
level.Debug(o.logger).Log("msg", "frontend UUID not found, trying to read it from b3scale")
var id string

// Try reading ID from existing frontend
existingFrontend, err := getFrontendByName(ctx, *o.apiClient, bbbFrontend.Spec.Credentials.Frontend)
if err == nil {
id = existingFrontend.ID
} else {
level.Debug(o.logger).Log("msg", "frontend does not exist, creating")
// Create frontend in B3Scale backend
createdFrontend, err := o.apiClient.FrontendCreate(ctx, &store.FrontendState{
Active: true,
Expand Down Expand Up @@ -243,5 +245,5 @@ func getFrontendByName(
if len(frontends) > 0 {
return frontends[0], nil
}
return nil, nil
return nil, fmt.Errorf("cloud not find BBBFrontend with name %s", key)
}

0 comments on commit 95db19f

Please sign in to comment.