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

Multi-target support v2 #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gchaviaras-NS1
Copy link

@gchaviaras-NS1 gchaviaras-NS1 commented May 31, 2024

In several use cases, due to the fact that Cluster Proportional Autoscaler (=CPA) is able to control only one deployment/replicasets, we end up having multiple deployments of CPA to control multiple deployments under the same Namespace. This situation is a bit redundant and creates an inefficient resource management by wasting resources both CPU and MEM.

This PR introduces multi target support functionality that allows a single instance of CPA to control multiple deployments/replicasets under the same Namespace

Is based and rebased from #159

Added:

  • Extra Config tests
  • target param renamed to targets
  • Docs
  • Updated helm charts

Copy link

linux-foundation-easycla bot commented May 31, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: palasanu / name: Palasanu George (7cb626c)

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

Welcome @gchaviaras-NS1!

It looks like this is your first PR to kubernetes-sigs/cluster-proportional-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-sigs/cluster-proportional-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 requested review from bowei and MrHohn May 31, 2024 13:52
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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 31, 2024
@gchaviaras-NS1
Copy link
Author

/assign @thockin

@gchaviaras-NS1
Copy link
Author

/assign @MrHohn

Any chance you could have a look?

Copy link

@thockin thockin left a comment

Choose a reason for hiding this comment

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

It's been a VERY long time since I looked at this code in depth, sorry if it is slow.

Between this and https://github.com/kubernetes-sigs/cluster-proportional-autoscaler/pull/159we have 2 PRs on the same topic - which one do we keep and which do we close? Can we work together on one?

Since I am looking at this one, can you please:

  1. squash
  2. include something in the commit and PR messages aboout WHY this matters
  3. include something in the README about the behavior

@@ -117,7 +123,7 @@ func (c *configMapData) Type() string {

// AddFlags adds flags for a specific AutoScaler to the specified FlagSet
func (c *AutoScalerConfig) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&c.Target, "target", c.Target, "Target to scale. In format: deployment/*, replicationcontroller/* or replicaset/* (not case sensitive).")
fs.StringVar(&c.Targets, "targets", c.Targets, "Targets to scale. In format: 'deployment/*,replicationcontroller/*,replicaset/*' (not case sensitive, comma delimiter supported).")
Copy link

Choose a reason for hiding this comment

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

You can't break compat without a major change (e.g. 2.0.0). I suggest you still accept the old flag and add the new flag. If only the old flag is specified, you can convert it into the new-style list. If only the new flag is specified, no problem. If both are specified, it can be a fatal error.

Copy link
Author

Choose a reason for hiding this comment

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

@thockin Thanks for the comment.
In that case isn't it better to discard the targets flag and just stick with a single flag target that will support both single and multiple targets ?
I know it breaks the meaning of the singular form of the flag target because it will support multiple targets too, but it can be stated in the documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with just keeping the target flag, that was my initial idea.

Copy link
Author

Choose a reason for hiding this comment

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

@thockin I kept the Target flag; Supports both single and multiple targets.
Also I added an extra paragraph explaining the multi-target support feature.
Let me know if more changes are needed

Copy link
Member

Choose a reason for hiding this comment

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

Repurposing the original flag while keeping it backward compatible seems fine to me.

Co-authored-by: George Palasanu <[email protected]>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gchaviaras-NS1
Once this PR has been reviewed and has the lgtm label, please ask for approval from mrhohn. 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

Copy link
Member

@MrHohn MrHohn left a comment

Choose a reason for hiding this comment

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

Added some minor comments. Sorry for my super long silence and thanks for adding this - seems to me an obvious use case.

Going forward I'm actually interested to see whether there is a potential to scale the solution beyond a namespace and beyond a single scale param config - not going to block this further though.

@@ -1,6 +1,6 @@
apiVersion: v2
name: cluster-proportional-autoscaler
version: 1.1.0
version: 1.1.1
Copy link
Member

Choose a reason for hiding this comment

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

Less certain about helm chart version here - I would expect a minor version bump for CPA itself as this is introducing a new feature.

Should we probably bump this later once we have a new CPA version released?

func (k *k8sClient) UpdateReplicas(expReplicas int32) (err error) {
for _, target := range k.scaleTargets.targets {
_, err := k.UpdateTargetReplicas(expReplicas, target)
if err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Should check for non-nil instead?
if err != nil { ...

@@ -270,10 +298,10 @@ func (k *k8sClient) updateReplicasAppsV1(expReplicas int32) (prevReplicas int32,

prevReplicas = scale.Spec.Replicas
if expReplicas != prevReplicas {
glog.V(0).Infof("Cluster status: SchedulableNodes[%v], TotalNodes[%v], SchedulableCores[%v], TotalCores[%v]", k.clusterStatus.SchedulableNodes, k.clusterStatus.TotalNodes, k.clusterStatus.SchedulableCores, k.clusterStatus.TotalCores)
glog.V(0).Infof("Cluster status: SchedulableNodes[%v], SchedulableCores[%v]", k.clusterStatus.SchedulableNodes, k.clusterStatus.SchedulableCores)
glog.V(0).Infof("Replicas are not as expected : updating replicas from %d to %d", prevReplicas, expReplicas)
Copy link
Member

Choose a reason for hiding this comment

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

Since we have multiple targets now, could we also log what is being scaled here?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 16, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

5 participants