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

Update DecreaseTargetSize to Exclude Placeholders #6866

Closed
wants to merge 1 commit into from
Closed

Update DecreaseTargetSize to Exclude Placeholders #6866

wants to merge 1 commit into from

Conversation

ruiscosta
Copy link

This commit updates the DecreaseTargetSize function in the AWS cloud provider module of the cluster-autoscaler to address a potential deadlock scenario. The function was modified to filter out placeholder nodes marked as 'placeholderUnfulfillableStatus' before determining if a decrease in target size is allowable. This change ensures that the scaling process considers only operational nodes, which enhances the stability and manageability of AWS Auto Scaling Groups.

  • Added checks to specifically exclude placeholders in the DecreaseTargetSize calculations.
  • Enhanced the logging to provide better clarity when instance statuses are fetched, continuing the process despite potential errors.

For more details on the scenarios and reproduction steps that guided these enhancements, please refer to the discussion in issue #6128.

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR is crucial for improving the reliability and efficiency of node scaling operations within the AWS cloud provider for the Kubernetes cluster-autoscaler. By ensuring that placeholder nodes do not influence scaling decisions, it prevents potential deadlocks and enhances the manageability of clusters, particularly in complex environments.

Which issue(s) this PR refers to:

For further discussion and a detailed exploration of the problem, see issue #6128.

This commit updates the DecreaseTargetSize function in the AWS cloud provider module of the cluster-autoscaler to address a potential deadlock scenario. The function was modified to filter out placeholder nodes marked as 'placeholderUnfulfillableStatus' before determining if a decrease in target size is allowable. This change ensures that the scaling process considers only operational nodes, which enhances the stability and manageability of AWS Auto Scaling Groups.

- Added checks to specifically exclude placeholders in the DecreaseTargetSize calculations.
- Enhanced the logging to provide better clarity when instance statuses are fetched, continuing the process despite potential errors.

Refer to discussion in issue 6128 for more details on the scenarios and reproduction steps that guided these enhancements.
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 26, 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 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. labels May 26, 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 gjtempleton 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

@dims
Copy link
Member

dims commented May 26, 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 26, 2024
@dims
Copy link
Member

dims commented May 26, 2024

xref: older PR #6817

@@ -739,3 +740,44 @@ func TestHasInstance(t *testing.T) {
assert.NoError(t, err)
assert.False(t, present)
}

// MockNodeGroup simulates the behavior of a NodeGroup for testing.
type MockNodeGroup struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use testify.mock here instead of rolling a new mock interface by hand? There are some other examples in this package, e.g., the autoScalingMock defined in aws_wrapper_test.go.

}

// TestDecreaseTargetSizeWithMock verifies functionality and error handling.
func TestDecreaseTargetSizeWithMock(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need a test to show that, if the difference between the current size and the new size is (say) -10, and 4 of those nodes are "real" and the other 6 are placeholders, that we only delete the placeholders. Right now it looks like we're just testing a decrease of -1 node.

}

// TestDecreaseTargetSizeWithInvalidInput checks the method's response to invalid input.
func TestDecreaseTargetSizeWithInvalidInput(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want to use a table-driven test here instead of individual test cases.

@ruiscosta ruiscosta closed this Jun 12, 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: yes Indicates the PR's author has signed the CNCF CLA. 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.

4 participants