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
3252beb0
Unverified
Commit
3252beb0
authored
Feb 14, 2018
by
Mikhail Mazurskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Propagate signal from stop to context
parent
dc32a341
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
server.go
cmd/kube-scheduler/app/server.go
+16
-7
No files found.
cmd/kube-scheduler/app/server.go
View file @
3252beb0
...
@@ -182,17 +182,26 @@ func Run(c schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}) error
...
@@ -182,17 +182,26 @@ func Run(c schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}) error
controller
.
WaitForCacheSync
(
"scheduler"
,
stopCh
,
c
.
PodInformer
.
Informer
()
.
HasSynced
)
controller
.
WaitForCacheSync
(
"scheduler"
,
stopCh
,
c
.
PodInformer
.
Informer
()
.
HasSynced
)
// Prepare a reusable run function.
// Prepare a reusable run function.
run
:=
func
(
stopCh
<-
chan
struct
{}
)
{
run
:=
func
(
ctx
context
.
Context
)
{
sched
.
Run
()
sched
.
Run
()
<-
stopCh
<-
ctx
.
Done
()
}
}
runCtx
,
cancel
:=
context
.
WithCancel
(
context
.
TODO
())
// once Run() accepts a context, it should be used here
defer
cancel
()
go
func
()
{
select
{
case
<-
stopCh
:
cancel
()
case
<-
runCtx
.
Done
()
:
}
}()
// If leader election is enabled, run via LeaderElector until done and exit.
// If leader election is enabled, run via LeaderElector until done and exit.
if
c
.
LeaderElection
!=
nil
{
if
c
.
LeaderElection
!=
nil
{
c
.
LeaderElection
.
Callbacks
=
leaderelection
.
LeaderCallbacks
{
c
.
LeaderElection
.
Callbacks
=
leaderelection
.
LeaderCallbacks
{
OnStartedLeading
:
func
(
ctx
context
.
Context
)
{
OnStartedLeading
:
run
,
run
(
ctx
.
Done
())
},
OnStoppedLeading
:
func
()
{
OnStoppedLeading
:
func
()
{
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"lost master"
))
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"lost master"
))
},
},
...
@@ -202,13 +211,13 @@ func Run(c schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}) error
...
@@ -202,13 +211,13 @@ func Run(c schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}) error
return
fmt
.
Errorf
(
"couldn't create leader elector: %v"
,
err
)
return
fmt
.
Errorf
(
"couldn't create leader elector: %v"
,
err
)
}
}
leaderElector
.
Run
(
context
.
TODO
()
)
leaderElector
.
Run
(
runCtx
)
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 inline until done.
run
(
stopCh
)
run
(
runCtx
)
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