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 Monitor Scaler will panic if the timeseries has no data #679

Closed
jsturtevant opened this issue Mar 13, 2020 · 1 comment · Fixed by #680
Closed

Azure Monitor Scaler will panic if the timeseries has no data #679

jsturtevant opened this issue Mar 13, 2020 · 1 comment · Fixed by #680

Comments

@jsturtevant
Copy link
Contributor

The metric scaler incorrectly checks for nil and does not check length so end up with the following exception:

 1 runtime.go:71] Observed a panic: runtime error: index out of range

This occurs if Azure monitor returns no timeseries as is sometimes the case for IncomingMessages for EventHub metrics.

This was originally discovered in Azure Monitor project: Azure/azure-k8s-metrics-adapter#90

@Vishal2696
Copy link

Vishal2696 commented Mar 25, 2020

@ahmelsayed @jsturtevant This has to be reopened as Just now I encountered this error. When I setup a scaledobject that will trigger autoscaling based on the IncomingMessages metric of the eventhub. I encountered this error when I pointed to an event hub that has been inactive for quite amount of time. However this worked properly when I pointed to an event-hub that has active message flow.
Below is the error message I got

panic: runtime error: index out of range [0] with length 0

goroutine 815 [running]:
github.com/kedacore/keda/pkg/scalers.extractValue(0xc000808140, 0x10, 0xc0006baa50, 0x24, 0xc00011485e, 0x1a, 0xc000114840, 0x12, 0xc000114853, 0xa, ...)
        keda/pkg/scalers/azure_monitor.go:127 +0x7e1
github.com/kedacore/keda/pkg/scalers.getAzureMetric(0x218df20, 0xc0007e52b0, 0x2190ec0, 0xc000555cb0, 0x0, 0x0, 0xdf8475800, 0xd18c2e2800, 0x3, 0x6fc23ac00, ...)
        keda/pkg/scalers/azure_monitor.go:108 +0x4c5
github.com/kedacore/keda/pkg/scalers.executeRequest(0x218df20, 0xc0007e52b0, 0x2190ec0, 0xc000555cb0, 0x0, 0x0, 0xdf8475800, 0xd18c2e2800, 0x3, 0x6fc23ac00, ...)
        keda/pkg/scalers/azure_monitor.go:79 +0xab
github.com/kedacore/keda/pkg/scalers.GetAzureMetricValue(0x21d8640, 0xc0009ca940, 0xc0003f62c0, 0xc000652710, 0xc0007f5e00, 0x42de7f)
        keda/pkg/scalers/azure_monitor.go:40 +0xf9
github.com/kedacore/keda/pkg/scalers.(*azureMonitorScaler).IsActive(0xc0000c0be8, 0x21d8640, 0xc0009ca940, 0x1, 0x1, 0xc000a5b200)
        keda/pkg/scalers/azure_monitor_scaler.go:159 +0x46
github.com/kedacore/keda/pkg/handler.(*ScaleHandler).handleScaleDeployment(0xc0005558c0, 0x21d8640, 0xc0009ca940, 0xc0003ee000)
        keda/pkg/handler/scale_loop.go:119 +0x11a
github.com/kedacore/keda/pkg/handler.(*ScaleHandler).handleScale(0xc0005558c0, 0x21d8640, 0xc0009ca940, 0xc0003ee000)
        keda/pkg/handler/scale_loop.go:45 +0x6b
github.com/kedacore/keda/pkg/handler.(*ScaleHandler).HandleScaleLoop(0xc0005558c0, 0x21d8640, 0xc0009ca940, 0xc0003ee000)
        keda/pkg/handler/scale_loop.go:14 +0x1d2
created by github.com/kedacore/keda/pkg/controller/scaledobject.(*ReconcileScaledObject).startScaleLoop
        keda/pkg/controller/scaledobject/scaledobject_controller.go:330 +0x35f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants