redhat-cop / operator-utils

Utilities to support operators
Apache License 2.0
153 stars 37 forks source link

Avoid panics in manageError when inspecting a nil instance #68

Closed roivaz closed 3 years ago

roivaz commented 3 years ago

First of all I wanted to thank you for the awesome project, we are currently using in it a couple of our operators (https://github.com/3scale-ops/marin3r and https://github.com/3scale-ops/saas-operator).

We have detected some panics in the manageError function that happen whenever errors occur in API calls that result in the call not returning a result. In these cases, calling instance.GetGeneration triggers a panic as instance is nil. In our case we have detected this primarily in our test suite, for example when the context is canceled before the API call is completed (which happens a lot in testing). I'm unsure if there are other error types that cause the same behavior, so my approach to fixing this was just making sure that instance actually holds a value before inspecting it. I don't know the code base that well, so maybe there is a better approach to fixing this.

roivaz commented 3 years ago

Hi @raffaelespazzoli, could you review this or point me to someone that can? Thanks! :)