From 1719bd220006e7225d8634da22c7a738163a9849 Mon Sep 17 00:00:00 2001 From: Tom Weininger Date: Tue, 1 Oct 2024 11:08:56 +0000 Subject: [PATCH] Skip flavor configuration on error Return error only if none of the flavors could be configured. --- controllers/amphoracontroller_controller.go | 2 +- pkg/amphoracontrollers/flavors.go | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/controllers/amphoracontroller_controller.go b/controllers/amphoracontroller_controller.go index d1ba793a..ba753182 100644 --- a/controllers/amphoracontroller_controller.go +++ b/controllers/amphoracontroller_controller.go @@ -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)) diff --git a/pkg/amphoracontrollers/flavors.go b/pkg/amphoracontrollers/flavors.go index 5a873a82..a0d17b15 100644 --- a/pkg/amphoracontrollers/flavors.go +++ b/pkg/amphoracontrollers/flavors.go @@ -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 } @@ -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)) @@ -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 }