-
Notifications
You must be signed in to change notification settings - Fork 205
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 bug where some ConfigMap and Secret references could be missed #4330
Conversation
if reflect.PointerTo(rt).Implements(interfaceType) { | ||
return gvk, nil | ||
} |
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.
Why not use the existing NewEmptyVersionedResourceFromGVK()
and then test using if _, ok := empty.(conversion.Hub); ok
, avoiding the cryptic reflection code?
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.
Two reasons:
scheme.AllKnownTypes
returns amap[schema.GroupVersionKind]reflect.Type
, so it seemed to make some sense to stay in the "reflect world" when scanning it if I don't actually need an instance.- Since this is called in the (somewhat) hot path of the core reconcile loop logic, and can be hit at least a couple times through each loop (because there may be multiple versions of a resource for a given group + version) I was a bit concerned about performance/extra allocations. It probably wouldn't matter but avoiding constructing 8-10 objects that are immediately thrown away when instead we can do a check via reflection that avoids those allocations.
I almost just computed a map of this upfront once and then we could look it up whenever we wanted but that seemed overkill so instead settled on using a less-allocations approach using this reflection method that kept things "simple" (no extra variables to storage cached data that needed to be passed around) while still avoiding excess allocations.
The ASO controller uses reflection to look through the resource and find the ConfigMapReference and SecretReference fields. This reflection could miss SecretReference and ConfigMapReference fields that had been serialized into the "PropertyBag" property on the storage type. This was most common when working with preview APIs that had added new ConfigMapReference or SecretReference fields that don't exist in the GA api version. The fix is to use the converted version for reflection-based discovery. Fixes Azure#4298. Fixes Azure#4316.
f209def
to
654df66
Compare
/ok-to-test sha=654df66 |
The ASO controller uses reflection to look through the resource and find the ConfigMapReference and SecretReference fields. This reflection could miss SecretReference and ConfigMapReference fields that had been serialized into the "PropertyBag" property on the storage type. This was most common when working with preview APIs that had added new ConfigMapReference or SecretReference fields that don't exist in the GA api version.
The fix is to use the converted version for reflection-based discovery.
Fixes #4298.
Fixes #4316.
If applicable: