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

Requeue for Power state polling and ensuringServerClaim binding #131

Merged
merged 1 commit into from
Sep 19, 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: 1 addition & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func main() {
flag.DurationVar(&powerPollingTimeout, "power-polling-timeout", 2*time.Minute, "Timeout for polling power state")
flag.DurationVar(&registryResyncInterval, "registry-resync-interval", 10*time.Second,
"Defines the interval at which the registry is polled for new server information.")
flag.DurationVar(&serverResyncInterval, "server-resync-interval", 30*time.Second,
flag.DurationVar(&serverResyncInterval, "server-resync-interval", 2*time.Minute,
"Defines the interval at which the server is polled.")
flag.StringVar(&registryURL, "registry-url", "", "The URL of the registry.")
flag.StringVar(&registryProtocol, "registry-protocol", "http", "The protocol to use for the registry.")
Expand Down
18 changes: 10 additions & 8 deletions internal/controller/server_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (r *ServerReconciler) reconcile(ctx context.Context, log logr.Logger, serve

requeue, err := r.ensureServerStateTransition(ctx, log, server)
if requeue && err == nil {
return ctrl.Result{Requeue: requeue, RequeueAfter: r.RegistryResyncInterval}, nil
return ctrl.Result{Requeue: requeue, RequeueAfter: r.ResyncInterval}, nil
}
if err != nil && !apierrors.IsNotFound(err) {
return ctrl.Result{}, fmt.Errorf("failed to ensure server state transition: %w", err)
Expand Down Expand Up @@ -318,7 +318,7 @@ func (r *ServerReconciler) handleAvailableState(ctx context.Context, log logr.Lo
return false, fmt.Errorf("failed to ensure server indicator led: %w", err)
}
log.V(1).Info("Reconciled available state")
return false, nil
return true, nil
}

func (r *ServerReconciler) handleReservedState(ctx context.Context, log logr.Logger, server *metalv1alpha1.Server) (bool, error) {
Expand All @@ -328,11 +328,13 @@ func (r *ServerReconciler) handleReservedState(ctx context.Context, log logr.Log
}
log.V(1).Info("Server boot configuration is ready")

if err := r.pxeBootServer(ctx, log, server); err != nil {
return false, fmt.Errorf("failed to boot server: %w", err)
//TODO: handle working Reserved Server that was suddenly powered off but needs to boot from disk
if server.Status.PowerState == metalv1alpha1.ServerOffPowerState {
afritzler marked this conversation as resolved.
Show resolved Hide resolved
if err := r.pxeBootServer(ctx, log, server); err != nil {
return false, fmt.Errorf("failed to boot server: %w", err)
}
log.V(1).Info("Server is powered off, booting Server in PXE")
}
log.V(1).Info("Booted Server in PXE")

if err := r.ensureServerPowerState(ctx, log, server); err != nil {
return false, fmt.Errorf("failed to ensure server power state: %w", err)
}
Expand All @@ -341,7 +343,7 @@ func (r *ServerReconciler) handleReservedState(ctx context.Context, log logr.Log
return false, fmt.Errorf("failed to ensure server indicator led: %w", err)
}
log.V(1).Info("Reconciled reserved state")
return false, nil
return true, nil
}

func (r *ServerReconciler) ensureServerBootConfigRef(ctx context.Context, server *metalv1alpha1.Server, config *metalv1alpha1.ServerBootConfiguration) error {
Expand Down Expand Up @@ -890,7 +892,7 @@ func (r *ServerReconciler) SetupWithManager(mgr ctrl.Manager) error {

// Start a goroutine to send events to the channel at the specified interval
go func() {
ticker := time.NewTicker(r.RegistryResyncInterval)
ticker := time.NewTicker(r.ResyncInterval)
defer ticker.Stop()

for {
Expand Down
6 changes: 6 additions & 0 deletions internal/controller/serverclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,12 @@ func (r *ServerClaimReconciler) enqueueServerClaimByRefs() handler.EventHandler
})
return req
}
if claim.Spec.ServerRef == nil {
req = append(req, reconcile.Request{
NamespacedName: types.NamespacedName{Namespace: claim.Namespace, Name: claim.Name},
})
return req
}
}
return req
})
Expand Down
Loading