cluster-api: KubeadmConfig conversion webhook cannot return errors when downconverting

What steps did you take and what happened:

  • Create a v1alpha3 KubeadmConfig with status.dataSecretName set
  • Retrieve it as v1alpha2 (so it’s converted)
  • Get an error

What did you expect to happen:

  • No error

Anything else you would like to add: I checked with sig-apimachinery and conversion cannot fail because an older api version doesn’t have the same fields as a newer one. In Convert_v1alpha3_KubeadmConfigStatus_To_v1alpha2_KubeadmConfigStatus, we’re returning an error if the a3 version has status.dataSecretName. We can choose from:

  1. Silently drop the field
  2. Add the new field to all API versions so that it’s convertible (it would be present but unreconciled/unused in older versions)
  3. Shuttle the field through metadata (annotation) so that a3 -> a2 -> a3 would preserve the value.

Option 1 is probably a nonstarter because it would mean we’d lose data if we did a3 -> a2 -> update apiserver.

Environment:

  • Cluster-api version: master

/kind bug

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

Yes

If they do an update instead of a patch, yes. That’s why we’ve been pushing patch so heavily. Sounds like the annotation approach is the safest?

I did a quick bit of prototyping a while back to prove out the idea, and it was relatively simple to implement, just had to implement it in either the ConvertFrom methods, or in the Convert_v1alpha3_<Type>_To_v1alpha2_Type> methods, since the Spec/Status conversion methods don’t have access to the annotations.