Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ require (
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/google/uuid v1.6.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down
14 changes: 10 additions & 4 deletions internal/controller/aggregates_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ func slicesEqualUnordered(a, b []string) bool {
return true
}

// registerWithManager registers the controller with the Manager without acquiring OpenStack clients.
// This is useful for testing where clients are injected directly.
func (ac *AggregatesController) registerWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
Named(AggregatesControllerName).
For(&kvmv1.Hypervisor{}, builder.WithPredicates(utils.LifecycleEnabledPredicate)).
Complete(ac)
}

// SetupWithManager sets up the controller with the Manager.
func (ac *AggregatesController) SetupWithManager(mgr ctrl.Manager) error {
ctx := context.Background()
Expand All @@ -218,8 +227,5 @@ func (ac *AggregatesController) SetupWithManager(mgr ctrl.Manager) error {
return err
}

return ctrl.NewControllerManagedBy(mgr).
Named(AggregatesControllerName).
For(&kvmv1.Hypervisor{}, builder.WithPredicates(utils.LifecycleEnabledPredicate)).
Complete(ac)
return ac.registerWithManager(mgr)
}
14 changes: 10 additions & 4 deletions internal/controller/decomission_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ func (r *NodeDecommissionReconciler) markOffboarded(ctx context.Context, hv *kvm
return nil
}

// registerWithManager registers the controller with the Manager without acquiring OpenStack clients.
// This is useful for testing where clients are injected directly.
func (r *NodeDecommissionReconciler) registerWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
Named(DecommissionControllerName).
For(&kvmv1.Hypervisor{}).
Complete(r)
}

// SetupWithManager sets up the controller with the Manager.
func (r *NodeDecommissionReconciler) SetupWithManager(mgr ctrl.Manager) error {
ctx := context.Background()
Expand All @@ -195,8 +204,5 @@ func (r *NodeDecommissionReconciler) SetupWithManager(mgr ctrl.Manager) error {
}
r.placementClient.Microversion = "1.39" // yoga, or later

return ctrl.NewControllerManagedBy(mgr).
Named(DecommissionControllerName).
For(&kvmv1.Hypervisor{}).
Complete(r)
return r.registerWithManager(mgr)
}
14 changes: 10 additions & 4 deletions internal/controller/eviction_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,15 @@ func (r *EvictionReconciler) coldMigrate(ctx context.Context, uuid string, evict
return nil
}

// registerWithManager registers the controller with the Manager without acquiring OpenStack clients.
// This is useful for testing where clients are injected directly.
func (r *EvictionReconciler) registerWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
Named(EvictionControllerName).
For(&kvmv1.Eviction{}).
Complete(r)
}

// SetupWithManager sets up the controller with the Manager.
func (r *EvictionReconciler) SetupWithManager(mgr ctrl.Manager) error {
ctx := context.Background()
Expand All @@ -401,8 +410,5 @@ func (r *EvictionReconciler) SetupWithManager(mgr ctrl.Manager) error {
}
r.computeClient.Microversion = "2.90" // Xena (or later)

return ctrl.NewControllerManagedBy(mgr).
Named(EvictionControllerName).
For(&kvmv1.Eviction{}).
Complete(r)
return r.registerWithManager(mgr)
}
16 changes: 11 additions & 5 deletions internal/controller/hypervisor_maintenance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ func (hec *HypervisorMaintenanceController) ensureEviction(ctx context.Context,
}
}

// registerWithManager registers the controller with the Manager without acquiring OpenStack clients.
// This is useful for testing where clients are injected directly.
func (hec *HypervisorMaintenanceController) registerWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
Named(HypervisorMaintenanceControllerName).
For(&kvmv1.Hypervisor{}).
Owns(&kvmv1.Eviction{}). // trigger Reconcile whenever an Own-ed eviction is created/updated/deleted
Complete(hec)
}

// SetupWithManager sets up the controller with the Manager.
func (hec *HypervisorMaintenanceController) SetupWithManager(mgr ctrl.Manager) error {
ctx := context.Background()
Expand All @@ -267,9 +277,5 @@ func (hec *HypervisorMaintenanceController) SetupWithManager(mgr ctrl.Manager) e
}
hec.computeClient.Microversion = "2.90" // Xena (or later)

return ctrl.NewControllerManagedBy(mgr).
Named(HypervisorMaintenanceControllerName).
For(&kvmv1.Hypervisor{}).
Owns(&kvmv1.Eviction{}). // trigger Reconcile whenever an Own-ed eviction is created/updated/deleted
Complete(hec)
return hec.registerWithManager(mgr)
}
Loading