@@ -134,6 +134,18 @@ leaderElection:
134
134
t .Fatal (err )
135
135
}
136
136
137
+ v1alpha1Config := filepath .Join (tmpDir , "kubeconfig_v1alpha1.yaml" )
138
+ if err := ioutil .WriteFile (v1alpha1Config , []byte (fmt .Sprintf (`
139
+ apiVersion: kubescheduler.config.k8s.io/v1alpha1
140
+ kind: KubeSchedulerConfiguration
141
+ clientConnection:
142
+ kubeconfig: "%s"
143
+ leaderElection:
144
+ leaderElect: true
145
+ hardPodAffinitySymmetricWeight: 3` , configKubeconfig )), os .FileMode (0600 )); err != nil {
146
+ t .Fatal (err )
147
+ }
148
+
137
149
unknownFieldConfigLenient := filepath .Join (tmpDir , "scheduler_invalid_unknown_field_lenient.yaml" )
138
150
if err := ioutil .WriteFile (unknownFieldConfigLenient , []byte (fmt .Sprintf (`
139
151
apiVersion: kubescheduler.config.k8s.io/v1alpha1
@@ -307,11 +319,10 @@ plugins:
307
319
},
308
320
expectedUsername : "config" ,
309
321
expectedConfig : kubeschedulerconfig.KubeSchedulerConfiguration {
310
- SchedulerName : "default-scheduler" ,
311
- AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
312
- HardPodAffinitySymmetricWeight : 1 ,
313
- HealthzBindAddress : "0.0.0.0:10251" ,
314
- MetricsBindAddress : "0.0.0.0:10251" ,
322
+ SchedulerName : "default-scheduler" ,
323
+ AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
324
+ HealthzBindAddress : "0.0.0.0:10251" ,
325
+ MetricsBindAddress : "0.0.0.0:10251" ,
315
326
DebuggingConfiguration : componentbaseconfig.DebuggingConfiguration {
316
327
EnableProfiling : true ,
317
328
EnableContentionProfiling : true ,
@@ -399,11 +410,10 @@ plugins:
399
410
},
400
411
expectedUsername : "flag" ,
401
412
expectedConfig : kubeschedulerconfig.KubeSchedulerConfiguration {
402
- SchedulerName : "default-scheduler" ,
403
- AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
404
- HardPodAffinitySymmetricWeight : 1 ,
405
- HealthzBindAddress : "" , // defaults empty when not running from config file
406
- MetricsBindAddress : "" , // defaults empty when not running from config file
413
+ SchedulerName : "default-scheduler" ,
414
+ AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
415
+ HealthzBindAddress : "" , // defaults empty when not running from config file
416
+ MetricsBindAddress : "" , // defaults empty when not running from config file
407
417
DebuggingConfiguration : componentbaseconfig.DebuggingConfiguration {
408
418
EnableProfiling : true ,
409
419
EnableContentionProfiling : true ,
@@ -464,11 +474,10 @@ plugins:
464
474
},
465
475
},
466
476
expectedConfig : kubeschedulerconfig.KubeSchedulerConfiguration {
467
- SchedulerName : "default-scheduler" ,
468
- AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
469
- HardPodAffinitySymmetricWeight : 1 ,
470
- HealthzBindAddress : "" , // defaults empty when not running from config file
471
- MetricsBindAddress : "" , // defaults empty when not running from config file
477
+ SchedulerName : "default-scheduler" ,
478
+ AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
479
+ HealthzBindAddress : "" , // defaults empty when not running from config file
480
+ MetricsBindAddress : "" , // defaults empty when not running from config file
472
481
DebuggingConfiguration : componentbaseconfig.DebuggingConfiguration {
473
482
EnableProfiling : true ,
474
483
EnableContentionProfiling : true ,
@@ -504,11 +513,10 @@ plugins:
504
513
},
505
514
expectedUsername : "config" ,
506
515
expectedConfig : kubeschedulerconfig.KubeSchedulerConfiguration {
507
- SchedulerName : "default-scheduler" ,
508
- AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
509
- HardPodAffinitySymmetricWeight : 1 ,
510
- HealthzBindAddress : "0.0.0.0:10251" ,
511
- MetricsBindAddress : "0.0.0.0:10251" ,
516
+ SchedulerName : "default-scheduler" ,
517
+ AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
518
+ HealthzBindAddress : "0.0.0.0:10251" ,
519
+ MetricsBindAddress : "0.0.0.0:10251" ,
512
520
DebuggingConfiguration : componentbaseconfig.DebuggingConfiguration {
513
521
EnableProfiling : true ,
514
522
EnableContentionProfiling : true ,
@@ -578,11 +586,10 @@ plugins:
578
586
},
579
587
expectedUsername : "config" ,
580
588
expectedConfig : kubeschedulerconfig.KubeSchedulerConfiguration {
581
- SchedulerName : "default-scheduler" ,
582
- AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
583
- HardPodAffinitySymmetricWeight : 1 ,
584
- HealthzBindAddress : "0.0.0.0:10251" ,
585
- MetricsBindAddress : "0.0.0.0:10251" ,
589
+ SchedulerName : "default-scheduler" ,
590
+ AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
591
+ HealthzBindAddress : "0.0.0.0:10251" ,
592
+ MetricsBindAddress : "0.0.0.0:10251" ,
586
593
DebuggingConfiguration : componentbaseconfig.DebuggingConfiguration {
587
594
EnableProfiling : true ,
588
595
EnableContentionProfiling : true ,
@@ -632,21 +639,114 @@ plugins:
632
639
options : & Options {},
633
640
expectedError : "no configuration has been provided" ,
634
641
},
642
+ {
643
+ name : "Deprecated HardPodAffinitySymmetricWeight" ,
644
+ options : & Options {
645
+ ComponentConfig : func () kubeschedulerconfig.KubeSchedulerConfiguration {
646
+ cfg , _ := newDefaultComponentConfig ()
647
+ cfg .ClientConnection .Kubeconfig = flagKubeconfig
648
+ return * cfg
649
+ }(),
650
+ Deprecated : & DeprecatedOptions {
651
+ HardPodAffinitySymmetricWeight : 5 ,
652
+ },
653
+ },
654
+ expectedUsername : "flag" ,
655
+ expectedConfig : kubeschedulerconfig.KubeSchedulerConfiguration {
656
+ SchedulerName : "default-scheduler" ,
657
+ AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
658
+ DebuggingConfiguration : componentbaseconfig.DebuggingConfiguration {
659
+ EnableProfiling : true ,
660
+ EnableContentionProfiling : true ,
661
+ },
662
+ LeaderElection : kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration {
663
+ LeaderElectionConfiguration : componentbaseconfig.LeaderElectionConfiguration {
664
+ LeaderElect : true ,
665
+ LeaseDuration : metav1.Duration {Duration : 15 * time .Second },
666
+ RenewDeadline : metav1.Duration {Duration : 10 * time .Second },
667
+ RetryPeriod : metav1.Duration {Duration : 2 * time .Second },
668
+ ResourceLock : "endpointsleases" ,
669
+ ResourceNamespace : "kube-system" ,
670
+ ResourceName : "kube-scheduler" ,
671
+ },
672
+ },
673
+ ClientConnection : componentbaseconfig.ClientConnectionConfiguration {
674
+ Kubeconfig : flagKubeconfig ,
675
+ QPS : 50 ,
676
+ Burst : 100 ,
677
+ ContentType : "application/vnd.kubernetes.protobuf" ,
678
+ },
679
+ PercentageOfNodesToScore : defaultPercentageOfNodesToScore ,
680
+ BindTimeoutSeconds : defaultBindTimeoutSeconds ,
681
+ PodInitialBackoffSeconds : defaultPodInitialBackoffSeconds ,
682
+ PodMaxBackoffSeconds : defaultPodMaxBackoffSeconds ,
683
+ PluginConfig : []kubeschedulerconfig.PluginConfig {
684
+ {
685
+ Name : "InterPodAffinity" ,
686
+ Args : runtime.Unknown {
687
+ Raw : []byte (`{"hardPodAffinityWeight":5}` ),
688
+ },
689
+ },
690
+ },
691
+ },
692
+ },
693
+ {
694
+ name : "v1alpha1 config with HardPodAffinitySymmetricWeight" ,
695
+ options : & Options {
696
+ ConfigFile : v1alpha1Config ,
697
+ },
698
+ expectedUsername : "config" ,
699
+ expectedConfig : kubeschedulerconfig.KubeSchedulerConfiguration {
700
+ SchedulerName : "default-scheduler" ,
701
+ AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
702
+ HealthzBindAddress : "0.0.0.0:10251" ,
703
+ MetricsBindAddress : "0.0.0.0:10251" ,
704
+ DebuggingConfiguration : componentbaseconfig.DebuggingConfiguration {
705
+ EnableProfiling : true ,
706
+ EnableContentionProfiling : true ,
707
+ },
708
+ LeaderElection : kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration {
709
+ LeaderElectionConfiguration : componentbaseconfig.LeaderElectionConfiguration {
710
+ LeaderElect : true ,
711
+ LeaseDuration : metav1.Duration {Duration : 15 * time .Second },
712
+ RenewDeadline : metav1.Duration {Duration : 10 * time .Second },
713
+ RetryPeriod : metav1.Duration {Duration : 2 * time .Second },
714
+ ResourceLock : "endpointsleases" ,
715
+ ResourceNamespace : "kube-system" ,
716
+ ResourceName : "kube-scheduler" ,
717
+ },
718
+ },
719
+ ClientConnection : componentbaseconfig.ClientConnectionConfiguration {
720
+ Kubeconfig : configKubeconfig ,
721
+ QPS : 50 ,
722
+ Burst : 100 ,
723
+ ContentType : "application/vnd.kubernetes.protobuf" ,
724
+ },
725
+ PercentageOfNodesToScore : defaultPercentageOfNodesToScore ,
726
+ BindTimeoutSeconds : defaultBindTimeoutSeconds ,
727
+ PodInitialBackoffSeconds : defaultPodInitialBackoffSeconds ,
728
+ PodMaxBackoffSeconds : defaultPodMaxBackoffSeconds ,
729
+ PluginConfig : []kubeschedulerconfig.PluginConfig {
730
+ {
731
+ Name : "InterPodAffinity" ,
732
+ Args : runtime.Unknown {
733
+ Raw : []byte (`{"hardPodAffinityWeight":3}` ),
734
+ },
735
+ },
736
+ },
737
+ },
738
+ },
635
739
{
636
740
name : "unknown field lenient (v1alpha1)" ,
637
741
options : & Options {
638
742
ConfigFile : unknownFieldConfigLenient ,
639
743
},
640
- // TODO (obitech): Remove this comment and add a new test for v1alpha2, when it's available, as this should fail then.
641
- // expectedError: "found unknown field: foo",
642
- // checkErrFn: runtime.IsStrictDecodingError,
643
744
expectedUsername : "config" ,
644
745
expectedConfig : kubeschedulerconfig.KubeSchedulerConfiguration {
645
- SchedulerName : "default-scheduler" ,
646
- AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
647
- HardPodAffinitySymmetricWeight : 1 ,
648
- HealthzBindAddress : "0.0.0.0:10251" ,
649
- MetricsBindAddress : "0.0.0.0:10251" ,
746
+ SchedulerName : "default-scheduler" ,
747
+ AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
748
+ HealthzBindAddress : "0.0.0.0:10251" ,
749
+ MetricsBindAddress : "0.0.0.0:10251" ,
650
750
DebuggingConfiguration : componentbaseconfig.DebuggingConfiguration {
651
751
EnableProfiling : true ,
652
752
EnableContentionProfiling : true ,
@@ -688,16 +788,12 @@ plugins:
688
788
options : & Options {
689
789
ConfigFile : duplicateFieldConfigLenient ,
690
790
},
691
- // TODO (obitech): Remove this comment and add a new test for v1alpha2, when it's available, as this should fail then.
692
- // expectedError: `key "leaderElect" already set`,
693
- // checkErrFn: runtime.IsStrictDecodingError,
694
791
expectedUsername : "config" ,
695
792
expectedConfig : kubeschedulerconfig.KubeSchedulerConfiguration {
696
- SchedulerName : "default-scheduler" ,
697
- AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
698
- HardPodAffinitySymmetricWeight : 1 ,
699
- HealthzBindAddress : "0.0.0.0:10251" ,
700
- MetricsBindAddress : "0.0.0.0:10251" ,
793
+ SchedulerName : "default-scheduler" ,
794
+ AlgorithmSource : kubeschedulerconfig.SchedulerAlgorithmSource {Provider : & defaultSource },
795
+ HealthzBindAddress : "0.0.0.0:10251" ,
796
+ MetricsBindAddress : "0.0.0.0:10251" ,
701
797
DebuggingConfiguration : componentbaseconfig.DebuggingConfiguration {
702
798
EnableProfiling : true ,
703
799
EnableContentionProfiling : true ,
0 commit comments