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

Add proactive scaleup #7145

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

abdelrahman882
Copy link
Contributor

@abdelrahman882 abdelrahman882 commented Aug 8, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Introduce proactive scale up, to proactively scale up nodes based on replica count by injecting fake pods that triggers scale up logic which eliminates the need for waiting for the real pod to be marked as not scheduled then act and scale up

Does this PR introduce a user-facing change?

Cluster Autoscaler can now trigger large scale ups before all pending pods are created. This behavior is disabled by default and can be enabled with --enable-proactive-scaleup flag.

enable-proactive-scaleup : To enable the new feature
pod-injection-limit : Limits the total number of injected pods

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. labels Aug 8, 2024
@k8s-ci-robot k8s-ci-robot requested a review from x13n August 8, 2024 08:12
@k8s-ci-robot k8s-ci-robot added 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. labels Aug 8, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @abdelrahman882. 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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 8, 2024
@abdelrahman882 abdelrahman882 deleted the proactive-scaleup branch August 8, 2024 08:54
@abdelrahman882 abdelrahman882 restored the proactive-scaleup branch August 8, 2024 09:06
@abdelrahman882 abdelrahman882 reopened this Aug 8, 2024
@@ -265,6 +268,9 @@ var (
"Eg. flag usage: '10000:20,1000:100,0:60'")
provisioningRequestsEnabled = flag.Bool("enable-provisioning-requests", false, "Whether the clusterautoscaler will be handling the ProvisioningRequest CRs.")
frequentLoopsEnabled = flag.Bool("frequent-loops-enabled", false, "Whether clusterautoscaler triggers new iterations more frequently when it's needed")
proactiveScaleupEnabled = flag.Bool("enable-proactive-scaleup", false, "Whether to enable/disable proactive scale-ups, defaults to false")
podInjectionLimit = flag.Int("pod-injection-limit", 5000, "Limits total number of pods while injecting fake pods. If unschedulable pods already exceeds the limit, pod injection is disabled but pods are not truncated.")
nodeLimit = flag.Int("node-limit", 15000, "Limits total number of nodes in cluster to avoid overloading KCP, only used when --enable-proactive-scaleup is set to true. Defaults to 15k nodes")
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason to introduce this flag? It is essentially the same as --max-nodes-total. As a user, how would I decide when to use one vs the other?

podListProcessor = pods.NewCombinedPodListProcessor([]pods.PodListProcessor{podInjectionPodListProcessor, podListProcessor, enforceInjectedPodsLimitProcessor})

// FakePodsScaleUpStatusProcessor processor needs to be the first processor in ScaleUpStatusProcessor as it filters out fake pods from
// Scale Up status so that we don't emit events, visibility logs, ..etc for them.
Copy link
Member

Choose a reason for hiding this comment

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

nit: Visibility events are a GKE specific concept, so I wouldn't mention them here.

@abdelrahman882 abdelrahman882 force-pushed the proactive-scaleup branch 3 times, most recently from ed601a8 to c488df7 Compare August 12, 2024 08:12
@abdelrahman882 abdelrahman882 marked this pull request as ready for review August 14, 2024 08:24
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 14, 2024
@x13n
Copy link
Member

x13n commented Aug 16, 2024

The code changes look good to me, can you re-add the release note box in the first comment and add a more user-facing release note there? For instance:

Cluster Autoscaler can now trigger large scale ups before all pending pods are created. This behavior is disabled by default and can be enabled with `--enable-proactive-scaleup` flag.

Copy link
Contributor

@atwamahmoud atwamahmoud left a comment

Choose a reason for hiding this comment

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

Apart from the comments I had it LGTM

return desiredReplicas
}

func workQueue(job *batchv1.Job) bool {
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 add a comment here describing what this method evaluates since it's a bit hard to read/reason

Or maybe we can use an if/else statement to simplify it a bit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clarified with a comment


// Removes NoScaleUpInfo entries which contain a fake pod from the input list
// Returns a list of NoScaleUpInfo which doesn't contain any fake pods
func filterNoScaleUpInfos(noScaleUpInfos []status.NoScaleUpInfo) ([]status.NoScaleUpInfo, []types.UID) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we can use generics here, maybe we can just have one method instead of filterNoScaleUpInfos & filterFakePods
@x13n I remember we talked about this before but I don't remember the decision :'D

Copy link
Member

Choose a reason for hiding this comment

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

I think one more generic filtering here would be ok, though these two functions are not identical, so I'm not sure if it is enough shared code to justify introducing a shared generic. I'm fine either way, would leave it up to @abdelrahman882 to pick one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both are sharing almost same logic (filtering fake pods from a list of pods or pod wrappers), I will go with one generic function to avoid having duplicated code and logging messages

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 22, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 23, 2024
@x13n
Copy link
Member

x13n commented Aug 26, 2024

Thanks for the changes!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 26, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abdelrahman882, x13n

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

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 26, 2024
@k8s-ci-robot k8s-ci-robot merged commit 9226cf6 into kubernetes:master Aug 26, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants