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

Azure Blob Scaler fails when using multiple triggers with different blobPrefixes #1815

Closed
MattJeanes opened this issue May 20, 2021 · 4 comments · Fixed by #1816
Closed

Azure Blob Scaler fails when using multiple triggers with different blobPrefixes #1815

MattJeanes opened this issue May 20, 2021 · 4 comments · Fixed by #1816
Labels
bug Something isn't working

Comments

@MattJeanes
Copy link
Contributor

Report

The metricName uniqueness is not adequate when using multiple scalers with the same blobContainerName but a different blobPrefix

The current code only uses blobContainerName for uniqueness when it should include blobPrefix: https://github.com/kedacore/keda/blob/v2.2.0/pkg/scalers/azure_blob_scaler.go#L153

Expected Behavior

The scaler should work correctly without error

Actual Behavior

The scaler does not work , status of the ScaledObject shows:

status:
  conditions:
    - message: Failed to ensure HPA is correctly created for ScaledObject
      reason: ScaledObjectCheckFailed
      status: 'False'
      type: Ready
    - message: ScaledObject check failed
      reason: UnkownState
      status: Unknown
      type: Active
  originalReplicaCount: 

Steps to Reproduce the Problem

  1. Create a ScaledObject with multiple blob triggers using the same blobContainerName but a different blobPrefix:
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: my-scaled-function-scaler
spec:
  scaleTargetRef:
    name: my-scaled-function
  triggers:
    - metadata:
        blobContainerName: mycontainer
        blobPrefix: folder1
        connectionFromEnv: AzureWebJobsStorage
      type: azure-blob
    - metadata:
        blobContainerName: mycontainer
        blobPrefix: folder2
        connectionFromEnv: AzureWebJobsStorage
      type: azure-blob
  1. The ScaledObject fails to work correctly

Logs from KEDA operator

2021-05-20T00:05:22.235Z	INFO	controllers.ScaledObject	Reconciling ScaledObject	{"ScaledObject.Namespace": "my-namespace", "ScaledObject.Name": "my-scaled-function-scaler"}
2021-05-20T00:05:22.236Z	INFO	controllers.ScaledObject	Creating a new HPA	{"ScaledObject.Namespace": "my-namespace", "ScaledObject.Name": "my-scaled-function-scaler", "HPA.Namespace": "my-namespace", "HPA.Name": "keda-hpa-my-scaled-function-scaler"}
2021-05-20T00:05:22.236Z	ERROR	controllers.ScaledObject	Failed to create new HPA resource	{"ScaledObject.Namespace": "my-namespace", "ScaledObject.Name": "my-scaled-function-scaler", "HPA.Namespace": "my-namespace", "HPA.Name": "keda-hpa-my-scaled-function-scaler", "error": "metricName azure-blob-mycontainer defined multiple times in ScaledObject my-scaled-function-scaler, please refer the documentation how to define metricName manually"}
github.com/kedacore/keda/v2/controllers.(*ScaledObjectReconciler).ensureHPAForScaledObjectExists
	/workspace/controllers/scaledobject_controller.go:316
github.com/kedacore/keda/v2/controllers.(*ScaledObjectReconciler).reconcileScaledObject
	/workspace/controllers/scaledobject_controller.go:204
github.com/kedacore/keda/v2/controllers.(*ScaledObjectReconciler).Reconcile
	/workspace/controllers/scaledobject_controller.go:160
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.5/pkg/internal/controller/controller.go:244
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.5/pkg/internal/controller/controller.go:218
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).worker
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.5/pkg/internal/controller/controller.go:197
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:155
k8s.io/apimachinery/pkg/util/wait.BackoffUntil
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:156
k8s.io/apimachinery/pkg/util/wait.JitterUntil
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:133
k8s.io/apimachinery/pkg/util/wait.Until
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:90
2021-05-20T00:05:22.236Z	ERROR	controllers.ScaledObject	Failed to ensure HPA is correctly created for ScaledObject	{"ScaledObject.Namespace": "my-namespace", "ScaledObject.Name": "my-scaled-function-scaler", "error": "metricName azure-blob-mycontainer defined multiple times in ScaledObject my-scaled-function-scaler, please refer the documentation how to define metricName manually"}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.5/pkg/internal/controller/controller.go:244
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.5/pkg/internal/controller/controller.go:218
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).worker
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.5/pkg/internal/controller/controller.go:197
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:155
k8s.io/apimachinery/pkg/util/wait.BackoffUntil
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:156
k8s.io/apimachinery/pkg/util/wait.JitterUntil
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:133
k8s.io/apimachinery/pkg/util/wait.Until
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:90
2021-05-20T00:05:22.249Z	ERROR	controller	Reconciler error	{"reconcilerGroup": "keda.sh", "reconcilerKind": "ScaledObject", "controller": "scaledobject", "name": "my-scaled-function-scaler", "namespace": "my-namespace", "error": "metricName azure-blob-mycontainer defined multiple times in ScaledObject my-scaled-function-scaler, please refer the documentation how to define metricName manually"}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.5/pkg/internal/controller/controller.go:218
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).worker
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.5/pkg/internal/controller/controller.go:197
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:155
k8s.io/apimachinery/pkg/util/wait.BackoffUntil
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:156
k8s.io/apimachinery/pkg/util/wait.JitterUntil
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:133
k8s.io/apimachinery/pkg/util/wait.Until
	/go/pkg/mod/k8s.io/apimachinery@v0.20.4/pkg/util/wait/wait.go:90

KEDA Version

2.2.0

Kubernetes Version

1.20

Platform

Microsoft Azure

Scaler Details

Azure Blob

Anything else?

No response

@MattJeanes MattJeanes added the bug Something isn't working label May 20, 2021
@zroubalik
Copy link
Member

Could you please send a fix so the blobPrefix is included into the metricName? Thanks!

@MattJeanes
Copy link
Contributor Author

I'll give it a go! I don't have much experience with Go but looks to be a relatively simple change 😄

@zroubalik
Copy link
Member

Thanks a lot, it should be an easy one! It could be a good starter for Go and KEDA developement :)

@MattJeanes
Copy link
Contributor Author

I've raised this now, I tested it on my Kubernetes cluster with my own built image and it works!

I've also included the ability to manually specify the metricName while I was at it: #1816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants