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
102090d1
Unverified
Commit
102090d1
authored
Jun 07, 2018
by
Mikhail Mazurskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use context.TODO() to be explicit that cancellation is not implemented
parent
3252beb0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
17 deletions
+10
-17
controllermanager.go
cmd/cloud-controller-manager/app/controllermanager.go
+2
-5
controllermanager.go
cmd/kube-controller-manager/app/controllermanager.go
+2
-5
server.go
cmd/kube-scheduler/app/server.go
+4
-4
leaderelection.go
...c/k8s.io/client-go/tools/leaderelection/leaderelection.go
+2
-3
No files found.
cmd/cloud-controller-manager/app/controllermanager.go
View file @
102090d1
...
@@ -157,11 +157,8 @@ func Run(c *cloudcontrollerconfig.CompletedConfig) error {
...
@@ -157,11 +157,8 @@ func Run(c *cloudcontrollerconfig.CompletedConfig) error {
}
}
}
}
runCtx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
if
!
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
LeaderElect
{
if
!
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
LeaderElect
{
run
(
runCtx
)
run
(
context
.
TODO
()
)
panic
(
"unreachable"
)
panic
(
"unreachable"
)
}
}
...
@@ -187,7 +184,7 @@ func Run(c *cloudcontrollerconfig.CompletedConfig) error {
...
@@ -187,7 +184,7 @@ func Run(c *cloudcontrollerconfig.CompletedConfig) error {
}
}
// Try and become the leader and start cloud controller manager loops
// Try and become the leader and start cloud controller manager loops
leaderelection
.
RunOrDie
(
runCtx
,
leaderelection
.
LeaderElectionConfig
{
leaderelection
.
RunOrDie
(
context
.
TODO
()
,
leaderelection
.
LeaderElectionConfig
{
Lock
:
rl
,
Lock
:
rl
,
LeaseDuration
:
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
LeaseDuration
.
Duration
,
LeaseDuration
:
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
LeaseDuration
.
Duration
,
RenewDeadline
:
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
RenewDeadline
.
Duration
,
RenewDeadline
:
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
RenewDeadline
.
Duration
,
...
...
cmd/kube-controller-manager/app/controllermanager.go
View file @
102090d1
...
@@ -181,11 +181,8 @@ func Run(c *config.CompletedConfig) error {
...
@@ -181,11 +181,8 @@ func Run(c *config.CompletedConfig) error {
select
{}
select
{}
}
}
runCtx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
if
!
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
LeaderElect
{
if
!
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
LeaderElect
{
run
(
runCtx
)
run
(
context
.
TODO
()
)
panic
(
"unreachable"
)
panic
(
"unreachable"
)
}
}
...
@@ -208,7 +205,7 @@ func Run(c *config.CompletedConfig) error {
...
@@ -208,7 +205,7 @@ func Run(c *config.CompletedConfig) error {
glog
.
Fatalf
(
"error creating lock: %v"
,
err
)
glog
.
Fatalf
(
"error creating lock: %v"
,
err
)
}
}
leaderelection
.
RunOrDie
(
runCtx
,
leaderelection
.
LeaderElectionConfig
{
leaderelection
.
RunOrDie
(
context
.
TODO
()
,
leaderelection
.
LeaderElectionConfig
{
Lock
:
rl
,
Lock
:
rl
,
LeaseDuration
:
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
LeaseDuration
.
Duration
,
LeaseDuration
:
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
LeaseDuration
.
Duration
,
RenewDeadline
:
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
RenewDeadline
.
Duration
,
RenewDeadline
:
c
.
ComponentConfig
.
GenericComponent
.
LeaderElection
.
RenewDeadline
.
Duration
,
...
...
cmd/kube-scheduler/app/server.go
View file @
102090d1
...
@@ -187,14 +187,14 @@ func Run(c schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}) error
...
@@ -187,14 +187,14 @@ func Run(c schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}) error
<-
ctx
.
Done
()
<-
ctx
.
Done
()
}
}
runCtx
,
cancel
:=
context
.
WithCancel
(
context
.
TODO
())
//
once Run() accepts a context, it should be used here
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
TODO
())
// TODO
once Run() accepts a context, it should be used here
defer
cancel
()
defer
cancel
()
go
func
()
{
go
func
()
{
select
{
select
{
case
<-
stopCh
:
case
<-
stopCh
:
cancel
()
cancel
()
case
<-
runC
tx
.
Done
()
:
case
<-
c
tx
.
Done
()
:
}
}
}()
}()
...
@@ -211,13 +211,13 @@ func Run(c schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}) error
...
@@ -211,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
(
runC
tx
)
leaderElector
.
Run
(
c
tx
)
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
(
runC
tx
)
run
(
c
tx
)
return
fmt
.
Errorf
(
"finished without leader elect"
)
return
fmt
.
Errorf
(
"finished without leader elect"
)
}
}
...
...
staging/src/k8s.io/client-go/tools/leaderelection/leaderelection.go
View file @
102090d1
...
@@ -208,10 +208,9 @@ func (le *LeaderElector) renew(ctx context.Context) {
...
@@ -208,10 +208,9 @@ func (le *LeaderElector) renew(ctx context.Context) {
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
defer
cancel
()
defer
cancel
()
wait
.
Until
(
func
()
{
wait
.
Until
(
func
()
{
// PollUntil() sleeps for "interval" duration before calling the function so we need to increase the timeout by le.config.RetryPeriod
timeoutCtx
,
timeoutCancel
:=
context
.
WithTimeout
(
ctx
,
le
.
config
.
RenewDeadline
)
timeoutCtx
,
timeoutCancel
:=
context
.
WithTimeout
(
ctx
,
le
.
config
.
RetryPeriod
+
le
.
config
.
RenewDeadline
)
defer
timeoutCancel
()
defer
timeoutCancel
()
err
:=
wait
.
PollUntil
(
le
.
config
.
RetryPeriod
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
Poll
Immediate
Until
(
le
.
config
.
RetryPeriod
,
func
()
(
bool
,
error
)
{
return
le
.
tryAcquireOrRenew
(),
nil
return
le
.
tryAcquireOrRenew
(),
nil
},
timeoutCtx
.
Done
())
},
timeoutCtx
.
Done
())
le
.
maybeReportTransition
()
le
.
maybeReportTransition
()
...
...
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