Change:
In the codegenerator we have: So basically we process only packages that are explicitly requested by the user and ignore ones that are imported. So in order to have the conversion func imported by the generator, the package where it lives has to be explicitly imported. So we should basically always pass all input packages to conversion generator. This is problematic, when regenerating conversions, we simply pass to input directories only those that were changed in the meantime: We should fix that - probably by passing all CONVERSIONDIRS as inputs to conversion-gen /kind-bug
I think this caused Not sure if was related yet.
It's the other way around - this is the main bug and root cause and the other that you linked is a consequence.
Also - FYI
I actually already started looking into it - so let me assign this.
is out for review
/triage accepted

Discussion:
| xargs -n1 dirname                                           | LC_ALL=C sort -u                                            ) DEFAULTER_FILES := $(addsuffix /$(DEFAULTER_FILENAME), $(DEFAULTER_DIRS)) <ins> DEFAULTER_EXTRA_PEER_PKGS :=  $(addprefix $(PRJ_SRC_PATH)/, $(DEFAULTER_DIRS)) </ins> # Reset the list of packages that need generation. $(shell mkdir -p $$(dirname $(META_DIR)/$(DEFAULTER_GEN)))

--v $(KUBE_VERBOSE)                                          --logtostderr                                                -i "$$pkgs"                                                  <del> --extra-peer-dirs $$(echo $(addprefix $(PRJ_SRC_PATH)/, $(DEFAULTER_DIRS)) | sed 's/ /,/g')  </del> <ins> --extra-peer-dirs $$(echo $(DEFAULTER_EXTRA_PEER_PKGS) | sed 's/ /,/g')  </ins> -O $(DEFAULTER_BASENAME)                                     "$$@";                                                       fi

$(META_DIR)/$(DEFAULTER_GEN).todo: $(DEFAULTER_FILES) $(DEFAULTER_FILES): $(DEFAULTER_GEN) <del> if [[ "$(DBG_CODEGEN)" == 1 ]]; then          </del> <ins> if [[ "$(DBG_CODEGEN)" == 1 ]]; then       </ins> echo "DBG: defaulter needed $(@D):";   <del> ls -lf --full-time $@ $? || true;         </del> <ins> ls -lf --full-time $@ $? || true;      </ins> fi echo $(PRJ_SRC_PATH)/$(@D) >> $(META_DIR)/$(DEFAULTER_GEN).todo

| xargs -n1 dirname                                              | LC_ALL=C sort -u                                               ) CONVERSION_FILES := $(addsuffix /$(CONVERSION_FILENAME), $(CONVERSION_DIRS)) <del> CONVERSION_EXTRA_PEER_DIRS := k8s.io/kubernetes/pkg/apis/core,k8s.io/kubernetes/pkg/apis/core/v1,k8s.io/api/core/v1 </del> <ins> CONVERSION_EXTRA_PEER_PKGS :=  k8s.io/kubernetes/pkg/apis/core  k8s.io/kubernetes/pkg/apis/core/v1  k8s.io/api/core/v1 CONVERSION_EXTRA_PKGS := $(addprefix $(PRJ_SRC_PATH)/, $(CONVERSION_DIRS)) </ins> # Reset the list of packages that need generation. $(shell mkdir -p $$(dirname $(META_DIR)/$(CONVERSION_GEN)))

echo "DBG: running $(CONVERSION_GEN) for $$pkgs";             fi;                                                               ./hack/run-in-gopath.sh $(CONVERSION_GEN)                         <del> --extra-peer-dirs $(CONVERSION_EXTRA_PEER_DIRS)               </del> <ins> --extra-peer-dirs $$(echo $(CONVERSION_EXTRA_PEER_PKGS) | sed 's/ /,/g')  --extra-dirs $$(echo $(CONVERSION_EXTRA_PKGS) | sed 's/ /,/g')  </ins> --v $(KUBE_VERBOSE)                                           --logtostderr                                                 -i "$$pkgs"                                                  

kube::util::ensure_clean_working_dir _tmpdir="$(kube::realpath "$(mktemp -d -t verify-generated-files.XXXXXX)")" <del> kube::util::trap_add "rm -rf ${_tmpdir}" EXIT </del> _tmp_gopath="${_tmpdir}/go" _tmp_kuberoot="${_tmp_gopath}/src/k8s.io/kubernetes" mkdir -p "${_tmp_kuberoot}/.." <del> cp -a "${KUBE_ROOT}" "${_tmp_kuberoot}/.." </del> <ins> git worktree add "${_tmp_kuberoot}" kube::util::trap_add "git worktree remove -f ${_tmp_kuberoot} && rm -rf ${_tmpdir}" EXIT </ins> cd "${_tmp_kuberoot}" # clean out anything from the temp dir that's not checked in

// generator pick up manually written conversion funcs from external packages. ExtraPeerDirs []string <ins> // Additional dirs to parse and load, but not consider for peers.  This is // useful when packages depend on other packages and want to call // conversions across them. ExtraDirs []string </ins> // SkipUnsafe indicates whether to generate unsafe conversions to improve the efficiency // of these operations. The unsafe operation is a direct pointer assignment via unsafe // (within the allowed uses of unsafe) and is equivalent to a proposed Golang change to

"Comma-separated list of apimachinery import paths which are considered, after tag-specified peers, for conversions. Only change these if you have very good reasons.") pflag.CommandLine.StringSliceVar(&ca.ExtraPeerDirs, "extra-peer-dirs", ca.ExtraPeerDirs, "Application specific comma-separated list of import paths which are considered, after tag-specified peers and base-peer-dirs, for conversions.") <ins> pflag.CommandLine.StringSliceVar(&ca.ExtraDirs, "extra-dirs", ca.ExtraDirs, "Application specific comma-separated list of import paths which are loaded and considered for callable conversions, but are not considered peers for conversion.") </ins> pflag.CommandLine.BoolVar(&ca.SkipUnsafe, "skip-unsafe", ca.SkipUnsafe, "If true, will not generate code using unsafe pointer conversions; resulting code may be slower.") }

continue } skipUnsafe := false <ins> extraDirs := []string{} </ins> if customArgs, ok := arguments.CustomArgs.(*conversionargs.CustomArgs); ok { if len(peerPkgs) > 0 { peerPkgs = append(peerPkgs, customArgs.BasePeerDirs...) peerPkgs = append(peerPkgs, customArgs.ExtraPeerDirs...) } <ins> extraDirs = customArgs.ExtraDirs </ins> skipUnsafe = customArgs.SkipUnsafe }

for i := range peerPkgs { peerPkgs[i] = genutil.Vendorless(peerPkgs[i]) } <ins> for i := range extraDirs { extraDirs[i] = genutil.Vendorless(extraDirs[i]) } </ins> // Make sure our peer-packages are added and fully parsed. <del> for _, pp := range peerPkgs { </del> <ins> for _, pp := range append(peerPkgs, extraDirs...) { </ins> context.AddDir(pp) p := context.Universe[pp] if nil == p {