Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0ba66130
Commit
0ba66130
authored
Nov 08, 2018
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kube-scheduler: split out cmd Run func
parent
98d8e871
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
26 deletions
+31
-26
server.go
cmd/kube-scheduler/app/server.go
+31
-26
No files found.
cmd/kube-scheduler/app/server.go
View file @
0ba66130
...
@@ -81,7 +81,7 @@ constraints, affinity and anti-affinity specifications, data locality, inter-wor
...
@@ -81,7 +81,7 @@ constraints, affinity and anti-affinity specifications, data locality, inter-wor
interference, deadlines, and so on. Workload-specific requirements will be exposed
interference, deadlines, and so on. Workload-specific requirements will be exposed
through the API as necessary.`
,
through the API as necessary.`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
err
:=
run
(
cmd
,
args
,
opts
);
err
!=
nil
{
if
err
:=
run
Command
(
cmd
,
args
,
opts
);
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%v
\n
"
,
err
)
fmt
.
Fprintf
(
os
.
Stderr
,
"%v
\n
"
,
err
)
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
...
@@ -94,8 +94,8 @@ through the API as necessary.`,
...
@@ -94,8 +94,8 @@ through the API as necessary.`,
return
cmd
return
cmd
}
}
// run runs the scheduler.
// run
Command
runs the scheduler.
func
run
(
cmd
*
cobra
.
Command
,
args
[]
string
,
opts
*
options
.
Options
)
error
{
func
run
Command
(
cmd
*
cobra
.
Command
,
args
[]
string
,
opts
*
options
.
Options
)
error
{
verflag
.
PrintAndExitIfRequested
()
verflag
.
PrintAndExitIfRequested
()
utilflag
.
PrintFlags
(
cmd
.
Flags
())
utilflag
.
PrintFlags
(
cmd
.
Flags
())
...
@@ -136,37 +136,42 @@ func run(cmd *cobra.Command, args []string, opts *options.Options) error {
...
@@ -136,37 +136,42 @@ func run(cmd *cobra.Command, args []string, opts *options.Options) error {
// Configz registration.
// Configz registration.
if
cz
,
err
:=
configz
.
New
(
"componentconfig"
);
err
==
nil
{
if
cz
,
err
:=
configz
.
New
(
"componentconfig"
);
err
==
nil
{
cz
.
Set
(
c
.
ComponentConfig
)
cz
.
Set
(
c
c
.
ComponentConfig
)
}
else
{
}
else
{
return
fmt
.
Errorf
(
"unable to register configz: %s"
,
err
)
return
fmt
.
Errorf
(
"unable to register configz: %s"
,
err
)
}
}
return
Run
(
cc
,
stopCh
)
}
// Run executes the scheduler based on the given configuration. It only return on error or when stopCh is closed.
func
Run
(
cc
schedulerserverconfig
.
CompletedConfig
,
stopCh
<-
chan
struct
{})
error
{
var
storageClassInformer
storageinformers
.
StorageClassInformer
var
storageClassInformer
storageinformers
.
StorageClassInformer
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
storageClassInformer
=
c
.
InformerFactory
.
Storage
()
.
V1
()
.
StorageClasses
()
storageClassInformer
=
c
c
.
InformerFactory
.
Storage
()
.
V1
()
.
StorageClasses
()
}
}
// Create the scheduler.
// Create the scheduler.
sched
,
err
:=
scheduler
.
New
(
c
.
Client
,
sched
,
err
:=
scheduler
.
New
(
c
c
.
Client
,
c
.
InformerFactory
.
Core
()
.
V1
()
.
Nodes
(),
c
c
.
InformerFactory
.
Core
()
.
V1
()
.
Nodes
(),
c
.
PodInformer
,
c
c
.
PodInformer
,
c
.
InformerFactory
.
Core
()
.
V1
()
.
PersistentVolumes
(),
c
c
.
InformerFactory
.
Core
()
.
V1
()
.
PersistentVolumes
(),
c
.
InformerFactory
.
Core
()
.
V1
()
.
PersistentVolumeClaims
(),
c
c
.
InformerFactory
.
Core
()
.
V1
()
.
PersistentVolumeClaims
(),
c
.
InformerFactory
.
Core
()
.
V1
()
.
ReplicationControllers
(),
c
c
.
InformerFactory
.
Core
()
.
V1
()
.
ReplicationControllers
(),
c
.
InformerFactory
.
Apps
()
.
V1
()
.
ReplicaSets
(),
c
c
.
InformerFactory
.
Apps
()
.
V1
()
.
ReplicaSets
(),
c
.
InformerFactory
.
Apps
()
.
V1
()
.
StatefulSets
(),
c
c
.
InformerFactory
.
Apps
()
.
V1
()
.
StatefulSets
(),
c
.
InformerFactory
.
Core
()
.
V1
()
.
Services
(),
c
c
.
InformerFactory
.
Core
()
.
V1
()
.
Services
(),
c
.
InformerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
(),
c
c
.
InformerFactory
.
Policy
()
.
V1beta1
()
.
PodDisruptionBudgets
(),
storageClassInformer
,
storageClassInformer
,
c
.
Recorder
,
c
c
.
Recorder
,
c
.
ComponentConfig
.
AlgorithmSource
,
c
c
.
ComponentConfig
.
AlgorithmSource
,
stopCh
,
stopCh
,
scheduler
.
WithName
(
c
.
ComponentConfig
.
SchedulerName
),
scheduler
.
WithName
(
c
c
.
ComponentConfig
.
SchedulerName
),
scheduler
.
WithHardPodAffinitySymmetricWeight
(
c
.
ComponentConfig
.
HardPodAffinitySymmetricWeight
),
scheduler
.
WithHardPodAffinitySymmetricWeight
(
c
c
.
ComponentConfig
.
HardPodAffinitySymmetricWeight
),
scheduler
.
WithEquivalenceClassCacheEnabled
(
c
.
ComponentConfig
.
EnableContentionProfiling
),
scheduler
.
WithEquivalenceClassCacheEnabled
(
c
c
.
ComponentConfig
.
EnableContentionProfiling
),
scheduler
.
WithPreemptionDisabled
(
c
.
ComponentConfig
.
DisablePreemption
),
scheduler
.
WithPreemptionDisabled
(
c
c
.
ComponentConfig
.
DisablePreemption
),
scheduler
.
WithPercentageOfNodesToScore
(
c
.
ComponentConfig
.
PercentageOfNodesToScore
),
scheduler
.
WithPercentageOfNodesToScore
(
c
c
.
ComponentConfig
.
PercentageOfNodesToScore
),
scheduler
.
WithBindTimeoutSeconds
(
*
c
.
ComponentConfig
.
BindTimeoutSeconds
))
scheduler
.
WithBindTimeoutSeconds
(
*
c
c
.
ComponentConfig
.
BindTimeoutSeconds
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -206,7 +211,7 @@ func run(cmd *cobra.Command, args []string, opts *options.Options) error {
...
@@ -206,7 +211,7 @@ func run(cmd *cobra.Command, args []string, opts *options.Options) error {
cc
.
InformerFactory
.
WaitForCacheSync
(
stopCh
)
cc
.
InformerFactory
.
WaitForCacheSync
(
stopCh
)
controller
.
WaitForCacheSync
(
"scheduler"
,
stopCh
,
cc
.
PodInformer
.
Informer
()
.
HasSynced
)
controller
.
WaitForCacheSync
(
"scheduler"
,
stopCh
,
cc
.
PodInformer
.
Informer
()
.
HasSynced
)
// Prepare a reusable run function.
// Prepare a reusable run
Command
function.
run
:=
func
(
ctx
context
.
Context
)
{
run
:=
func
(
ctx
context
.
Context
)
{
sched
.
Run
()
sched
.
Run
()
<-
ctx
.
Done
()
<-
ctx
.
Done
()
...
@@ -223,7 +228,7 @@ func run(cmd *cobra.Command, args []string, opts *options.Options) error {
...
@@ -223,7 +228,7 @@ func run(cmd *cobra.Command, args []string, opts *options.Options) error {
}
}
}()
}()
// If leader election is enabled, run via LeaderElector until done and exit.
// If leader election is enabled, run
Command
via LeaderElector until done and exit.
if
cc
.
LeaderElection
!=
nil
{
if
cc
.
LeaderElection
!=
nil
{
cc
.
LeaderElection
.
Callbacks
=
leaderelection
.
LeaderCallbacks
{
cc
.
LeaderElection
.
Callbacks
=
leaderelection
.
LeaderCallbacks
{
OnStartedLeading
:
run
,
OnStartedLeading
:
run
,
...
@@ -241,7 +246,7 @@ func run(cmd *cobra.Command, args []string, opts *options.Options) error {
...
@@ -241,7 +246,7 @@ func run(cmd *cobra.Command, args []string, opts *options.Options) error {
return
fmt
.
Errorf
(
"lost lease"
)
return
fmt
.
Errorf
(
"lost lease"
)
}
}
// Leader election is disabled, so run inline until done.
// Leader election is disabled, so run
Command
inline until done.
run
(
ctx
)
run
(
ctx
)
return
fmt
.
Errorf
(
"finished without leader elect"
)
return
fmt
.
Errorf
(
"finished without leader elect"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment