Change:
/kind flake /sig testing /sig auth we are injecting a restMapper into this admisson controller while in its test, the restMapper somehow become empty when we remove internal clientset/informer dependency from it (). now we come up with a walkaround in which we manually init the legacy schema via a dry import so that the built-in resources can be installed. this failing test suggests that the test is not quite correct logically.
/assign Are you up for trying to figure out how to avoid requiring the internal types?
What test does this break? Links?
link here: w/o the dry import, then will fail with output:
sure. will be looking into it
OK, setting priority so that I know this isn't a 1.13 blocker. /priority important-longterm

Discussion:
srcs = ["gc_admission_test.go"], embed = [":go_default_library"], deps = [ <del> "//pkg/api/legacyscheme:go_default_library", </del> "//pkg/apis/core:go_default_library", <del> "//pkg/client/clientset_generated/internalclientset:go_default_library", </del> "//pkg/kubeapiserver/admission:go_default_library", <del> "//staging/src/k8s.io/apimachinery/pkg/api/meta/testrestmapper:go_default_library", </del> <ins> "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/extensions/v1beta1:go_default_library", </ins> "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",

"//staging/src/k8s.io/apiserver/pkg/admission/initializer:go_default_library", "//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library", "//staging/src/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library", <ins> "//staging/src/k8s.io/client-go/discovery/fake:go_default_library", "//staging/src/k8s.io/client-go/restmapper:go_default_library", "//staging/src/k8s.io/client-go/testing:go_default_library", </ins> ], )

package gc import ( <ins> "fmt" </ins> "strings" "testing" <del> "k8s.io/apimachinery/pkg/api/meta/testrestmapper" </del> <ins> corev1 "k8s.io/api/core/v1" extensionv1beta1 "k8s.io/api/extensions/v1beta1" </ins> metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema"

"k8s.io/apiserver/pkg/admission/initializer" "k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authorization/authorizer" <del> "k8s.io/kubernetes/pkg/api/legacyscheme" </del> <ins> fakediscovery "k8s.io/client-go/discovery/fake" "k8s.io/client-go/restmapper" coretesting "k8s.io/client-go/testing" </ins> api "k8s.io/kubernetes/pkg/apis/core" kubeadmission "k8s.io/kubernetes/pkg/kubeapiserver/admission" <del> // Manually initialize legacy scheme to make test rest mapper work with built-in resources. // See issue #70192 for more details _ "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" </del> ) type fakeAuthorizer struct{}

} genericPluginInitializer := initializer.New(nil, nil, fakeAuthorizer{}, nil) <del> pluginInitializer := kubeadmission.NewPluginInitializer(nil, testrestmapper.TestOnlyStaticRESTMapper(legacyscheme.Scheme), nil) </del> <ins> fakeDiscoveryClient := &fakediscovery.FakeDiscovery{Fake: &coretesting.Fake{}} fakeDiscoveryClient.Resources = []*metav1.APIResourceList{ { GroupVersion: corev1.SchemeGroupVersion.String(), APIResources: []metav1.APIResource{ {Name: "nodes", Namespaced: false, Kind: "Node"}, {Name: "pods", Namespaced: true, Kind: "Pod"}, {Name: "replicationcontrollers", Namespaced: true, Kind: "ReplicationController"}, }, }, { GroupVersion: extensionv1beta1.SchemeGroupVersion.String(), APIResources: []metav1.APIResource{ {Name: "daemonsets", Namespaced: true, Kind: "DaemonSet"}, }, }, } restMapperRes, err := restmapper.GetAPIGroupResources(fakeDiscoveryClient) if err != nil { return nil, fmt.Errorf("unexpected error while constructing resource list from fake discovery client: %v", err) } restMapper := restmapper.NewDiscoveryRESTMapper(restMapperRes) pluginInitializer := kubeadmission.NewPluginInitializer(nil, restMapper, nil) </ins> initializersChain := admission.PluginInitializers{} initializersChain = append(initializersChain, genericPluginInitializer) initializersChain = append(initializersChain, pluginInitializer)