@@ -37,7 +37,6 @@ import (
3737 "sigs.k8s.io/controller-runtime/pkg/client"
3838 "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
3939 logger "sigs.k8s.io/controller-runtime/pkg/log"
40- "sigs.k8s.io/controller-runtime/pkg/reconcile"
4140
4241 kvmv1 "github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1"
4342 "github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/openstack"
@@ -106,7 +105,7 @@ func (r *EvictionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
106105 return ctrl.Result {}, nil
107106}
108107
109- func (r * EvictionReconciler ) handleRunning (ctx context.Context , eviction * kvmv1.Eviction ) (reconcile .Result , error ) {
108+ func (r * EvictionReconciler ) handleRunning (ctx context.Context , eviction * kvmv1.Eviction ) (ctrl .Result , error ) {
110109 if ! meta .IsStatusConditionTrue (eviction .Status .Conditions , kvmv1 .ConditionTypePreflight ) {
111110 // Ensure the hypervisor is disabled and we have the preflight condition
112111 return r .handlePreflight (ctx , eviction )
@@ -129,7 +128,7 @@ func (r *EvictionReconciler) handleRunning(ctx context.Context, eviction *kvmv1.
129128 return ctrl.Result {}, r .Status ().Update (ctx , eviction )
130129}
131130
132- func (r * EvictionReconciler ) handlePreflight (ctx context.Context , eviction * kvmv1.Eviction ) (reconcile .Result , error ) {
131+ func (r * EvictionReconciler ) handlePreflight (ctx context.Context , eviction * kvmv1.Eviction ) (ctrl .Result , error ) {
133132 hypervisorName := eviction .Spec .Hypervisor
134133
135134 // Does the hypervisor even exist? Is it enabled/disabled?
@@ -216,7 +215,7 @@ func (r *EvictionReconciler) handlePreflight(ctx context.Context, eviction *kvmv
216215 return ctrl.Result {}, r .Status ().Update (ctx , eviction )
217216}
218217
219- func (r * EvictionReconciler ) evictNext (ctx context.Context , eviction * kvmv1.Eviction ) (reconcile .Result , error ) {
218+ func (r * EvictionReconciler ) evictNext (ctx context.Context , eviction * kvmv1.Eviction ) (ctrl .Result , error ) {
220219 instances := & eviction .Status .OutstandingInstances
221220 uuid := (* instances )[len (* instances )- 1 ]
222221 log := logger .FromContext (ctx ).WithName ("Evict" ).WithValues ("server" , uuid )
@@ -236,7 +235,7 @@ func (r *EvictionReconciler) evictNext(ctx context.Context, eviction *kvmv1.Evic
236235 })
237236 return ctrl.Result {}, r .Status ().Update (ctx , eviction )
238237 }
239- return reconcile .Result {}, err
238+ return ctrl .Result {}, err
240239 }
241240
242241 log = log .WithValues ("server_status" , vm .Status )
@@ -245,7 +244,7 @@ func (r *EvictionReconciler) evictNext(ctx context.Context, eviction *kvmv1.Evic
245244 switch vm .Status {
246245 case "MIGRATING" , "RESIZE" :
247246 // wait for the migration to finish
248- return reconcile .Result {RequeueAfter : 5 * time .Second }, nil
247+ return ctrl .Result {RequeueAfter : 5 * time .Second }, nil
249248 case "ERROR" :
250249 // Needs manual intervention (or another operator fixes it)
251250 // put it at the end of the list (beginning of array)
@@ -262,7 +261,7 @@ func (r *EvictionReconciler) evictNext(ctx context.Context, eviction *kvmv1.Evic
262261 return ctrl.Result {}, err
263262 }
264263
265- return reconcile .Result {}, fmt .Errorf ("error migrating instance %v" , uuid )
264+ return ctrl .Result {}, fmt .Errorf ("error migrating instance %v" , uuid )
266265 }
267266
268267 currentHypervisor , _ , _ := strings .Cut (vm .HypervisorHostname , "." )
@@ -282,16 +281,16 @@ func (r *EvictionReconciler) evictNext(ctx context.Context, eviction *kvmv1.Evic
282281 if gophercloud .ResponseCodeIs (err , http .StatusNotFound ) {
283282 log .Info ("Instance is gone" )
284283 // Fall-back to beginning, which will clean it out
285- return reconcile .Result {Requeue : true }, nil
284+ return ctrl .Result {Requeue : true }, nil
286285 }
287286 // Retry confirm in next reconciliation
288- return reconcile .Result {}, err
287+ return ctrl .Result {}, err
289288 }
290289 }
291290
292291 // All done
293292 * instances = (* instances )[:len (* instances )- 1 ]
294- return reconcile .Result {}, r .Status ().Update (ctx , eviction )
293+ return ctrl .Result {}, r .Status ().Update (ctx , eviction )
295294 }
296295
297296 if vm .TaskState == "deleting" {
@@ -314,7 +313,7 @@ func (r *EvictionReconciler) evictNext(ctx context.Context, eviction *kvmv1.Evic
314313 if gophercloud .ResponseCodeIs (err , http .StatusNotFound ) {
315314 log .Info ("Instance is gone" )
316315 // Fall-back to beginning, which will clean it out
317- return reconcile .Result {RequeueAfter : 0 }, nil
316+ return ctrl .Result {RequeueAfter : 0 }, nil
318317 }
319318 copy ((* instances )[1 :], (* instances )[:len (* instances )- 1 ])
320319 (* instances )[0 ] = uuid
@@ -336,7 +335,7 @@ func (r *EvictionReconciler) evictNext(ctx context.Context, eviction *kvmv1.Evic
336335 if err := r .coldMigrate (ctx , vm .ID , eviction ); err != nil {
337336 if gophercloud .ResponseCodeIs (err , http .StatusNotFound ) {
338337 log .Info ("Instance is gone" )
339- return reconcile .Result {RequeueAfter : 0 }, nil
338+ return ctrl .Result {RequeueAfter : 0 }, nil
340339 }
341340 copy ((* instances )[1 :], (* instances )[:len (* instances )- 1 ])
342341 (* instances )[0 ] = uuid
0 commit comments