Repository navigation
Description
What happened?
Right now, if you have a cross-package type reference, e.g. the authorization.k8s.io type AuthorizationConditionsRequest refers to AdmissionRequest in admission.k8s.io, conversion-gen fails with
if in.AdmissionRequest != nil {
in, out := &in.AdmissionRequest, &out.AdmissionRequest
*out = new(admission.AdmissionRequest)
// FIXME: Provide conversion function to convert admissionv1.AdmissionRequest to admission.AdmissionRequest
compileErrorOnMissingConversion()
} else {
out.AdmissionRequest = nil
}in the generated code on the authorization.k8s.io side. This is because conversion-gen doesn't "see" any ready-made conversion for AdmissionRequest between its internal and external versions. However, conversion-gen is in fact responsible for generating that conversion too, hence it doesn't exist up front.
This can be worked around by adding the following to pkg/apis/admission/v1/conversion.go:
// Convert_v1_AdmissionRequest_To_admission_AdmissionRequest just calls the covering autogenerated function, but is defined and thus
// "exported" in conversion.go, such that it is usable by other API groups that embed AdmissionRequest.
func Convert_v1_AdmissionRequest_To_admission_AdmissionRequest(in *admissionv1.AdmissionRequest, out *admission.AdmissionRequest, s conversion.Scope) error {
return autoConvert_v1_AdmissionRequest_To_admission_AdmissionRequest(in, out, s)
}
// Convert_admission_AdmissionRequest_To_v1_AdmissionRequest just calls the covering autogenerated function, but is defined and thus
// "exported" in conversion.go, such that it is usable by other API groups that embed AdmissionRequest.
func Convert_admission_AdmissionRequest_To_v1_AdmissionRequest(in *admission.AdmissionRequest, out *admissionv1.AdmissionRequest, s conversion.Scope) error {
return autoConvert_admission_AdmissionRequest_To_v1_AdmissionRequest(in, out, s)
}What did you expect to happen?
I want conversion-gen to understand what Convert_X_Z_To_Y_Z functions it will generate, and call those automatically when creating the conversions.
How can we reproduce it (as minimally and precisely as possible)?
Consider the type structure e.g. in #137633
Make a cross-API-package type reference in core Kubernetes, and try to generate a conversion.
Anything else we need to know?
No response
Kubernetes version
Details
Latest main
Cloud provider
Details
N/AOS version
Details
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here
# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
Activity
kubernetes-prow commentedon Sep 23, 2026
This issue is currently awaiting triage.
If a SIG or subproject determines this is a relevant issue, they will accept it by applying the
triage/acceptedlabel and provide further guidance.The
triage/acceptedlabel can be added by org members by writing/triage acceptedin a comment.Details
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
luxas commentedon Sep 23, 2026
/sig api-machinery
sarooshmehboob commentedon Sep 23, 2026
/assign
luxas commentedon Oct 9, 2026
Thanks for taking this on @sarooshmehboob! 🎉
When this is fixed, revert this part of #137633
sarooshmehboob commentedon Oct 21, 2026
/unassign
liggitt commentedon Oct 21, 2026
cc @jpbetz @yongruilin for visibility ... this is making conversion take expensive paths instead of cheap cast paths for things which are actually memory equivalent
yashaggarwal85d commentedon Oct 24, 2026
/assign