Skip to content
New issue

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

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

Already on GitHub? # to your account

chore: Fix returning non-empty reconcile result and error #618

Merged
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
6 changes: 4 additions & 2 deletions pkg/controllers/node/termination/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ func (c *Controller) Finalize(ctx context.Context, node *v1.Node) (reconcile.Res
}
return reconcile.Result{RequeueAfter: 1 * time.Second}, nil
}

if err := c.cloudProvider.Delete(ctx, nodeclaimutil.NewFromNode(node)); cloudprovider.IgnoreNodeClaimNotFoundError(err) != nil {
return reconcile.Result{}, fmt.Errorf("terminating cloudprovider instance, %w", err)
}
return reconcile.Result{}, c.removeFinalizer(ctx, node)
if err := c.removeFinalizer(ctx, node); err != nil {
return reconcile.Result{}, err
}
return reconcile.Result{}, nil
}

func (c *Controller) deleteAllMachines(ctx context.Context, node *v1.Node) error {
Expand Down
5 changes: 4 additions & 1 deletion pkg/controllers/nodeclaim/disruption/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ func (c *Controller) Reconcile(ctx context.Context, nodeClaim *v1beta1.NodeClaim
return reconcile.Result{}, client.IgnoreNotFound(err)
}
}
return result.Min(results...), errs
if errs != nil {
return reconcile.Result{}, errs
}
return result.Min(results...), nil
}

var _ corecontroller.TypedController[*v1beta1.NodeClaim] = (*NodeClaimController)(nil)
Expand Down
5 changes: 4 additions & 1 deletion pkg/controllers/nodeclaim/garbagecollection/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ func (c *Controller) Reconcile(ctx context.Context, _ reconcile.Request) (reconc
Debugf("garbage collecting %s with no cloudprovider representation", lo.Ternary(nodeClaims[i].IsMachine, "machine", "nodeclaim"))
nodeclaimutil.TerminatedCounter(nodeClaims[i], "garbage_collected").Inc()
})
return reconcile.Result{RequeueAfter: time.Minute * 2}, multierr.Combine(errs...)
if err = multierr.Combine(errs...); err != nil {
return reconcile.Result{}, err
}
return reconcile.Result{RequeueAfter: time.Minute * 2}, nil
}

func (c *Controller) Builder(_ context.Context, m manager.Manager) corecontroller.Builder {
Expand Down
5 changes: 4 additions & 1 deletion pkg/controllers/nodeclaim/lifecycle/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ func (c *Controller) Reconcile(ctx context.Context, nodeClaim *v1beta1.NodeClaim
// USE CAUTION when determining whether to increase this timeout or remove this line
time.Sleep(time.Second)
}
return result.Min(results...), errs
if errs != nil {
return reconcile.Result{}, errs
}
return result.Min(results...), nil
}

var _ corecontroller.TypedController[*v1beta1.NodeClaim] = (*NodeClaimController)(nil)
Expand Down
6 changes: 4 additions & 2 deletions pkg/controllers/state/informer/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ func (c *Controller) Reconcile(ctx context.Context, req reconcile.Request) (reco
}
return reconcile.Result{}, client.IgnoreNotFound(err)
}

return reconcile.Result{RequeueAfter: time.Minute}, c.cluster.UpdateDaemonSet(ctx, &daemonSet)
if err := c.cluster.UpdateDaemonSet(ctx, &daemonSet); err != nil {
return reconcile.Result{}, err
}
return reconcile.Result{RequeueAfter: time.Minute}, nil
}

func (c *Controller) Builder(_ context.Context, m manager.Manager) corecontroller.Builder {
Expand Down