-
Notifications
You must be signed in to change notification settings - Fork 344
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 runtime panic when trying to update operator controlled resources that don't have annotation or labels #433
Conversation
Signed-off-by: Xabier Larrakoetxea <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #433 +/- ##
==========================================
+ Coverage 89.79% 91.11% +1.32%
==========================================
Files 64 64
Lines 3115 3130 +15
==========================================
+ Hits 2797 2852 +55
+ Misses 216 196 -20
+ Partials 102 82 -20
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for finding this and submitting a PR.
pkg/inventory/misc.go
Outdated
|
||
// initK8sObjectMeta will set the required default settings to | ||
// kubernetes objects metadata if is required. | ||
func initK8sObjectMeta(obj metav1.Object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move this to pkg/util/util.go
?
Also would be good to have a test for this.
Ready for a new check! |
…ethod to an utility method Signed-off-by: Xabier Larrakoetxea <[email protected]>
@slok Thanks! |
Hi!
First of all, thanks for this awesome software, it helps us a lot (also Jaeger! 😄).
This PR fixes the possibility of having runtime panics due to the operator trying to update annotations or labels on existing Kubernetes resources that don't have labels or annotations.
This happened to us when we upgraded from
v1.11.0
to a newer version (v1.11.1
andv1.12.0
), the operator listed the operator ownedservices
and tried to update the annotations, it didn't have, so the map wasn't initialized and when updating it hit a panic due to the assignment on the map making the operator enter in crash loopback.To fix it I initialized the annotation and label maps when they are nil, also I saw that this was on all the resources of the inventory, so I applied the same logic to all of the resources.
In the meantime, we managed to bypass the problem setting a dummy annotation on all the services controlled by the operator.
Here are tracebacks of the panic:
Also happens on
v1.11.1
Thanks!