-
Notifications
You must be signed in to change notification settings - Fork 132
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
base: master
Are you sure you want to change the base?
Multi-target support v2 #211
Conversation
|
Welcome @gchaviaras-NS1! |
/assign @thockin |
/assign @MrHohn Any chance you could have a look? |
There was a problem hiding this 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:
- squash
- include something in the commit and PR messages aboout WHY this matters
- 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).") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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]>
f42d402
to
7cb626c
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gchaviaras-NS1 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 |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
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. |
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:
target
param renamed totargets