fix: emit active metric for resource scalers#7755
Conversation
Signed-off-by: Puneet Dixit <[email protected]>
|
Thank you for your contribution! 🙏 Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected. While you are waiting, make sure to:
Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient. Learn more about our contribution guide. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Signed-off-by: Puneet Dixit <[email protected]>
Use context.Background in the resource scaler active metric regression test instead of context.TODO. Signed-off-by: Puneet Dixit <[email protected]>
|
Thanks for the great improvement! I think that this makes sense to be included as part of e2e test
By adding a test also there, we can ensure that the metric will be always rightly generated |
There was a problem hiding this comment.
Pull request overview
This PR fixes missing initialization of the keda_scaler_active Prometheus metric for CPU/memory (resource) triggers by recording activity metrics for resource and containerResource metric specs that KEDA otherwise skips querying directly. This improves Grafana dashboard label discovery for ScaledObjects that only use CPU/memory triggers.
Changes:
- Record
keda_scaler_activeforResource/ContainerResourcemetric specs before continuing past non-external metric specs. - Add a unit test that asserts
keda_scaler_activeis emitted with the expected labels for a CPU resource trigger. - Add a changelog entry for the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/scaling/scale_handler.go | Emit keda_scaler_active for resource/containerResource metric specs that were previously skipped. |
| pkg/scaling/scale_handler_test.go | Add regression test to ensure the active metric is emitted for resource scalers. |
| CHANGELOG.md | Document the bugfix for missing keda_scaler_active on CPU/memory triggers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Puneet Dixit <[email protected]>
|
Added the requested Prometheus and OpenTelemetry sequential coverage in 6f2ee46. Local checks passed: go test ./pkg/scaling -count=1, and go test -tags e2e ./tests/sequential/prometheus_metrics ./tests/sequential/opentelemetry_metrics -run "^$" -count=0. |
|
/run-e2e sequential |
|
Thanks for running the sequential e2e. I checked the failing run/artifact and it looks like this failed in shared setup before the new sequential metric tests ran: Could you rerun |
Signed-off-by: Rick Brouwer <[email protected]>
|
/run-e2e sequential passed tests: 5failed tests: 0 |
…-scaler-active Signed-off-by: Deepak kudi <[email protected]> # Conflicts: # CHANGELOG.md
|
Merged current Local verification before push:
Fresh GitHub checks are queued/running now; DCO is already green. |
|
Merged current Local verification:
GitHub checks are running on the new head |
|
/run-e2e sequential passed tests: 5failed tests: 0 |
…ration (#7808) #7755 added TestGetScaledObjectStateRecordsResourceScalerActiveMetric and TestGetScaledObjectStateSkipsResourceScalerActiveMetricWithModifiers using record.NewFakeRecorder. In the meantime #7781 migrated this file to the events recorder and dropped the k8s.io/client-go/tools/record import, so the merged result fails to compile with "undefined: record", breaking the unit-test build and Static Checks on main. Use events.NewFakeRecorder, matching the rest of the file and the events.EventRecorder type of the Recorder/recorder fields. Signed-off-by: Jan Wozniak <[email protected]>
Signed-off-by: Puneet Dixit <[email protected]> Signed-off-by: Rick Brouwer <[email protected]> Co-authored-by: Puneet Dixit <[email protected]> Co-authored-by: Rick Brouwer <[email protected]> Co-authored-by: Deepak kudi <[email protected]> Signed-off-by: Yurii Shcherbak <[email protected]>
…ration (kedacore#7808) kedacore#7755 added TestGetScaledObjectStateRecordsResourceScalerActiveMetric and TestGetScaledObjectStateSkipsResourceScalerActiveMetricWithModifiers using record.NewFakeRecorder. In the meantime kedacore#7781 migrated this file to the events recorder and dropped the k8s.io/client-go/tools/record import, so the merged result fails to compile with "undefined: record", breaking the unit-test build and Static Checks on main. Use events.NewFakeRecorder, matching the rest of the file and the events.EventRecorder type of the Recorder/recorder fields. Signed-off-by: Jan Wozniak <[email protected]> Signed-off-by: Yurii Shcherbak <[email protected]>
Fixes #4945.
This records
keda_scaler_activefor resource metrics before skipping the CPU/memory metric specs that KEDA does not query directly. The existing behavior for resource metric values/errors stays unchanged, but the active metric is initialized so dashboards can resolve labels for ScaledObjects that only use CPU or memory triggers.Tests:
GOMODCACHE="$PWD/.gomodcache" GOCACHE="$PWD/.gocache" go test ./pkg/scaling -run TestGetScaledObjectStateRecordsResourceScalerActiveMetric -count=2GOMODCACHE="$PWD/.gomodcache" GOCACHE="$PWD/.gocache" go test ./pkg/scaling -count=1GOMODCACHE="$PWD/.gomodcache" GOCACHE="$PWD/.gocache" go test ./pkg/metricscollector -count=1git diff --checkChecklist
make generate-scalers-schemahas been run to update any outdated generated filesDocumentation, Helm chart, scaler schema, and new-scaler governance updates are not applicable here because this only initializes an existing metric and does not change manifests, scaler schemas, or public configuration.