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 Nov 5, 2024
1 parent c3b4d38 commit 1719bd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 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
10 changes: 4 additions & 6 deletions pkg/amphoracontrollers/flavors.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ 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 {
if amphoraFlavors[flavorOpts.Name].VCPUs > 1 {
flavorProfileData.AmpImageTag = octavia.AmphoraImageVertTag
}

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 1719bd2

Please sign in to comment.