Repository navigation
feat: allow maxReplicas=0 to completely disable workload - #3
Conversation
Setting maxReplicas to 0 acts as a manual "disable switch" to immediately scale to 0 and free all resources. Useful for maintenance windows or cost saving during off-hours. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @dittops, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant enhancement to the BudAIScaler by allowing the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a feature to allow setting maxReplicas: 0 to disable a workload. The changes in the BudAIScaler type definition and the main CRD YAML are correct. However, the implementation is incomplete. There is a critical issue in the controller's validation logic that prevents maxReplicas: 0 from being used. Additionally, several other CRD definition files in the repository have not been updated to reflect this change, which will lead to inconsistent behavior and validation errors. I've left a detailed comment with the required fixes.
| // Set to 0 to completely disable the workload and free all resources. | ||
| // +kubebuilder:validation:Required | ||
| // +kubebuilder:validation:Minimum=1 | ||
| // +kubebuilder:validation:Minimum=0 |
There was a problem hiding this comment.
While changing the validation here is correct, the implementation of this feature seems incomplete. The PR will not work as intended because of issues in other files:
-
Controller Validation: The validation logic in the controller has not been updated to allow
maxReplicas: 0. The reconciliation will fail for anyBudAIScalerwithmaxReplicas: 0.
Inpkg/controller/budaiscaler/budaiscaler_controller.go, line 206:if scaler.Spec.MaxReplicas < 1 { return fmt.Errorf("maxReplicas must be at least 1") }
This check should be changed to
if scaler.Spec.MaxReplicas < 0to allow0as a valid value. -
Inconsistent CRD Definitions: The CRD definitions in other parts of the repository have not been updated. This will cause validation failures at the API server level if those definitions are used.
config/crd/bases/scaler.bud.studio_budaiscalers.yamlcharts/scaler/crds/scaler.bud.studio_budaiscalers.yaml
Both files still have
minimum: 1formaxReplicas. Please ensure all generated files are updated, perhaps by runningmake manifestsor a similar command.
Without these changes, the feature to disable workloads with maxReplicas: 0 is not functional.
Setting maxReplicas to 0 acts as a manual "disable switch" to immediately scale to 0 and free all resources. Useful for maintenance windows or cost saving during off-hours.