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

Add connection name for the rabbitmq scaler #6093

Merged
merged 7 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -68,6 +68,7 @@ Here is an overview of all new **experimental** features:

### Improvements

- **RabbitMQ Scaler**: Add connection name for AMQP ([#5958](https://github.com/kedacore/keda/issues/5958))
- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))

### Fixes
Expand Down
26 changes: 15 additions & 11 deletions pkg/scalers/rabbitmq_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
rabbitMetricType = "External"
rabbitRootVhostPath = "/%2F"
rmqTLSEnable = "enable"
connectionName = "keda"
JorTurFer marked this conversation as resolved.
Show resolved Hide resolved
)

const (
Expand Down Expand Up @@ -445,22 +446,25 @@ func parseTrigger(meta *rabbitMQMetadata, config *scalersconfig.ScalerConfig) (*
}

// getConnectionAndChannel returns an amqp connection. If enableTLS is true tls connection is made using
//
// the given ceClient cert, ceClient key,and CA certificate. If clientKeyPassword is not empty the provided password will be used to
//
// the given ceClient cert, ceClient key,and CA certificate. If clientKeyPassword is not empty the provided password will be used to
// decrypt the given key. If enableTLS is disabled then amqp connection will be created without tls.
func getConnectionAndChannel(host string, meta *rabbitMQMetadata) (*amqp.Connection, *amqp.Channel, error) {
var conn *amqp.Connection
var err error
amqpConfig := amqp.Config{
Properties: amqp.Table{
"connection_name": connectionName,
},
}

if meta.enableTLS {
tlsConfig, configErr := kedautil.NewTLSConfigWithPassword(meta.cert, meta.key, meta.keyPassword, meta.ca, meta.unsafeSsl)
if configErr != nil {
return nil, nil, configErr
tlsConfig, err := kedautil.NewTLSConfigWithPassword(meta.cert, meta.key, meta.keyPassword, meta.ca, meta.unsafeSsl)
if err != nil {
return nil, nil, err
}
conn, err = amqp.DialTLS(host, tlsConfig)
} else {
conn, err = amqp.Dial(host)

amqpConfig.TLSClientConfig = tlsConfig
}

conn, err := amqp.DialConfig(host, amqpConfig)
if err != nil {
return nil, nil, err
}
Expand Down
Loading