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

Allow specification of multiple expanders #4233

Merged
merged 1 commit into from
Sep 24, 2021

Conversation

ryanmcnamara
Copy link
Contributor

Multiple expanders can now be specified, expanders now "filter to the
tied for best" instead of "selecting the best" so the output of one
expander is now fed to the input of the next. Each expander may only
be used once to disallow bad configuration. This should not be a change
in functionality as in the event of a tie the random expander is still
used.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 30, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @ryanmcnamara!

It looks like this is your first PR to kubernetes/autoscaler 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/autoscaler has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 30, 2021
@ryanmcnamara
Copy link
Contributor Author

fixes #4206

@ryanmcnamara
Copy link
Contributor Author

Built and deployed this locally and confirmed I was able to use --expander=priority,least-waste and it worked as expected


switch expanderFlag {
case expander.RandomExpanderName:
filters = append(filters, random.NewFilter())
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be an error to specify an expander that's guaranteed to provide a single option with a fallback? E.g. random,least-waste is not really a reasonable config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True that the configuration is not a reasonable one, but I felt that catching this case wasn't worth the effort as it would require disambiguating between expanders that

  1. Always return one result and
  2. Those that can return more than one.

My thinking is that since it won't create problems then we can keep the simplicity of allowing this. Happy to be overruled on this though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Yup, something like this. I'm not insisting on this one, but since you're generating an error for one class of invalid configs (duplicated entries), I thought it may make sense to go a step further and disallow bad ordering as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok addressed in this pr now!

Copy link
Member

Choose a reason for hiding this comment

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

Neat, thanks! Maybe worth adding a comment about this behavior? May be surprising for anyone adding a new expander in the future. Please also squash commits before merging.

func (c *chainStrategy) BestOption(options []expander.Option, nodeInfo map[string]*schedulerframework.NodeInfo) *expander.Option {
filteredOptions := options
for _, filter := range c.filters {
filteredOptions = filter.BestOptions(filteredOptions, nodeInfo)
Copy link
Member

Choose a reason for hiding this comment

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

There is non-trivial logic behind BestOptions call sometime, so maybe worth returning earlier if there's just one option left?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1, will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@ryanmcnamara
Copy link
Contributor Author

Looking for a review from a code owner, perhaps @MaciekPytel or if not can you redirect? Thanks!

@x13n
Copy link
Member

x13n commented Aug 13, 2021

I'm about to go on vacation tomorrow, so to make sure it's not blocked on me in the meantime:

/lgtm
/hold until the commits are squashed

For final approval:
/assign @MaciekPytel

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 13, 2021
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 13, 2021
@x13n
Copy link
Member

x13n commented Sep 3, 2021

Just realized this is still open. Can you squash the commits?

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 7, 2021
@ryanmcnamara
Copy link
Contributor Author

@x13n done!

@x13n
Copy link
Member

x13n commented Sep 7, 2021

/lgtm
/hold cancel

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Sep 7, 2021
Copy link
Contributor

@mwielgus mwielgus left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mwielgus, ryanmcnamara

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 Sep 22, 2021
@mwielgus
Copy link
Contributor

Please fix:

Boilerplate header is wrong for: /home/runner/work/autoscaler/autoscaler/go/src/k8s.io/autoscaler/cluster-autoscaler/expander/factory/chain_test.go

Multiple expanders can now be specified, expanders now "filter to the
tied for best" instead of "selecting the best" so the output of one
expander is now fed to the input of the next. Each expander may only
be used once to disallow bad configuration. This should not be a change
in functionality as in the event of a tie the random expander is still
used.
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 23, 2021
@ryanmcnamara
Copy link
Contributor Author

@mwielgus done, thanks for the review

@x13n
Copy link
Member

x13n commented Sep 24, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 24, 2021
@k8s-ci-robot k8s-ci-robot merged commit 82bdc4a into kubernetes:master Sep 24, 2021
bpineau added a commit to DataDog/autoscaler that referenced this pull request Sep 27, 2021
The github action hooks didn't run the unit tests on the expanders
update in kubernetes#4233 (likely the known "tests don't run automatically for
new contributor" limitation).

NewStrategy became NewFilter, with a BestOptions (plural) method,
and returns a Options slice instead of a single Option.
bpineau added a commit to DataDog/autoscaler that referenced this pull request Sep 30, 2021
The github action hooks didn't run the unit tests on the expanders
update in kubernetes#4233 (likely the known "tests don't run automatically for
new contributor" limitation).

NewStrategy became NewFilter, with a BestOptions (plural) method,
and returns a Options slice instead of a single Option.
piotrnosek pushed a commit to piotrnosek/autoscaler that referenced this pull request Nov 30, 2021
The github action hooks didn't run the unit tests on the expanders
update in kubernetes#4233 (likely the known "tests don't run automatically for
new contributor" limitation).

NewStrategy became NewFilter, with a BestOptions (plural) method,
and returns a Options slice instead of a single Option.
evansheng pushed a commit to airbnb/autoscaler that referenced this pull request Dec 3, 2021
evansheng pushed a commit to airbnb/autoscaler that referenced this pull request Dec 3, 2021
Allow specification of multiple expanders
-- EDIT: change uses of scheduler/schedulerframework to
scheduler/nodeinfo, as we are not yet on the version that switches
evansheng pushed a commit to airbnb/autoscaler that referenced this pull request Dec 3, 2021
The github action hooks didn't run the unit tests on the expanders
update in kubernetes#4233 (likely the known "tests don't run automatically for
new contributor" limitation).

NewStrategy became NewFilter, with a BestOptions (plural) method,
and returns a Options slice instead of a single Option.
drmorr0 pushed a commit to airbnb/autoscaler that referenced this pull request Jan 13, 2022
MaxRink pushed a commit to MaxRink/autoscaler that referenced this pull request Feb 14, 2022
The github action hooks didn't run the unit tests on the expanders
update in kubernetes#4233 (likely the known "tests don't run automatically for
new contributor" limitation).

NewStrategy became NewFilter, with a BestOptions (plural) method,
and returns a Options slice instead of a single Option.
evansheng pushed a commit to airbnb/autoscaler that referenced this pull request Mar 24, 2022
@jonathanbbai
Copy link

I don't want to upgrade my cluster to 1.23 but i really like this feature, You think if I upgrade the CA version to 1.23 while on a 1.20 cluster, what are the chances it'll work?

jiancheung pushed a commit to airbnb/autoscaler that referenced this pull request Jul 29, 2022
akirillov pushed a commit to airbnb/autoscaler that referenced this pull request Oct 27, 2022
tim-smart pushed a commit to arisechurch/autoscaler that referenced this pull request Nov 22, 2022
The github action hooks didn't run the unit tests on the expanders
update in kubernetes#4233 (likely the known "tests don't run automatically for
new contributor" limitation).

NewStrategy became NewFilter, with a BestOptions (plural) method,
and returns a Options slice instead of a single Option.
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants