-
Notifications
You must be signed in to change notification settings - Fork 138
Trigger node deletion when machine is deleted #1102
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
base: master
Are you sure you want to change the base?
Changes from all commits
da4359c
9864805
e02a450
70001bf
92ba83b
2cf292e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,11 +63,16 @@ func (c *controller) updateNode(oldObj, newObj any) { | |
| return | ||
| } | ||
|
|
||
| // Do not process node updates if there is no associated machine | ||
| // In case of transient errors while fetching machine, do not retry | ||
| // as the update handler will be triggered again due to kubelet updates. | ||
| // Do not process node updates if there is no associated machine, except | ||
| // when the node is being deleted, in that case enqueue it for finalizer removal. | ||
| // For transient fetch errors, do not retry; the update handler will be triggered | ||
| // again due to kubelet updates. | ||
| machine, err := c.getMachineFromNode(node.Name) | ||
| if err != nil { | ||
| if errors.Is(err, errNoMachineMatch) && node.DeletionTimestamp != nil { | ||
| c.enqueueNode(node, fmt.Sprintf("handling node UPDATE event. Node %q is being deleted with no backing machine", node.Name)) | ||
| return | ||
| } | ||
| klog.Errorf("unable to handle update event for node %q, couldn't fetch associated machine. Error: %v", node.Name, err) | ||
| return | ||
| } | ||
|
|
@@ -148,11 +153,17 @@ func (c *controller) reconcileClusterNodeKey(key string) error { | |
| return nil | ||
| } | ||
|
|
||
| // Ignore node updates without an associated machine. Retry only for errors other than errNoMachineMatch; | ||
| // transient fetch errors will be eventually requeued by the update handler due to kubelet updates. | ||
| // Ignore node updates without an associated machine, except when the node is being | ||
| // deleted, then remove the MCM finalizer to unblock deletion. Retry only for | ||
| // errors other than errNoMachineMatch; transient fetch errors will be eventually | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there's a transient error while fetching the machine for the node, and node deletion was triggered via Or there's no possibility of getting no machine match (when there is a machine) because we're relying on listers?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's why I thought maybe the finalizer removal and node deletion could happen as a unit as part of machine on delete event similar to how its done in Not proposing that this is how it should be done, just pitching an alternative to see if there's any pros/cons of doing it either way. |
||
| // requeued by the update handler due to kubelet updates. | ||
| machine, err := c.getMachineFromNode(node.Name) | ||
| if err != nil { | ||
| if errors.Is(err, errNoMachineMatch) { | ||
| if node.DeletionTimestamp != nil { | ||
|
thiyyakat marked this conversation as resolved.
|
||
| klog.V(2).Infof("ClusterNode %q: Node is being deleted with no backing machine, removing finalizer", key) | ||
| return c.removeNodeFinalizers(ctx, node) | ||
| } | ||
| klog.Errorf("ClusterNode %q: No machine found matching node, skipping adding finalizers", key) | ||
| return nil | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the finalizer being retained here, wouldn't it make sense to speed up cleanup by removing it as well? Why wait for node reconciliation to happen?
Is it for convenience or there's some value in preserving the finalizer still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a pre-existing mechanism to handle the finalizer removal (So that any nodes that do not have a machine do not get a finalizer, added as part of #1065).
So I did not add it here, as the finalizer is removed anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but AFAICS the current
reconcileClusterNodeKeydoesn't have any finalizer removal logicmachine-controller-manager/pkg/util/provider/machinecontroller/node.go
Line 133 in 580d98f
Please correct me if I'm wrong but the only place we currently actively remove the finalizer from the node and issue deletion is
deleteNodeObjectwhich is part oftriggerDeletionFlow.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, really sorry for the confusion, #1065 had no finalizer removal steps (The change was to never add it in the first place).
But we do have it now now as part of this PR