Description
Quoting @mdbooth from Slack
We recently discovered in CAPO a couple of classes of error in the way we were doing API version conversion from our currently release API version to the soon-to-be-released version. The errors were around how we restore data from lossy conversions using the annotation. Specifically, the errors were:
- We could restore old data which had been modified during up-conversion, resulting in data loss
- We could try to restore data to a struct whose parent had been deleted during up-conversion, resulting in a panic
We already run the incredibly useful CAPI fuzz tests, but they weren't sufficient to exercise these bugs so I wrote some more based on the existing ones: https://github.com/shiftstack/cluster-api-provider-openstack/blob/issue1606/test/helpers/fuzz_mutate.go
These aren't merged in CAPO yet, but I'm wondering if folks would be interested in adding them alongside the existing tests in https://github.com/kubernetes-sigs/cluster-api/blob/main/util/conversion/conversion.go.I would keep the tests separate as here, so you'd have to call the new tests explicitly. The reason for this is that they're highly likely to find bugs for non-trivial API conversions, and these bugs can be extremely difficult to fix. It wouldn't be desirable to force users of the existing fuzz tests to fix them all before version bumping CAPI.
xref: https://kubernetes.slack.com/archives/C8TSNPY4T/p1691583086419469
I think this would be a great addition to our tests