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

fix: reassign err to prevent invalid return in KedaProvider GetExternalMetric #6010

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

maxcao13
Copy link
Contributor

@maxcao13 maxcao13 commented Jul 31, 2024

Here in the the KedaProvider https://github.com/openshift/kedacore-keda/blob/be1b1737c53f708a62a6a7386b27f5f208bf7094/pkg/provider/provider.go#L92. The GetExternalMetric function can return nil,nil in the wait for the connection to be ready since it does not reassign the err variable.

The nil,nil gets dereferenced here: https://github.com/kubernetes-sigs/custom-metrics-apiserver/blob/1e7ed5df24ef39898861260b002d9400f2d09300/pkg/registry/external_metrics/reststorage.go#L87 and hence panics in the code.

This fix reassigns the err so that an invalid nil,nil return can not happen.

Checklist

Fixes #6009

@maxcao13 maxcao13 requested a review from a team as a code owner July 31, 2024 22:02
@JorTurFer
Copy link
Member

/skip-e2e

@JorTurFer JorTurFer merged commit d2f94b8 into kedacore:main Jul 31, 2024
20 checks passed
@JorTurFer
Copy link
Member

nice catch! Thanks for the fix ❤️

@maxcao13 maxcao13 deleted the fix-nil-dereference branch August 6, 2024 16:00
JorTurFer pushed a commit to JorTurFer/keda that referenced this pull request Oct 7, 2024
…nalMetric` (kedacore#6010)

Signed-off-by: Max Cao <macao@redhat.com>
Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KedaProvider GetExternalMetric can return nil,nil and cause nil pointer reference
3 participants