diff --git a/bmc/redfish.go b/bmc/redfish.go index 261e70c..21bf9fb 100644 --- a/bmc/redfish.go +++ b/bmc/redfish.go @@ -73,8 +73,6 @@ func (r *RedfishBMC) PowerOn(systemID string) error { if err := system.Reset(redfish.OnResetType); err != nil { return fmt.Errorf("failed to reset system to power on state: %w", err) } - } else { - fmt.Printf("System %s is already powered on.\n", systemID) } break } diff --git a/internal/controller/serverclaim_controller.go b/internal/controller/serverclaim_controller.go index b4b6de6..107b8f0 100644 --- a/internal/controller/serverclaim_controller.go +++ b/internal/controller/serverclaim_controller.go @@ -147,14 +147,15 @@ func (r *ServerClaimReconciler) reconcile(ctx context.Context, log logr.Logger, return ctrl.Result{}, fmt.Errorf("failed to get server: %w", err) } - if server.Status.State != metalv1alpha1.ServerStateAvailable { - log.V(1).Info("Failed to claim server in non available state", "Server", server.Name, "ServerState", server.Status.State) + // did somebody else claim this server? + if claimRef := server.Spec.ServerClaimRef; claimRef != nil && claimRef.UID != claim.UID { + log.V(1).Info("Server claim ref UID does not match claim", "Server", server.Name, "ClaimUID", claimRef.UID) return ctrl.Result{}, nil } - // did somebody else claimed this server? - if claimRef := server.Spec.ServerClaimRef; claimRef != nil && claimRef.UID != claim.UID { - log.V(1).Info("Server claim ref UID does not match claim", "Server", server.Name, "ClaimUID", claimRef.UID) + // Check server state and only proceed if it is Available or Reserved + if server.Status.State != metalv1alpha1.ServerStateAvailable && server.Status.State != metalv1alpha1.ServerStateReserved { + log.V(1).Info("Server not in a claimable state", "Server", server.Name, "ServerState", server.Status.State) return ctrl.Result{}, nil }