mirror of https://github.com/k3s-io/k3s
d2cc34fb07
Automatic merge from submit-queue (batch tested with PRs 65771, 65849). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add a new conversion path to replace GenericConversionFunc reflect.Call is very expensive. We currently use a switch block as part of AddGenericConversionFunc to avoid the bulk of top level a->b conversion for our primary types which is hand-written. Instead of having these be handwritten, we should generate them. The pattern for generating them looks like: ``` scheme.AddConversionFunc(&v1.Type{}, &internal.Type{}, func(a, b interface{}, scope conversion.Scope) error { return Convert_v1_Type_to_internal_Type(a.(*v1.Type), b.(*internal.Type), scope) }) ``` which matches AddDefaultObjectFunc (which proved out the approach last year). The conversion machinery should then do a simple map lookup based on the incoming types and invoke the function. Like defaulting, it's up to the caller to match the types to arguments, which we do by generating this code. This bypasses reflect.Call and in the future allows Golang mid-stack inlining to optimize this code. As part of this change I strengthened registration of custom functions to be generated instead of hand registered, and also strengthened error checking of the generator when it sees a manual conversion to error out. Since custom functions are automatically used by the generator, we don't really have a case for not registering the functions. Once this is fully tested out, we can remove the reflection based path and the old registration methods, and all conversion will work from point to point methods (whether generated or custom). Much of the need for the reflection path has been removed by changes to generation (to omit fields) and changes to Go (to make assigning equivalent structs easy). ```release-note NONE ``` |
||
---|---|---|
.. | ||
clicheck | ||
cloud-controller-manager | ||
controller-manager | ||
gendocs | ||
genkubedocs | ||
genman | ||
genswaggertypedocs | ||
genutils | ||
genyaml | ||
hyperkube | ||
importverifier | ||
kube-apiserver | ||
kube-controller-manager | ||
kube-proxy | ||
kube-scheduler | ||
kubeadm | ||
kubectl | ||
kubelet | ||
kubemark | ||
linkcheck | ||
BUILD | ||
OWNERS |