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

chore: remove machines from node termination and topology test #656

Merged
merged 1 commit into from
Nov 1, 2023
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
18 changes: 1 addition & 17 deletions pkg/controllers/node/termination/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,9 @@ func (c *Controller) Reconcile(_ context.Context, _ *v1.Node) (reconcile.Result,

//nolint:gocyclo
func (c *Controller) Finalize(ctx context.Context, node *v1.Node) (reconcile.Result, error) {
if !controllerutil.ContainsFinalizer(node, v1alpha5.TerminationFinalizer) {
if !controllerutil.ContainsFinalizer(node, v1beta1.TerminationFinalizer) {
return reconcile.Result{}, nil
}
if err := c.deleteAllMachines(ctx, node); err != nil {
return reconcile.Result{}, fmt.Errorf("deleting machines, %w", err)
}
if err := c.deleteAllNodeClaims(ctx, node); err != nil {
return reconcile.Result{}, fmt.Errorf("deleting nodeclaims, %w", err)
}
Expand Down Expand Up @@ -108,19 +105,6 @@ func (c *Controller) Finalize(ctx context.Context, node *v1.Node) (reconcile.Res
return reconcile.Result{}, nil
}

func (c *Controller) deleteAllMachines(ctx context.Context, node *v1.Node) error {
machineList := &v1alpha5.MachineList{}
if err := c.kubeClient.List(ctx, machineList, client.MatchingFields{"status.providerID": node.Spec.ProviderID}); err != nil {
return err
}
for i := range machineList.Items {
if err := c.kubeClient.Delete(ctx, &machineList.Items[i]); err != nil {
return client.IgnoreNotFound(err)
}
}
return nil
}

func (c *Controller) deleteAllNodeClaims(ctx context.Context, node *v1.Node) error {
nodeClaimList := &v1beta1.NodeClaimList{}
if err := c.kubeClient.List(ctx, nodeClaimList, client.MatchingFields{"status.providerID": node.Spec.ProviderID}); err != nil {
Expand Down
Loading