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
90b287c1
Commit
90b287c1
authored
Jun 20, 2018
by
xuzhonghu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
leaderelection: set timeout for tryAcquireOrRenew
parent
7c6213e9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
options.go
cmd/kube-scheduler/app/options/options.go
+1
-1
leaderelection.go
...c/k8s.io/client-go/tools/leaderelection/leaderelection.go
+13
-1
No files found.
cmd/kube-scheduler/app/options/options.go
View file @
90b287c1
...
@@ -204,7 +204,7 @@ func (o *Options) Config() (*schedulerappconfig.Config, error) {
...
@@ -204,7 +204,7 @@ func (o *Options) Config() (*schedulerappconfig.Config, error) {
}
}
// prepare kube clients.
// prepare kube clients.
client
,
leaderElectionClient
,
eventClient
,
err
:=
createClients
(
o
.
ComponentConfig
.
ClientConnection
,
o
.
Master
,
o
.
ComponentConfig
.
LeaderElection
.
RenewDeadline
.
Duration
)
client
,
leaderElectionClient
,
eventClient
,
err
:=
createClients
(
c
.
ComponentConfig
.
ClientConnection
,
o
.
Master
,
c
.
ComponentConfig
.
LeaderElection
.
RenewDeadline
.
Duration
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
staging/src/k8s.io/client-go/tools/leaderelection/leaderelection.go
View file @
90b287c1
...
@@ -207,8 +207,20 @@ func (le *LeaderElector) renew(ctx context.Context) {
...
@@ -207,8 +207,20 @@ func (le *LeaderElector) renew(ctx context.Context) {
timeoutCtx
,
timeoutCancel
:=
context
.
WithTimeout
(
ctx
,
le
.
config
.
RenewDeadline
)
timeoutCtx
,
timeoutCancel
:=
context
.
WithTimeout
(
ctx
,
le
.
config
.
RenewDeadline
)
defer
timeoutCancel
()
defer
timeoutCancel
()
err
:=
wait
.
PollImmediateUntil
(
le
.
config
.
RetryPeriod
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
PollImmediateUntil
(
le
.
config
.
RetryPeriod
,
func
()
(
bool
,
error
)
{
return
le
.
tryAcquireOrRenew
(),
nil
done
:=
make
(
chan
bool
,
1
)
go
func
()
{
defer
close
(
done
)
done
<-
le
.
tryAcquireOrRenew
()
}()
select
{
case
<-
timeoutCtx
.
Done
()
:
return
false
,
fmt
.
Errorf
(
"failed to tryAcquireOrRenew %s"
,
timeoutCtx
.
Err
())
case
result
:=
<-
done
:
return
result
,
nil
}
},
timeoutCtx
.
Done
())
},
timeoutCtx
.
Done
())
le
.
maybeReportTransition
()
le
.
maybeReportTransition
()
desc
:=
le
.
config
.
Lock
.
Describe
()
desc
:=
le
.
config
.
Lock
.
Describe
()
if
err
==
nil
{
if
err
==
nil
{
...
...
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