-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
unexpected cron scaling issue when start / end are defined with different days #4677
Comments
Hi, keda/pkg/scalers/cron_scaler.go Lines 164 to 174 in 2234a6f
as the next start is on Monday and next end is today, the first case is rejected, but as current time is before end time, the scaler thinks that it's in active period. TBH, I don't see an easy solution from code pov because there are multiple "end periods" without any "starting period", but I can suggest a workaround. if you set the ending cron for the same days that the starting cron, the problem will be solved:
|
BTW, based on the ScaledObject name ("selenium-node-chrome") I guess that you are scaling out/in a selenium node. Don't you prefer to use the selenium scaler directly? |
Thank you, we are using your suggested solution, but still I see this mentioned version as buggy. |
@JorTurFer I think this bug is persisting because of the design itself. Why we have taken start and end time when cron spec says "timezone and time" instead of "timezone, start and end" should inherently provide everything.
We would be able to leverage the cron library in a better way. Also, I think there are some bugs in parsing logic as well for example |
If you think that we can change the user side spec in maybe next or next to next release, this change might be worth considering as it would not require changing a lot of code, and the code side interface will remain the same and we would have one to one cron consistency. Also, it might not be a good first issue so I think we should remove the label. PS - I will try to fix it when I will get some time. |
This function is used only to sanitize the expression for the hpa's metric name. The parsing relies in the underlying library: keda/pkg/scalers/cron_scaler.go Lines 56 to 68 in 739b770
Yeah, but I'd not invest too much time because we want to redesign it as new scaler: #3566 |
Yeah that library is like the defacto standard to handle cron in go. That's why I was saying it as we would not require any sort of redundant handling, etc.
But after looking at the design proposal to change the spec. It looks really brilliant, I really like the idea. Minimal parsing can get things done. No library imports, required, etc. This is exactly what I wanted to do but with cron library, but the kube-green based interface design is like much much better, sleek and elegant. So basically two targets that we have to rewrite is cron_scaler.go and appropriate test. Also I just did a brief overview and think these files are self-inclusive for such implementation, as other things are being handled by Keda internal interfaces. If I have missed anything, let me know and feel free to assign me the issue. if everything looks good , I will try to implement the issue this week. Thanks! |
We should keep the current cron scaler backward compatible, and that's why we proposed to create another one. But if you implement it as a new scaler, it's fine :) |
Can we close this issue then in favor of #3566? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
@krishna-kariya PTAL. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed due to inactivity. |
Report
We wanna to scale our deployments / statefulsets from 0 replicas to bigger number (3) during working days from 6:30AM to 10:10PM. We have used following setup:
The problem is, that during working days from Mon to Fri, pods are correctly started, but they did not stop on Friday, as expected, and keep running till Sunday 22:10.
Expected Behavior
We expect, that using this definition for cron, pods will start (scale up to 3 replicas) each working day at 6:30 and stop (scale down to 0 replicas) daily at 22:10.
Actual Behavior
During working days from Mon to Fri, pods are correctly started, but they did not stop on Friday, as expected, and keep running till Sunday 22:10.
Steps to Reproduce the Problem
Logs from KEDA operator
KEDA Version
2.10.0
Kubernetes Version
1.26
Platform
Amazon Web Services
Scaler Details
cron
Anything else?
No response
The text was updated successfully, but these errors were encountered: