Skip to content

Commit

Permalink
validation and check in cron scaler for same start and end case (keda…
Browse files Browse the repository at this point in the history
…core#2032)

Signed-off-by: nilayasiktoprak <[email protected]>
  • Loading branch information
Ritikaa96 authored and nilayasiktoprak committed Oct 23, 2021
1 parent d92cc3f commit 15046c6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

### Improvements

- TODO ([#XXX](https://github.com/kedacore/keda/pull/XXX))
- Improve validation in Cron scaler in case start & end input is same.([#2032](https://github.com/kedacore/keda/pull/2032))

### Breaking Changes

Expand Down
3 changes: 3 additions & 0 deletions pkg/scalers/cron_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ func parseCronMetadata(config *ScalerConfig) (*cronMetadata, error) {
} else {
return nil, fmt.Errorf("no end schedule specified. %s", config.TriggerMetadata)
}
if meta.start == meta.end {
return nil, fmt.Errorf("error parsing schedule. %s: start and end can not have exactly same time input", config.TriggerMetadata)
}
if val, ok := config.TriggerMetadata["desiredReplicas"]; ok && val != "" {
metadataDesiredReplicas, err := strconv.Atoi(val)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/scalers/cron_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var testCronMetadata = []parseCronMetadataTestData{
{map[string]string{"timezone": "Asia/Kolkata", "start": "-30 * * * *", "end": "45 * * * *", "desiredReplicas": "10"}, true},
{map[string]string{"timezone": "Asia/Kolkata", "start": "30 * * * *", "end": "-50 * * * *", "desiredReplicas": "10"}, true},
{map[string]string{"timezone": "Asia/Kolkata", "start": "30 * * * *", "end": "50 * * -3 *", "desiredReplicas": "10"}, true},
{map[string]string{"timezone": "Asia/Kolkata", "start": "30 * * * *", "end": "30 * * * *", "desiredReplicas": "10"}, true},
}

var cronMetricIdentifiers = []cronMetricIdentifier{
Expand Down

0 comments on commit 15046c6

Please sign in to comment.