-
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
AWS SQS: Respect scaleOnDelayed #4383
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
956a482
Respect scaleOnDelayed
ivan-ding 3f787a6
Respect scaleOnDelayed
ivan-ding 213123c
Respect scaleOnDelayed
ivan-ding 2dbbe71
Respect scaleOnDelayed
ivan-ding 89ccbe2
Empty-Commit
ivan-ding 8bcf310
Empty-Commit
ivan-ding e611ff8
Empty-Commit
ivan-ding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,14 +21,10 @@ const ( | |
targetQueueLengthDefault = 5 | ||
activationTargetQueueLengthDefault = 0 | ||
defaultScaleOnInFlight = true | ||
defaultScaleOnDelayed = false | ||
) | ||
|
||
var awsSqsQueueMetricNamesForScalingInFlight = []string{ | ||
"ApproximateNumberOfMessages", | ||
"ApproximateNumberOfMessagesNotVisible", | ||
} | ||
|
||
var awsSqsQueueMetricNamesForNotScalingInFlight = []string{ | ||
var awsSqsQueueMetricNamesForScaling = []string{ | ||
"ApproximateNumberOfMessages", | ||
} | ||
Comment on lines
-27
to
29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does keeping this here make sense? I mean, maybe we could just move it to the parsing function |
||
|
||
|
@@ -49,6 +45,7 @@ type awsSqsQueueMetadata struct { | |
awsAuthorization awsAuthorizationMetadata | ||
scalerIndex int | ||
scaleOnInFlight bool | ||
scaleOnDelayed bool | ||
awsSqsQueueMetricNames []string | ||
} | ||
|
||
|
@@ -78,6 +75,7 @@ func parseAwsSqsQueueMetadata(config *ScalerConfig, logger logr.Logger) (*awsSqs | |
meta := awsSqsQueueMetadata{} | ||
meta.targetQueueLength = defaultTargetQueueLength | ||
meta.scaleOnInFlight = defaultScaleOnInFlight | ||
meta.scaleOnDelayed = defaultScaleOnDelayed | ||
|
||
if val, ok := config.TriggerMetadata["queueLength"]; ok && val != "" { | ||
queueLength, err := strconv.ParseInt(val, 10, 64) | ||
|
@@ -109,10 +107,22 @@ func parseAwsSqsQueueMetadata(config *ScalerConfig, logger logr.Logger) (*awsSqs | |
} | ||
} | ||
|
||
if val, ok := config.TriggerMetadata["scaleOnDelayed"]; ok && val != "" { | ||
scaleOnDelayed, err := strconv.ParseBool(val) | ||
if err != nil { | ||
meta.scaleOnDelayed = defaultScaleOnDelayed | ||
logger.Error(err, "Error parsing SQS queue metadata scaleOnDelayed, using default %n", defaultScaleOnDelayed) | ||
} else { | ||
meta.scaleOnDelayed = scaleOnDelayed | ||
} | ||
} | ||
|
||
meta.awsSqsQueueMetricNames = awsSqsQueueMetricNamesForScaling | ||
if meta.scaleOnInFlight { | ||
meta.awsSqsQueueMetricNames = awsSqsQueueMetricNamesForScalingInFlight | ||
} else { | ||
meta.awsSqsQueueMetricNames = awsSqsQueueMetricNamesForNotScalingInFlight | ||
meta.awsSqsQueueMetricNames = append(meta.awsSqsQueueMetricNames, "ApproximateNumberOfMessagesNotVisible") | ||
} | ||
if meta.scaleOnDelayed { | ||
meta.awsSqsQueueMetricNames = append(meta.awsSqsQueueMetricNames, "ApproximateNumberOfMessagesDelayed") | ||
} | ||
|
||
if val, ok := config.TriggerMetadata["queueURL"]; ok && val != "" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move this to
New
section? This isn't a fix because it's a new feature. The message should be something likeAdd support to scaledOnDelayed