Skip to content

Commit 41d2340

Browse files
Avesh Agarwaldeads2k
Avesh Agarwal
authored andcommitted
UPSTREAM: 53793: User separate client for leader election in scheduler 1.7 PR is kubernetes#53884
:100644 100644 d43ba8aeef... 46b5efe30f... M plugin/cmd/kube-scheduler/app/configurator.go :100644 100644 e987c656df... 74a1458649... M plugin/cmd/kube-scheduler/app/server.go
1 parent 08d02e5 commit 41d2340

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Diff for: plugin/cmd/kube-scheduler/app/configurator.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,22 @@ func createRecorder(kubecli *clientset.Clientset, s *options.SchedulerServer) re
5454
return eventBroadcaster.NewRecorder(api.Scheme, clientv1.EventSource{Component: s.SchedulerName})
5555
}
5656

57-
func createClient(s *options.SchedulerServer) (*clientset.Clientset, error) {
57+
func createClients(s *options.SchedulerServer) (*clientset.Clientset, *clientset.Clientset, error) {
5858
kubeconfig, err := clientcmd.BuildConfigFromFlags(s.Master, s.Kubeconfig)
5959
if err != nil {
60-
return nil, fmt.Errorf("unable to build config from flags: %v", err)
60+
return nil, nil, fmt.Errorf("unable to build config from flags: %v", err)
6161
}
6262

6363
kubeconfig.ContentType = s.ContentType
6464
// Override kubeconfig qps/burst settings from flags
6565
kubeconfig.QPS = s.KubeAPIQPS
6666
kubeconfig.Burst = int(s.KubeAPIBurst)
67-
68-
cli, err := clientset.NewForConfig(restclient.AddUserAgent(kubeconfig, "leader-election"))
67+
kubeClient, err := clientset.NewForConfig(restclient.AddUserAgent(kubeconfig, "scheduler"))
6968
if err != nil {
70-
return nil, fmt.Errorf("invalid API configuration: %v", err)
69+
glog.Fatalf("Invalid API configuration: %v", err)
7170
}
72-
return cli, nil
71+
leaderElectionClient := clientset.NewForConfigOrDie(restclient.AddUserAgent(kubeconfig, "leader-election"))
72+
return kubeClient, leaderElectionClient, nil
7373
}
7474

7575
// CreateScheduler encapsulates the entire creation of a runnable scheduler.

Diff for: plugin/cmd/kube-scheduler/app/server.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,20 @@ through the API as necessary.`,
6666

6767
// Run runs the specified SchedulerServer. This should never exit.
6868
func Run(s *options.SchedulerServer) error {
69-
kubecli, err := createClient(s)
69+
kubeClient, leaderElectionClient, err := createClients(s)
7070
if err != nil {
7171
return fmt.Errorf("unable to create kube client: %v", err)
7272
}
7373

74-
recorder := createRecorder(kubecli, s)
74+
recorder := createRecorder(kubeClient, s)
7575

76-
informerFactory := informers.NewSharedInformerFactory(kubecli, 0)
76+
informerFactory := informers.NewSharedInformerFactory(kubeClient, 0)
7777
// cache only non-terminal pods
78-
podInformer := factory.NewPodInformer(kubecli, 0)
78+
podInformer := factory.NewPodInformer(kubeClient, 0)
7979

8080
sched, err := CreateScheduler(
8181
s,
82-
kubecli,
82+
kubeClient,
8383
informerFactory.Core().V1().Nodes(),
8484
podInformer,
8585
informerFactory.Core().V1().PersistentVolumes(),
@@ -124,7 +124,7 @@ func Run(s *options.SchedulerServer) error {
124124
rl, err := resourcelock.New(s.LeaderElection.ResourceLock,
125125
s.LockObjectNamespace,
126126
s.LockObjectName,
127-
kubecli.Core(),
127+
leaderElectionClient.Core(),
128128
resourcelock.ResourceLockConfig{
129129
Identity: id,
130130
EventRecorder: recorder,

0 commit comments

Comments
 (0)