Skip to content

Conversion function is registered to copy of scheme #12683

@lubronzhan

Description

@lubronzhan

What steps did you take and what happened?

Similar to vmware-tanzu/vm-operator#1132

One of the example here

localSchemeBuilder = schemeBuilder

localSchemeBuilder is a copy, not a pointer to schemeBuilder.

While code here registers the func to the copy.

localSchemeBuilder.Register(RegisterConversions)

So the conversion functions in RegisterConversions are not actually registered.

Server-side (apiserver) conversion webhook use Hub/Spoke pattern which delegates to Convert_* functions, but they do not use the scheme’s RegisterConversions automatically. So server side conversion doesn't get impacted, so this bug was never discovered.
This happens when someone tries to explicitly call the scheme.Convert() from client.

What did you expect to happen?

localSchemeBuilder = &schemeBuilder

A simple replaceAll should do the work

Cluster API version

All

Kubernetes version

No response

Anything else you would like to add?

No response

Label(s) to be applied

/kind bug
One or more /area label. See https://github.com/kubernetes-sigs/cluster-api/labels?q=area for the list of labels.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-priorityIndicates an issue lacks a `priority/foo` label and requires one.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions