Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reconciling PowerState of Server resource from ServerClaim #50

Merged
merged 1 commit into from
Jun 20, 2024
Merged
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: 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