Skip to content

Commit

Permalink
Skip flavor configuration on error
Browse files Browse the repository at this point in the history
Return error only if none of the flavors could
be configured.
  • Loading branch information
weinimo committed Oct 10, 2024
1 parent c3b4d38 commit 0d72724
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion controllers/amphoracontroller_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (r *OctaviaAmphoraControllerReconciler) reconcileNormal(ctx context.Context

defaultFlavorID, err := amphoracontrollers.EnsureFlavors(ctx, instance, &r.Log, helper)
if err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Duration(180) * time.Second}, nil
}
r.Log.Info(fmt.Sprintf("Using default flavor \"%s\"", defaultFlavorID))

Expand Down
12 changes: 5 additions & 7 deletions pkg/amphoracontrollers/flavors.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,8 @@ func ensureFlavors(osclient *openstack.OpenStack, log *logr.Logger, instance *oc
ComputeFlavorID: amphoraFlavors[flavorOpts.Name].ID,
}

if amphoraFlavors[flavorOpts.Name].VCPUs == 1 {
flavorProfileData.AmpImageTag = octavia.AmphoraImageTag
} else {
flavorProfileData.AmpImageTag = octavia.AmphoraImageVertTag
if amphoraFlavors[flavorOpts.Name].VCPUs > 1 {
flavorProfileData.AmpImageTag = octavia.AmphoraImageVertTag
}

fpDataJSON, err := json.Marshal(flavorProfileData)
Expand All @@ -239,8 +237,8 @@ func ensureFlavors(osclient *openstack.OpenStack, log *logr.Logger, instance *oc
log.Info(fmt.Sprintf("Creating Octavia flavor profile \"%s\"", flavorProfileCreateOpts.Name))
fp, err := flavorprofiles.Create(lbClient, flavorProfileCreateOpts).Extract()
if err != nil {
errFmt := fmt.Errorf("error creating flavor profile: %w", err)
log.Error(errFmt, fmt.Sprintf("Amphora image might be missing or not "+
log.Info(fmt.Sprintf("Warning: Could not create flavor profile. "+
"Amphora image might be missing or not "+
"tagged correctly. Skipping configuration of octavia "+
"flavor profile %s and octavia flavor %s.",
flavorProfileCreateOpts.Name, name))
Expand All @@ -266,7 +264,7 @@ func ensureFlavors(osclient *openstack.OpenStack, log *logr.Logger, instance *oc
flavorSuccess = true
}
if !flavorSuccess {
return "", fmt.Errorf("none of the Octavia flavors could be configured because of errors. last error: %w", err)
return "", fmt.Errorf("none of the Octavia flavors could be configured")
}
return defaultFlavorID, nil
}
Expand Down

0 comments on commit 0d72724

Please sign in to comment.