-
Notifications
You must be signed in to change notification settings - Fork 452
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 TargetMemoryUtilization metric for AutoScaling #1223
Add TargetMemoryUtilization metric for AutoScaling #1223
Conversation
Signed-off-by: Kevin Earls <[email protected]>
…e version Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
@pavolloffay @frzifus Can I get a review on this? |
@@ -46,6 +46,22 @@ func HorizontalPodAutoscaler(cfg config.Config, logger logr.Logger, otelcol v1al | |||
} | |||
|
|||
if autoscalingVersion == autodetect.AutoscalingVersionV2Beta2 { | |||
metrics := []autoscalingv2beta2.MetricSpec{} | |||
|
|||
if otelcol.Spec.Autoscaler != nil && otelcol.Spec.Autoscaler.TargetMemoryUtilization != 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.
is the otelcol.Spec.Autoscaler != nil
needed? Line 71 defines otelcol.Spec.Autoscaler.TargetCPUUtilization
and it is not in the if block for the autoscaler, probably it should be moved there.
Also should be the lines 65-74 moved to if block if TargetCPUUtilization
is not nil?
The same should be handled on line 114
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've removed thise if clauses, but at this point TargetCPUUtilization will always be set, as the webhook will set it to default if it is not in the CR.
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.
but at this point TargetCPUUtilization will always be set, as the webhook will set it to default if it is not in the CR.
Is this correct behavior?
Shall we allow users to use independently CPU, memory or both?
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.
@pavolloffay Good qestion. :-) If we had done this correctly from the beginning I'd say no. But at some point we decided if MaxReplicas was set then we would automatically set TargetCPUUtilization to a default value if it was not in the CR.
I can implement this whatever way you think is correct.
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.
In case the operator supports only CPU metric then it makes sense to default it when HPA is used. But if there are multiple metrics users should have choice which one to use and the operator should default only when no user config is provided.
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
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.
LGTM
* Add TargetMemoryUtilization metric for AutoScaling Signed-off-by: Kevin Earls <[email protected]> * Add changes to v2beta2 as there is no way to un e2e tests just for one version Signed-off-by: Kevin Earls <[email protected]> * See if we just have a race condition Signed-off-by: Kevin Earls <[email protected]> * Reset kuttl timeout Signed-off-by: Kevin Earls <[email protected]> * Add some debugging code to help analyze failures on github Signed-off-by: Kevin Earls <[email protected]> * Try to appease the linter Signed-off-by: Kevin Earls <[email protected]> * Restore autoscale tests Signed-off-by: Kevin Earls <[email protected]> * Cleanup Signed-off-by: Kevin Earls <[email protected]> * More cleanup Signed-off-by: Kevin Earls <[email protected]> * Respond to comments Signed-off-by: Kevin Earls <[email protected]> * Cleanup whitespace so linter will rerun Signed-off-by: Kevin Earls <[email protected]> * Don't set TargetCPUUtilization to default if another metric is set Signed-off-by: Kevin Earls <[email protected]> Signed-off-by: Kevin Earls <[email protected]>
Trying to use this YAML for operator but targetMemoryUtilization is yet missing. Am I missing something? |
* Add TargetMemoryUtilization metric for AutoScaling Signed-off-by: Kevin Earls <[email protected]> * Add changes to v2beta2 as there is no way to un e2e tests just for one version Signed-off-by: Kevin Earls <[email protected]> * See if we just have a race condition Signed-off-by: Kevin Earls <[email protected]> * Reset kuttl timeout Signed-off-by: Kevin Earls <[email protected]> * Add some debugging code to help analyze failures on github Signed-off-by: Kevin Earls <[email protected]> * Try to appease the linter Signed-off-by: Kevin Earls <[email protected]> * Restore autoscale tests Signed-off-by: Kevin Earls <[email protected]> * Cleanup Signed-off-by: Kevin Earls <[email protected]> * More cleanup Signed-off-by: Kevin Earls <[email protected]> * Respond to comments Signed-off-by: Kevin Earls <[email protected]> * Cleanup whitespace so linter will rerun Signed-off-by: Kevin Earls <[email protected]> * Don't set TargetCPUUtilization to default if another metric is set Signed-off-by: Kevin Earls <[email protected]> Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls [email protected]
This is in response to #1203 It does this in an opinionated way, just adding targetMemoryUtilization for now. Implementing other things that can be set as metrics could be done later.
Note that there is no new e2e test. I originally wrote a new test, and it would pass consistently on my laptop, but then would fail most of the time under CI. Given the short time I have remaining on this project I was not able to resolve this.
I did test it manually, and even built an operator which did not set targetCPUUtilization and ran some tests against that to make sure it would scale correctly on memory.