castai / k8s-agent

Apache License 2.0
61 stars 16 forks source link

feat: prefer object GVK over runtime type in deltas calculations #194

Closed pijusn-cast closed 1 month ago

pijusn-cast commented 1 month ago

With this change, Delta logic prioritizes GVK information coming from the object itself over the runtime information. From what I could observe, various objects do contain this information (and it's required if that object is Unstructured) but some, like Pod don't seem to include this information. This is why at this point, a fallback is required.

Note I moved kind detection to Add in order to avoid running that computation twice and to reuse that information for the cache key.

For context, this is just a preparation for the actual changes I'm after. Keeping this small in order to minimize PR and testing in production scope (given that potentially changes like these could result in incorrect Snapshots). What I'm after is getting rid of some Go structs and replacing them with Unstructured object types at which point previous implementation would potentially treat them as the same type and merge their deltas. Relying on embedded GVK information allows to distinguish between these types despite them all sharing the same runtime type.