@@ -54,21 +54,17 @@ type HypervisorMaintenanceController struct {
5454// +kubebuilder:rbac:groups=kvm.cloud.sap,resources=hypervisors,verbs=get;list;watch
5555// +kubebuilder:rbac:groups=kvm.cloud.sap,resources=hypervisors/status,verbs=get;list;watch;create;update;patch;delete
5656// +kubebuilder:rbac:groups=kvm.cloud.sap,resources=evictions,verbs=get;list;watch;create;update;patch;delete
57-
5857func (hec * HypervisorMaintenanceController ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
5958 hv := & kvmv1.Hypervisor {}
6059 if err := hec .Get (ctx , req .NamespacedName , hv ); err != nil {
6160 // OnboardingReconciler not found errors, could be deleted
6261 return ctrl.Result {}, k8sclient .IgnoreNotFound (err )
6362 }
6463
65- // is onboarding completed?
66- if ! meta .IsStatusConditionFalse (hv .Status .Conditions , kvmv1 .ConditionTypeOnboarding ) {
67- return ctrl.Result {}, nil
68- }
69-
70- // ensure serviceId is set
71- if hv .Status .ServiceID == "" {
64+ // If onboarding hasn't even started, no value will be set
65+ // If it has been started, but not finished yet, we need to wait for it to be aborted
66+ // So we can continue, if the condition is either not set at all or false
67+ if meta .IsStatusConditionTrue (hv .Status .Conditions , kvmv1 .ConditionTypeOnboarding ) {
7268 return ctrl.Result {}, nil
7369 }
7470
@@ -94,6 +90,12 @@ func (hec *HypervisorMaintenanceController) reconcileComputeService(ctx context.
9490 log := logger .FromContext (ctx )
9591 serviceId := hv .Status .ServiceID
9692
93+ // We can only do something here, if there is a service to begin with.
94+ // The onboarding should take care of that
95+ if serviceId == "" {
96+ return nil
97+ }
98+
9799 switch hv .Spec .Maintenance {
98100 case kvmv1 .MaintenanceUnset :
99101 // Enable the compute service (in case we haven't done so already)
0 commit comments