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

Cron scaler: Fix unexpected instance count change #3838

Merged
merged 4 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio

### New

- **Cron Scaler**: Fix unexpected instance count change. ([#3838](https://github.com/kedacore/keda/pull/3838))
zou2699 marked this conversation as resolved.
Show resolved Hide resolved
- **General**: Introduction deprecation & breaking change policy ([Governance #68](https://github.com/kedacore/governance/issues/68))
- **General**: Consolidate all exposed Prometheus Metrics in KEDA Operator ([#3919](https://github.com/kedacore/keda/issues/3919))
- **General**: Disable response compression for k8s restAPI in client-go ([#3863](https://github.com/kedacore/keda/issues/3863)). Kubernetes issue for reference (https://github.com/kubernetes/kubernetes/issues/112296)
Expand Down
5 changes: 3 additions & 2 deletions pkg/scalers/cron_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ func (s *cronScaler) IsActive(ctx context.Context) (bool, error) {
return false, fmt.Errorf("unable to load timezone. Error: %s", err)
}

// Since we are considering the timestamp here and not the exact time, timezone does matter.
currentTime := time.Now().Unix()

nextStartTime, startTimecronErr := getCronTime(location, s.metadata.start)
if startTimecronErr != nil {
return false, fmt.Errorf("error initializing start cron: %s", startTimecronErr)
Expand All @@ -131,8 +134,6 @@ func (s *cronScaler) IsActive(ctx context.Context) (bool, error) {
return false, fmt.Errorf("error intializing end cron: %s", endTimecronErr)
}

// Since we are considering the timestamp here and not the exact time, timezone does matter.
currentTime := time.Now().Unix()
switch {
case nextStartTime < nextEndTime && currentTime < nextStartTime:
return false, nil
Expand Down