Skip to content

Commit

Permalink
Cron scaler: Fix unexpected instance count change (#3838)
Browse files Browse the repository at this point in the history
Signed-off-by: tux <[email protected]>
  • Loading branch information
zou2699 authored Dec 8, 2022
1 parent ccd6705 commit 35e6b6b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
- **AWS Scalers**: Add setting AWS endpoint url. ([#3337](https://github.com/kedacore/keda/issues/3337))
- **Azure Service Bus Scaler**: Add support for Shared Access Signature (SAS) tokens for authentication. ([#2920](https://github.com/kedacore/keda/issues/2920))
- **Azure Service Bus Scaler:** Support regex usage in queueName / subscriptionName parameters. ([#1624](https://github.com/kedacore/keda/issues/1624))
- **Cron Scaler**: Fix unexpected instance count change. ([#3838](https://github.com/kedacore/keda/pull/3838))
- **ElasticSearch Scaler**: Support for ElasticSearch Service on Elastic Cloud ([#3785]https://github.com/kedacore/keda/issues/3785)
- **Selenium Grid Scaler:** Allow setting url trigger parameter from TriggerAuthentication/ClusterTriggerAuthentication ([#3752](https://github.com/kedacore/keda/pull/3752))

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

0 comments on commit 35e6b6b

Please sign in to comment.