Skip to content

Commit

Permalink
feat: Support using connection strings for Event Hub namespace instea…
Browse files Browse the repository at this point in the history
…d of the Event Hub itself. (kedacore#3924)

Signed-off-by: Vighnesh Shenoy <vshenoy@microsoft.com>
  • Loading branch information
v-shenoy authored and josephangbc committed Dec 6, 2022
1 parent 9568a1f commit 3a570ec
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 58 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
- **Apache Kafka Scaler:** Limit Kafka Partitions KEDA operates on ([#3830](https://github.com/kedacore/keda/issues/3830))
- **Azure AD Pod Identity Authentication:** Improve error messages to emphasize problems around the integration with aad-pod-identity itself ([#3610](https://github.com/kedacore/keda/issues/3610))
- **Azure Event Hub Scaler:** Support Azure Active Direcotry Pod & Workload Identity for Storage Blobs ([#3569](https://github.com/kedacore/keda/issues/3569))
- **Azure Event Hub Scaler:** Support using connection strings for Event Hub namespace instead of the Event Hub itself. ([#3922](https://github.com/kedacore/keda/issues/3922))
- **Azure Pipelines Scaler:** Improved speed of profiling large set of Job Requests from Azure Pipelines ([#3702](https://github.com/kedacore/keda/issues/3702))
- **GCP Storage Scaler:** Add prefix and delimiter support ([#3756](https://github.com/kedacore/keda/issues/3756))
- **Metrics API Scaler:** Add unsafeSsl paramater to skip certificate validation when connecting over HTTPS ([#3728](https://github.com/kedacore/keda/discussions/3728))
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ clientset-generate: ## Generate client-go clientset, listers and informers.
./hack/update-codegen.sh

proto-gen: protoc-gen ## Generate Liiklus, ExternalScaler and MetricsService proto
PATH=$(LOCALBIN):$(PATH) protoc -I vendor --proto_path=hack LiiklusService.proto --go_out=pkg/scalers/liiklus --go-grpc_out=pkg/scalers/liiklus
PATH=$(LOCALBIN):$(PATH) protoc -I vendor --proto_path=pkg/scalers/externalscaler externalscaler.proto --go_out=pkg/scalers/externalscaler --go-grpc_out=pkg/scalers/externalscaler
PATH="$(LOCALBIN):$(PATH)" protoc -I vendor --proto_path=hack LiiklusService.proto --go_out=pkg/scalers/liiklus --go-grpc_out=pkg/scalers/liiklus
PATH="$(LOCALBIN):$(PATH)" protoc -I vendor --proto_path=pkg/scalers/externalscaler externalscaler.proto --go_out=pkg/scalers/externalscaler --go-grpc_out=pkg/scalers/externalscaler

.PHONY: mockgen-gen
mockgen-gen: mockgen pkg/mock/mock_scaling/mock_interface.go pkg/mock/mock_scaler/mock_scaler.go pkg/mock/mock_scale/mock_interfaces.go pkg/mock/mock_client/mock_interfaces.go pkg/scalers/liiklus/mocks/mock_liiklus.go
Expand Down
24 changes: 21 additions & 3 deletions pkg/scalers/azure_eventhub_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,33 @@ func parseAzureEventHubAuthenticationMetadata(logger logr.Logger, config *Scaler
return fmt.Errorf("no storage connection string given")
}

connection := ""
if config.AuthParams["connection"] != "" {
meta.eventHubInfo.EventHubConnection = config.AuthParams["connection"]
connection = config.AuthParams["connection"]
} else if config.TriggerMetadata["connectionFromEnv"] != "" {
meta.eventHubInfo.EventHubConnection = config.ResolvedEnv[config.TriggerMetadata["connectionFromEnv"]]
connection = config.ResolvedEnv[config.TriggerMetadata["connectionFromEnv"]]
}

if len(meta.eventHubInfo.EventHubConnection) == 0 {
if len(connection) == 0 {
return fmt.Errorf("no event hub connection string given")
}

if !strings.Contains(connection, "EntityPath") {
eventHubName := ""
if config.TriggerMetadata["eventHubName"] != "" {
eventHubName = config.TriggerMetadata["eventHubName"]
} else if config.TriggerMetadata["eventHubNameFromEnv"] != "" {
eventHubName = config.ResolvedEnv[config.TriggerMetadata["eventHubNameFromEnv"]]
}

if eventHubName == "" {
return fmt.Errorf("connection string does not contain event hub name, and parameter eventHubName not provided")
}

connection = fmt.Sprintf("%s;EntityPath=%s", connection, eventHubName)
}

meta.eventHubInfo.EventHubConnection = connection
case v1alpha1.PodIdentityProviderAzure, v1alpha1.PodIdentityProviderAzureWorkload:
meta.eventHubInfo.StorageAccountName = ""
if val, ok := config.TriggerMetadata["storageAccountName"]; ok {
Expand Down
Loading

0 comments on commit 3a570ec

Please sign in to comment.