mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Use feature gate in integration
Clean up unused import
This commit is contained in:
parent
20f7f37c49
commit
782a092e2e
@ -41,7 +41,6 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/scheduler"
|
"k8s.io/kubernetes/pkg/scheduler"
|
||||||
_ "k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
|
_ "k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
|
||||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/factory"
|
|
||||||
e2e "k8s.io/kubernetes/test/e2e/framework"
|
e2e "k8s.io/kubernetes/test/e2e/framework"
|
||||||
"k8s.io/kubernetes/test/integration/framework"
|
"k8s.io/kubernetes/test/integration/framework"
|
||||||
)
|
)
|
||||||
@ -364,22 +363,7 @@ func TestSchedulerExtender(t *testing.T) {
|
|||||||
policy.APIVersion = testapi.Groups[v1.GroupName].GroupVersion().String()
|
policy.APIVersion = testapi.Groups[v1.GroupName].GroupVersion().String()
|
||||||
|
|
||||||
informerFactory := informers.NewSharedInformerFactory(clientSet, 0)
|
informerFactory := informers.NewSharedInformerFactory(clientSet, 0)
|
||||||
schedulerConfigFactory := factory.NewConfigFactory(
|
schedulerConfigFactory := CreateConfigurator(clientSet, informerFactory)
|
||||||
v1.DefaultSchedulerName,
|
|
||||||
clientSet,
|
|
||||||
informerFactory.Core().V1().Nodes(),
|
|
||||||
informerFactory.Core().V1().Pods(),
|
|
||||||
informerFactory.Core().V1().PersistentVolumes(),
|
|
||||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
|
||||||
informerFactory.Core().V1().ReplicationControllers(),
|
|
||||||
informerFactory.Extensions().V1beta1().ReplicaSets(),
|
|
||||||
informerFactory.Apps().V1beta1().StatefulSets(),
|
|
||||||
informerFactory.Core().V1().Services(),
|
|
||||||
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
|
||||||
informerFactory.Storage().V1().StorageClasses(),
|
|
||||||
v1.DefaultHardPodAffinitySymmetricWeight,
|
|
||||||
enableEquivalenceCache,
|
|
||||||
)
|
|
||||||
schedulerConfig, err := schedulerConfigFactory.CreateFromConfig(policy)
|
schedulerConfig, err := schedulerConfigFactory.CreateFromConfig(policy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Couldn't create scheduler config: %v", err)
|
t.Fatalf("Couldn't create scheduler config: %v", err)
|
||||||
|
@ -517,22 +517,7 @@ func TestMultiScheduler(t *testing.T) {
|
|||||||
informerFactory2 := informers.NewSharedInformerFactory(context.clientSet, 0)
|
informerFactory2 := informers.NewSharedInformerFactory(context.clientSet, 0)
|
||||||
podInformer2 := factory.NewPodInformer(context.clientSet, 0, fooScheduler)
|
podInformer2 := factory.NewPodInformer(context.clientSet, 0, fooScheduler)
|
||||||
|
|
||||||
schedulerConfigFactory2 := factory.NewConfigFactory(
|
schedulerConfigFactory2 := CreateConfiguratorWithPodInformer(fooScheduler, clientSet2, podInformer2, informerFactory2)
|
||||||
fooScheduler,
|
|
||||||
clientSet2,
|
|
||||||
informerFactory2.Core().V1().Nodes(),
|
|
||||||
podInformer2,
|
|
||||||
informerFactory2.Core().V1().PersistentVolumes(),
|
|
||||||
informerFactory2.Core().V1().PersistentVolumeClaims(),
|
|
||||||
informerFactory2.Core().V1().ReplicationControllers(),
|
|
||||||
informerFactory2.Extensions().V1beta1().ReplicaSets(),
|
|
||||||
informerFactory2.Apps().V1beta1().StatefulSets(),
|
|
||||||
informerFactory2.Core().V1().Services(),
|
|
||||||
informerFactory2.Policy().V1beta1().PodDisruptionBudgets(),
|
|
||||||
informerFactory2.Storage().V1().StorageClasses(),
|
|
||||||
v1.DefaultHardPodAffinitySymmetricWeight,
|
|
||||||
enableEquivalenceCache,
|
|
||||||
)
|
|
||||||
schedulerConfig2, err := schedulerConfigFactory2.Create()
|
schedulerConfig2, err := schedulerConfigFactory2.Create()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Couldn't create scheduler config: %v", err)
|
t.Errorf("Couldn't create scheduler config: %v", err)
|
||||||
|
@ -42,7 +42,6 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/scheduler"
|
"k8s.io/kubernetes/pkg/scheduler"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
|
"k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/factory"
|
|
||||||
"k8s.io/kubernetes/plugin/pkg/admission/podtolerationrestriction"
|
"k8s.io/kubernetes/plugin/pkg/admission/podtolerationrestriction"
|
||||||
pluginapi "k8s.io/kubernetes/plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction"
|
pluginapi "k8s.io/kubernetes/plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction"
|
||||||
"k8s.io/kubernetes/test/integration/framework"
|
"k8s.io/kubernetes/test/integration/framework"
|
||||||
@ -113,22 +112,7 @@ func TestTaintNodeByCondition(t *testing.T) {
|
|||||||
algorithmprovider.ApplyFeatureGates()
|
algorithmprovider.ApplyFeatureGates()
|
||||||
|
|
||||||
// Start scheduler
|
// Start scheduler
|
||||||
configurator := factory.NewConfigFactory(
|
configurator := CreateConfigurator(clientset, informers)
|
||||||
v1.DefaultSchedulerName,
|
|
||||||
clientset,
|
|
||||||
informers.Core().V1().Nodes(),
|
|
||||||
informers.Core().V1().Pods(),
|
|
||||||
informers.Core().V1().PersistentVolumes(),
|
|
||||||
informers.Core().V1().PersistentVolumeClaims(),
|
|
||||||
informers.Core().V1().ReplicationControllers(),
|
|
||||||
informers.Extensions().V1beta1().ReplicaSets(),
|
|
||||||
informers.Apps().V1beta1().StatefulSets(),
|
|
||||||
informers.Core().V1().Services(),
|
|
||||||
informers.Policy().V1beta1().PodDisruptionBudgets(),
|
|
||||||
informers.Storage().V1().StorageClasses(),
|
|
||||||
v1.DefaultHardPodAffinitySymmetricWeight,
|
|
||||||
true, // Enable EqualCache by default.
|
|
||||||
)
|
|
||||||
|
|
||||||
sched, err := scheduler.NewFromConfigurator(configurator, func(cfg *scheduler.Config) {
|
sched, err := scheduler.NewFromConfigurator(configurator, func(cfg *scheduler.Config) {
|
||||||
cfg.StopEverything = controllerCh
|
cfg.StopEverything = controllerCh
|
||||||
|
@ -27,7 +27,9 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
|
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
clientv1core "k8s.io/client-go/kubernetes/typed/core/v1"
|
clientv1core "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||||
corelisters "k8s.io/client-go/listers/core/v1"
|
corelisters "k8s.io/client-go/listers/core/v1"
|
||||||
@ -35,6 +37,7 @@ import (
|
|||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
||||||
|
"k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/scheduler"
|
"k8s.io/kubernetes/pkg/scheduler"
|
||||||
_ "k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
|
_ "k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/factory"
|
"k8s.io/kubernetes/pkg/scheduler/factory"
|
||||||
@ -54,6 +57,60 @@ type TestContext struct {
|
|||||||
scheduler *scheduler.Scheduler
|
scheduler *scheduler.Scheduler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// createConfigurator create a configurator for scheduler with given informer factory and default name.
|
||||||
|
func CreateConfigurator(
|
||||||
|
clientSet clientset.Interface,
|
||||||
|
informerFactory informers.SharedInformerFactory,
|
||||||
|
) scheduler.Configurator {
|
||||||
|
// Enable EnableEquivalenceClassCache for all integration tests.
|
||||||
|
utilfeature.DefaultFeatureGate.Set("EnableEquivalenceClassCache=true")
|
||||||
|
|
||||||
|
return factory.NewConfigFactory(
|
||||||
|
v1.DefaultSchedulerName,
|
||||||
|
clientSet,
|
||||||
|
informerFactory.Core().V1().Nodes(),
|
||||||
|
informerFactory.Core().V1().Pods(),
|
||||||
|
informerFactory.Core().V1().PersistentVolumes(),
|
||||||
|
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||||
|
informerFactory.Core().V1().ReplicationControllers(),
|
||||||
|
informerFactory.Extensions().V1beta1().ReplicaSets(),
|
||||||
|
informerFactory.Apps().V1beta1().StatefulSets(),
|
||||||
|
informerFactory.Core().V1().Services(),
|
||||||
|
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||||
|
informerFactory.Storage().V1().StorageClasses(),
|
||||||
|
v1.DefaultHardPodAffinitySymmetricWeight,
|
||||||
|
utilfeature.DefaultFeatureGate.Enabled(features.EnableEquivalenceClassCache),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateConfiguratorWithPodInformer create a configurator for scheduler with given informer factory, custom name and pod informer.
|
||||||
|
func CreateConfiguratorWithPodInformer(
|
||||||
|
schedulerName string,
|
||||||
|
clientSet clientset.Interface,
|
||||||
|
podInformer coreinformers.PodInformer,
|
||||||
|
informerFactory informers.SharedInformerFactory,
|
||||||
|
) scheduler.Configurator {
|
||||||
|
// Enable EnableEquivalenceClassCache for all integration tests.
|
||||||
|
utilfeature.DefaultFeatureGate.Set("EnableEquivalenceClassCache=true")
|
||||||
|
|
||||||
|
return factory.NewConfigFactory(
|
||||||
|
schedulerName,
|
||||||
|
clientSet,
|
||||||
|
informerFactory.Core().V1().Nodes(),
|
||||||
|
podInformer,
|
||||||
|
informerFactory.Core().V1().PersistentVolumes(),
|
||||||
|
informerFactory.Core().V1().PersistentVolumeClaims(),
|
||||||
|
informerFactory.Core().V1().ReplicationControllers(),
|
||||||
|
informerFactory.Extensions().V1beta1().ReplicaSets(),
|
||||||
|
informerFactory.Apps().V1beta1().StatefulSets(),
|
||||||
|
informerFactory.Core().V1().Services(),
|
||||||
|
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
||||||
|
informerFactory.Storage().V1().StorageClasses(),
|
||||||
|
v1.DefaultHardPodAffinitySymmetricWeight,
|
||||||
|
utilfeature.DefaultFeatureGate.Enabled(features.EnableEquivalenceClassCache),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// initTest initializes a test environment and creates a scheduler with default
|
// initTest initializes a test environment and creates a scheduler with default
|
||||||
// configuration.
|
// configuration.
|
||||||
func initTest(t *testing.T, nsPrefix string) *TestContext {
|
func initTest(t *testing.T, nsPrefix string) *TestContext {
|
||||||
@ -66,22 +123,7 @@ func initTest(t *testing.T, nsPrefix string) *TestContext {
|
|||||||
context.clientSet = clientset.NewForConfigOrDie(&restclient.Config{Host: context.httpServer.URL})
|
context.clientSet = clientset.NewForConfigOrDie(&restclient.Config{Host: context.httpServer.URL})
|
||||||
context.informerFactory = informers.NewSharedInformerFactory(context.clientSet, 0)
|
context.informerFactory = informers.NewSharedInformerFactory(context.clientSet, 0)
|
||||||
podInformer := factory.NewPodInformer(context.clientSet, 12*time.Hour, v1.DefaultSchedulerName)
|
podInformer := factory.NewPodInformer(context.clientSet, 12*time.Hour, v1.DefaultSchedulerName)
|
||||||
context.schedulerConfigFactory = factory.NewConfigFactory(
|
context.schedulerConfigFactory = CreateConfiguratorWithPodInformer(v1.DefaultSchedulerName, context.clientSet, podInformer, context.informerFactory)
|
||||||
v1.DefaultSchedulerName,
|
|
||||||
context.clientSet,
|
|
||||||
context.informerFactory.Core().V1().Nodes(),
|
|
||||||
podInformer,
|
|
||||||
context.informerFactory.Core().V1().PersistentVolumes(),
|
|
||||||
context.informerFactory.Core().V1().PersistentVolumeClaims(),
|
|
||||||
context.informerFactory.Core().V1().ReplicationControllers(),
|
|
||||||
context.informerFactory.Extensions().V1beta1().ReplicaSets(),
|
|
||||||
context.informerFactory.Apps().V1beta1().StatefulSets(),
|
|
||||||
context.informerFactory.Core().V1().Services(),
|
|
||||||
context.informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
|
||||||
context.informerFactory.Storage().V1().StorageClasses(),
|
|
||||||
v1.DefaultHardPodAffinitySymmetricWeight,
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
var err error
|
var err error
|
||||||
context.schedulerConfig, err = context.schedulerConfigFactory.Create()
|
context.schedulerConfig, err = context.schedulerConfigFactory.Create()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -28,8 +28,8 @@ import (
|
|||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/scheduler"
|
"k8s.io/kubernetes/pkg/scheduler"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/factory"
|
|
||||||
"k8s.io/kubernetes/test/integration/framework"
|
"k8s.io/kubernetes/test/integration/framework"
|
||||||
|
utilscheduler "k8s.io/kubernetes/test/integration/scheduler"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ShutdownFunc represents the function handle to be called, typically in a defer handler, to shutdown a running module
|
// ShutdownFunc represents the function handle to be called, typically in a defer handler, to shutdown a running module
|
||||||
@ -63,22 +63,7 @@ func StartScheduler(clientSet clientset.Interface, enableEquivalenceCache bool)
|
|||||||
evtWatch := evtBroadcaster.StartRecordingToSink(&clientv1core.EventSinkImpl{
|
evtWatch := evtBroadcaster.StartRecordingToSink(&clientv1core.EventSinkImpl{
|
||||||
Interface: clientv1core.New(clientSet.CoreV1().RESTClient()).Events("")})
|
Interface: clientv1core.New(clientSet.CoreV1().RESTClient()).Events("")})
|
||||||
|
|
||||||
schedulerConfigurator := factory.NewConfigFactory(
|
schedulerConfigurator := utilscheduler.CreateConfigurator(clientSet, informerFactory)
|
||||||
v1.DefaultSchedulerName,
|
|
||||||
clientSet,
|
|
||||||
informerFactory.Core().V1().Nodes(),
|
|
||||||
informerFactory.Core().V1().Pods(),
|
|
||||||
informerFactory.Core().V1().PersistentVolumes(),
|
|
||||||
informerFactory.Core().V1().PersistentVolumeClaims(),
|
|
||||||
informerFactory.Core().V1().ReplicationControllers(),
|
|
||||||
informerFactory.Extensions().V1beta1().ReplicaSets(),
|
|
||||||
informerFactory.Apps().V1beta1().StatefulSets(),
|
|
||||||
informerFactory.Core().V1().Services(),
|
|
||||||
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
|
|
||||||
informerFactory.Storage().V1().StorageClasses(),
|
|
||||||
v1.DefaultHardPodAffinitySymmetricWeight,
|
|
||||||
enableEquivalenceCache,
|
|
||||||
)
|
|
||||||
|
|
||||||
sched, err := scheduler.NewFromConfigurator(schedulerConfigurator, func(conf *scheduler.Config) {
|
sched, err := scheduler.NewFromConfigurator(schedulerConfigurator, func(conf *scheduler.Config) {
|
||||||
conf.Recorder = evtBroadcaster.NewRecorder(legacyscheme.Scheme, v1.EventSource{Component: "scheduler"})
|
conf.Recorder = evtBroadcaster.NewRecorder(legacyscheme.Scheme, v1.EventSource{Component: "scheduler"})
|
||||||
|
Loading…
Reference in New Issue
Block a user