Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Registrations in conversion machinery are extremely misleading #84452

@wojtek-t

Description

@wojtek-t

Currently, there are two ways of registering conversion functions:
(1) Using AddConversionFuncs():
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/runtime/scheme.go#L341
(2) Using AddConversionFunc()/AddGeneratedConversionFunc():
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/runtime/scheme.go#L353

And what is extremely surprising, those registrations goes into two different and separate sets of conversions:

(a) The ones registered by (1), are NOT used at the top-level of conversions:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/conversion/converter.go#L494
(b) But as soon as you get into "default" mode (the reflection-based), the ones registered by (2) are NO LONGER used - only the ones from the first set are used:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/conversion/converter.go#L563

This is incredibly misleading, and I think is actually leading to couple places that I guess didn't mean to do that, e.g.:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/tools/clientcmd/api/v1/conversion.go#L29

We need to get rid of (1), and clean this stuff up.

@kubernetes/sig-api-machinery-bugs
@liggitt @deads2k @smarterclayton - FYI

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions