Skip to content

Commit

Permalink
Fix reconciling PowerState for serverclaims (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
hardikdr authored Jun 20, 2024
1 parent da986bd commit d5d71df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 0 additions & 2 deletions bmc/redfish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 6 additions & 5 deletions internal/controller/serverclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit d5d71df

Please sign in to comment.