Skip to content

Conversation

liuxu623
Copy link

What this PR does / why we need it:

In scenarios where nodes experience DiskPressure, DaemonSet pods may be evicted and enter Failed state. When deleting Machines, cluster-api attempts to delete these failed pods, but this triggers DaemonSet to create new pods which can then be evicted again due to persistent DiskPressure, creating an infinite loop.

/area machine

@k8s-ci-robot k8s-ci-robot added area/machine Issues or PRs related to machine lifecycle management cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 14, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign vincepri for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 14, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @liuxu623. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@liuxu623 liuxu623 force-pushed the skip-drain-failed-daemonset-pod branch from 2ab8e5a to 86fe687 Compare August 14, 2025 05:11
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 14, 2025
@chrischdi
Copy link
Member

Could you please provide more information (logs, yaml Data etc.) to gather further information?

Afaik, daemonset pods get ignored during drain.
That is also mentioned here https://cluster-api.sigs.k8s.io/tasks/automated-machine-management/machine_deletions#node-drain

@liuxu623
Copy link
Author

liuxu623 commented Aug 18, 2025

Could you please provide more information (logs, yaml Data etc.) to gather further information?

Afaik, daemonset pods get ignored during drain. That is also mentioned here https://cluster-api.sigs.k8s.io/tasks/automated-machine-management/machine_deletions#node-drain

https://github.com/kubernetes-sigs/cluster-api/blob/v1.10.4/internal/controllers/machine/drain/filters.go#L215-L218

	// Any finished pod can be removed.
	if pod.Status.Phase == corev1.PodSucceeded || pod.Status.Phase == corev1.PodFailed {
		return MakePodDeleteStatusOkay()
	}

For failed daemonSet Pods, cluster-api will still delete them. The timeline roughly goes like this:

  1. Delete Machine
  2. cluster-api deletes the failed daemonSet Pod
  3. daemonSet controller creates a new Pod
  4. kubelet evict the new Pod and causes it to become Failed
  5. cluster-api deletes the new failed daemonSet Pod
  6. ...

cluster-api and the daemonSet controller enter a loop.

In scenarios where nodes experience DiskPressure, DaemonSet pods may be
evicted and enter Failed state. When deleting Machines, cluster-api attempts
to delete these failed pods, but this triggers DaemonSet to create new pods
which can then be evicted again due to persistent DiskPressure, creating an
infinite loop.

Signed-off-by: liuxu <[email protected]>
@liuxu623 liuxu623 force-pushed the skip-drain-failed-daemonset-pod branch from 86fe687 to 5f889ae Compare August 18, 2025 03:47
@chrischdi
Copy link
Member

Ah so its about failed or succeeded daemonset pods. That changes things.

Did you try if MachineDrainRules could help to workaround your issue? (see: https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240930-machine-drain-rules.md )

Just changing the drain behavior might introduce issues for other users.

@liuxu623
Copy link
Author

Ah so its about failed or succeeded daemonset pods. That changes things.

Did you try if MachineDrainRules could help to workaround your issue? (see: https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240930-machine-drain-rules.md )

Just changing the drain behavior might introduce issues for other users.

In certain scenarios, such as when a node is under DiskPressure, any DaemonSet Pod may be evicted. This is not an issue specific to any particular DaemonSet but rather stems from node-level abnormalities. In this context, MachineDrainRules may not be applicable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/machine Issues or PRs related to machine lifecycle management cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants