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

Allow using simple queue names in aws sqs scaler #2483

Merged
merged 1 commit into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -40,6 +40,7 @@
- **External Scaler:** fix wrong calculation of retry backoff duration ([#2416](https://github.com/kedacore/keda/pull/2416))
- **Kafka Scaler:** allow flag `topic` to be optional, where lag of all topics within the consumer group will be used for scaling ([#2409](https://github.com/kedacore/keda/pull/2409))
- **CPU Scaler:** Adding e2e test for the cpu scaler ([#2441](https://github.com/kedacore/keda/pull/2441))
- **AWS SQS Scaler**: allow using simple queue name instead of URL ([#2457](https://github.com/kedacore/keda/pull/2457))

### Breaking Changes

Expand Down
17 changes: 9 additions & 8 deletions pkg/scalers/aws_sqs_queue_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,18 @@ func parseAwsSqsQueueMetadata(config *ScalerConfig) (*awsSqsQueueMetadata, error

queueURL, err := url.ParseRequestURI(meta.queueURL)
if err != nil {
return nil, fmt.Errorf("queueURL is not a valid URL")
}
// queueURL is not a valid URL, using it as queueName
meta.queueName = meta.queueURL
} else {
queueURLPath := queueURL.Path
queueURLPathParts := strings.Split(queueURLPath, "/")
if len(queueURLPathParts) != 3 || len(queueURLPathParts[2]) == 0 {
return nil, fmt.Errorf("cannot get queueName from queueURL")
}

queueURLPath := queueURL.Path
queueURLPathParts := strings.Split(queueURLPath, "/")
if len(queueURLPathParts) != 3 || len(queueURLPathParts[2]) == 0 {
return nil, fmt.Errorf("cannot get queueName from queueURL")
meta.queueName = queueURLPathParts[2]
}

meta.queueName = queueURLPathParts[2]

if val, ok := config.TriggerMetadata["awsRegion"]; ok && val != "" {
meta.awsRegion = val
} else {
Expand Down
8 changes: 8 additions & 0 deletions pkg/scalers/aws_sqs_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
testAWSSQSProperQueueURL = "https://sqs.eu-west-1.amazonaws.com/account_id/DeleteArtifactQ"
testAWSSQSImproperQueueURL1 = "https://sqs.eu-west-1.amazonaws.com/account_id"
testAWSSQSImproperQueueURL2 = "https://sqs.eu-west-1.amazonaws.com"
testAWSSimpleQueueURL = "my-queue"

testAWSSQSErrorQueueURL = "https://sqs.eu-west-1.amazonaws.com/account_id/Error"
testAWSSQSBadDataQueueURL = "https://sqs.eu-west-1.amazonaws.com/account_id/BadData"
Expand Down Expand Up @@ -165,6 +166,13 @@ var testAWSSQSMetadata = []parseAWSSQSMetadataTestData{
},
false,
"with AWS Role assigned on KEDA operator itself"},
{map[string]string{
"queueURL": testAWSSimpleQueueURL,
"queueLength": "1",
"awsRegion": "eu-west-1"},
testAWSSQSAuthentication,
false,
"properly formed queue and region"},
}

var awsSQSMetricIdentifiers = []awsSQSMetricIdentifier{
Expand Down