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

fix: Allow ScaledObject.MinReplicaCount to be set to 0 #5571

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

yorik
Copy link
Contributor

@yorik yorik commented Mar 4, 2024

Makes ScaledObject API to be closer to ScaleJob API.
Renames functions to MinReplicaCount and MaxReplicaCount.
Updates doc strings to correspond new names.
Set MinReplicaCount default to 0 as written in the doc:
https://keda.sh/docs/1.5/concepts/scaling-deployments/#overview.
Moves HPA related hacks into hpa.go.

Fixes: #5570.

@yorik yorik requested a review from a team as a code owner March 4, 2024 16:00
Makes ScaledObject API to be closer to ScaleJob API.
Renames functions to MinReplicaCount and MaxReplicaCount.
Updates doc strings to correspond new names.
Set MinReplicaCount default to 0 as written in the doc:
https://keda.sh/docs/1.5/concepts/scaling-deployments/#overview.
Moves HPA related hacks into hpa.go.

Fixes: 5570.
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
@zroubalik
Copy link
Member

zroubalik commented Mar 7, 2024

/run-e2e
Update: You can check the progress here

Signed-off-by: Yury Akudovich <yorik13@gmail.com>
@yorik
Copy link
Contributor Author

yorik commented Mar 14, 2024

I've updated the branch with changes from main and locally those e2e test passed:

Test logs
$ go test -v -tags e2e ./internals/scaling_modifiers/... ./internals/value_metric_type/...
=== RUN   TestScalingModifiers
    scaling_modifiers_test.go:269: -- setting up ---
    helper.go:248: deleting namespace scaling-modifiers-test-ns
    helper.go:301: waiting for namespace scaling-modifiers-test-ns deletion
    helper.go:235: Creating namespace - scaling-modifiers-test-ns
    helper.go:550: Applying template: secretTemplate
    helper.go:550: Applying template: metricsServerDeploymentTemplate
    helper.go:550: Applying template: serviceTemplate
    helper.go:550: Applying template: triggerAuthenticationTemplate
    helper.go:550: Applying template: deploymentTemplate
    helper.go:550: Applying template: workloadDeploymentTemplate
    scaling_modifiers_test.go:281: --- testFormula ---
    helper.go:550: Applying template: soFallbackTemplate
    helper.go:598: Applying template: updateMetricsTemplate
    helper.go:502: Waiting for some time to ensure deployment replica count doesn't change from 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:509: Deployment - scaling-modifiers-test-deployment, Current  - 0
    helper.go:598: Applying template: updateMetricsTemplate
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - depl-workload-base, Current  - 0, Target - 2
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - depl-workload-base, Current  - 2, Target - 2
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 1, Target - 3
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 3, Target - 3
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 3, Target - 5
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 1, Target - 5
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 5, Target - 5
    helper.go:598: Applying template: updateMetricsTemplate
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 5, Target - 2
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 2, Target - 2
    helper.go:598: Applying template: updateMetricsTemplate
    helper.go:550: Applying template: soComplexFormula
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 2, Target - 0
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 0, Target - 0
    helper.go:598: Applying template: updateMetricsTemplate
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 0, Target - 3
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - scaling-modifiers-test-deployment, Current  - 3, Target - 3
    helper.go:619: Deleting template: soComplexFormula
    helper.go:619: Deleting template: workloadDeploymentTemplate
    helper.go:619: Deleting template: deploymentTemplate
    helper.go:619: Deleting template: triggerAuthenticationTemplate
    helper.go:619: Deleting template: serviceTemplate
    helper.go:619: Deleting template: metricsServerDeploymentTemplate
    helper.go:619: Deleting template: secretTemplate
    helper.go:248: deleting namespace scaling-modifiers-test-ns
    helper.go:301: waiting for namespace scaling-modifiers-test-ns deletion
    helper.go:301: waiting for namespace scaling-modifiers-test-ns deletion
    helper.go:301: waiting for namespace scaling-modifiers-test-ns deletion
--- PASS: TestScalingModifiers (188.27s)
PASS
ok  	github.com/kedacore/keda/v2/tests/internals/scaling_modifiers
=== RUN   TestScaler
    value_metric_type_test.go:113: --- setting up ---
    helper.go:248: deleting namespace value-metric-type-test-ns
    helper.go:301: waiting for namespace value-metric-type-test-ns deletion
    helper.go:235: Creating namespace - value-metric-type-test-ns
    helper.go:550: Applying template: deploymentTemplate
    helper.go:550: Applying template: monitoredDeploymentTemplate
    value_metric_type_test.go:141: --- testing scale by AverageValue ---
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 8
    helper.go:550: Applying template: scaledObjectTemplate
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 4
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 4, Target - 4
    helper.go:619: Deleting template: scaledObjectTemplate
    value_metric_type_test.go:159: --- testing scale by Value ---
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 4, Target - 8
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 8
    helper.go:550: Applying template: scaledObjectTemplate
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 8, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 9, Target - 10
    helper.go:444: Waiting for deployment replicas to hit target. Deployment - value-metric-type-test-deployment, Current  - 10, Target - 10
    helper.go:619: Deleting template: monitoredDeploymentTemplate
    helper.go:619: Deleting template: deploymentTemplate
    helper.go:248: deleting namespace value-metric-type-test-ns
    helper.go:301: waiting for namespace value-metric-type-test-ns deletion
    helper.go:301: waiting for namespace value-metric-type-test-ns deletion
    helper.go:301: waiting for namespace value-metric-type-test-ns deletion
    helper.go:301: waiting for namespace value-metric-type-test-ns deletion
--- PASS: TestScaler (86.80s)
PASS
ok  	github.com/kedacore/keda/v2/tests/internals/value_metric_type

Could you run e2e tests once again?

@SpiritZhou
Copy link
Contributor

SpiritZhou commented Mar 20, 2024

/run-e2e
Update: You can check the progress here

@SpiritZhou
Copy link
Contributor

Could you also update the ChangeLog.md?

@yorik yorik changed the title fix: Allows ScaledObject.MinReplicaCount to be set to 0. fix: Allow ScaledObject.MinReplicaCount to be set to 0 Mar 20, 2024
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
@yorik
Copy link
Contributor Author

yorik commented Mar 20, 2024

Could you also update the ChangeLog.md?

Added.

Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
@yorik
Copy link
Contributor Author

yorik commented Mar 26, 2024

Are there any chance to merge this? #5570 blocks migration to Keda for us in production.

Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
@SpiritZhou
Copy link
Contributor

SpiritZhou commented Apr 15, 2024

/run-e2e internals
Update: You can check the progress here

Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
@JorTurFer
Copy link
Member

JorTurFer commented Apr 28, 2024

/run-e2e internals
Update: You can check the progress here

Signed-off-by: Yury Akudovich <yorik13@gmail.com>
@igor-nikiforov
Copy link

Any blockers which prevent this to be merged?

Signed-off-by: Yury Akudovich <yorik13@gmail.com>
@yorik
Copy link
Contributor Author

yorik commented May 2, 2024

Any blockers which prevent this to be merged?

I don't see any, but there was some discussion in #5570

yorik added 6 commits May 7, 2024 09:46
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
@zroubalik
Copy link
Member

zroubalik commented May 17, 2024

/run-e2e internals
Update: You can check the progress here

yorik added 4 commits May 21, 2024 13:30
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
yorik added 6 commits May 29, 2024 13:20
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Signed-off-by: Yury Akudovich <yorik13@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MinReplicaCount for ScaledObject can't be set to 0
5 participants