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

Fix deadlock in DecreaseTargetSize by filtering placeholders Fixes #6128 #6817

Closed
wants to merge 4 commits into from
Closed

Fix deadlock in DecreaseTargetSize by filtering placeholders Fixes #6128 #6817

wants to merge 4 commits into from

Conversation

ruiscosta
Copy link

This commit resolves an issue where the DecreaseTargetSize function could enter a deadlock state by attempting to scale down when only placeholder nodes, marked as 'placeholderUnfulfillableStatus', are present. The updated function now filters out these placeholder nodes before calculating if a decrease in target size is permissible, ensuring that only operational nodes are considered in the scaling process. This prevents erroneous scaling activities that could impact cluster stability and node management in AWS Auto Scaling Groups.

  • Added checks to exclude placeholders in DecreaseTargetSize calculations.

  • Enhanced logging for better clarity when instance statuses are fetched but continue despite errors.

Fixes #6128

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR fixes a critical deadlock issue in the DecreaseTargetSize function within the AWS cloud provider implementation of the Kubernetes Cluster Autoscaler. By ensuring only operational nodes are considered for scaling down, it prevents the Cluster Autoscaler from making incorrect scaling decisions that could affect cluster stability.

Which issue(s) this PR fixes:

Fixes #6128

Special notes for your reviewer:

Please review the changes to the DecreaseTargetSize function, especially the new checks for placeholder nodes and the updated error handling logic.

Does this PR introduce a user-facing change?

Fix deadlock issue in the AWS implementation of Cluster Autoscaler by improving the logic in DecreaseTargetSize function to ignore placeholder nodes with 'placeholderUnfulfillableStatus'.

This commit resolves an issue where the DecreaseTargetSize function could enter a deadlock state by attempting to scale down when only placeholder nodes, marked as 'placeholderUnfulfillableStatus', are present. The updated function now filters out these placeholder nodes before calculating if a decrease in target size is permissible, ensuring that only operational nodes are considered in the scaling process. This prevents erroneous scaling activities that could impact cluster stability and node management in AWS Auto Scaling Groups.

- Added checks to exclude placeholders in DecreaseTargetSize calculations.

- Enhanced logging for better clarity when instance statuses are fetched but continue despite errors.

Fixes #6128
@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. kind/bug Categorizes issue or PR as related to a bug. labels May 10, 2024
Copy link

linux-foundation-easycla bot commented May 10, 2024

CLA Not Signed

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label May 10, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @ruiscosta. Thanks for your PR.

I'm waiting for a kubernetes 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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 10, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ruiscosta
Once this PR has been reviewed and has the lgtm label, please assign drmorr0 for approval. For more information see the Kubernetes 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 area/cluster-autoscaler area/provider/aws Issues or PRs related to aws provider size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 10, 2024
@drmorr0
Copy link
Contributor

drmorr0 commented May 16, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 16, 2024
@drmorr0
Copy link
Contributor

drmorr0 commented May 16, 2024

@ruiscosta thanks for the PR! You will need to get a CLA signed before we can merge it. I'll leave a few general comments in a review, though.

Copy link
Contributor

@drmorr0 drmorr0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These sorts of changes are very hard to reason about in isolation, and while I think the approach makes sense, it's unclear to me 100% that this will resolve the issues mentioned in #6128. I think at the very least we need some test coverage for this case that "fails before" your change and "passes afterwards". If possible, I'd also like to see some tests from a real cluster that show that this resolves the unwanted behaviour? It seems like from the comment thread that there is a reasonable set of steps to reproduce the issue.

@dims
Copy link
Member

dims commented May 25, 2024

/easycla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 25, 2024
This commit improves the `DecreaseTargetSize` function in the AWS cloud provider module of the cluster-autoscaler by refining the logic and enhancing the test coverage to ensure the changes effectively address the issues identified in #6128. The updates include:

- Expanded test coverage: Added new unit tests that demonstrate the failure before the changes and success after, verifying that the updates mitigate the issue effectively. These tests focus on ensuring that placeholder nodes are correctly filtered out and do not influence the scaling decisions, which was a critical concern.

- Code refinements: Refined the handling of instance statuses by adjusting how filtered nodes are used directly in subsequent logic, removing the need to re-assign to the original `nodes` variable. This change simplifies the code and reduces the risk of errors during node filtering processes.

- Comment optimization: Removed redundant comments and refined existing ones.

Reference to discussion in issue #6128 for more details.
@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 25, 2024
@k8s-ci-robot
Copy link
Contributor

Keywords which can automatically close issues and at(@) or hashtag(#) mentions are not allowed in commit messages.

The list of commits with invalid commit messages:

  • f731506 Fix deadlock in DecreaseTargetSize by filtering placeholders

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. I understand the commands that are listed here.

@k8s-ci-robot
Copy link
Contributor

Keywords which can automatically close issues and at(@) mentions are not allowed in the title of a Pull Request.

You can edit the title by writing /retitle in a comment.

When GitHub merges a Pull Request, the title is included in the merge commit. To avoid invalid keywords in the merge commit, please edit the title of the PR.

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. I understand the commands that are listed here.

@ruiscosta
Copy link
Author

Closed due to duplicate created to address feedback - #6866

@ruiscosta ruiscosta closed this May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cluster-autoscaler area/provider/aws Issues or PRs related to aws provider cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. kind/bug Categorizes issue or PR as related to a bug. ok-to-test Indicates a non-member PR verified by an org member that 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.

cluster-autoscaler gets stuck with "Failed to fix node group sizes" error
5 participants