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
fe17387f
Commit
fe17387f
authored
Dec 21, 2017
by
Michael Taufen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
periodically check whether assigned kubelet config should become last-known-good
parent
de064310
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
controller.go
pkg/kubelet/kubeletconfig/controller.go
+18
-9
No files found.
pkg/kubelet/kubeletconfig/controller.go
View file @
fe17387f
...
@@ -141,15 +141,11 @@ func (cc *Controller) Bootstrap() (*kubeletconfig.KubeletConfiguration, error) {
...
@@ -141,15 +141,11 @@ func (cc *Controller) Bootstrap() (*kubeletconfig.KubeletConfiguration, error) {
cc
.
configOK
.
Set
(
status
.
CurLocalMessage
,
reason
,
apiv1
.
ConditionTrue
)
cc
.
configOK
.
Set
(
status
.
CurLocalMessage
,
reason
,
apiv1
.
ConditionTrue
)
}
}
// when the trial period is over, the assigned config becomes the last-known-good
// update the last-known-good config if necessary, and start a timer that
if
trial
,
err
:=
cc
.
inTrial
(
assigned
.
ConfigTrialDuration
.
Duration
);
err
!=
nil
{
// periodically checks whether the last-known good needs to be updated
utillog
.
Errorf
(
"failed to check trial period for assigned config, error: %v"
,
err
)
// we only do this when the assigned config loads and passes validation
}
else
if
!
trial
{
// wait.Forever will call the func once before starting the timer
utillog
.
Infof
(
"assigned config passed trial period, will set as last-known-good"
)
go
wait
.
Forever
(
func
()
{
cc
.
checkTrial
(
assigned
.
ConfigTrialDuration
.
Duration
)
},
10
*
time
.
Second
)
if
err
:=
cc
.
graduateAssignedToLastKnownGood
();
err
!=
nil
{
utillog
.
Errorf
(
"failed to set last-known-good to assigned config, error: %v"
,
err
)
}
}
return
assigned
,
nil
return
assigned
,
nil
}
// Assert: the assigned config failed to load, parse, or validate
}
// Assert: the assigned config failed to load, parse, or validate
...
@@ -319,6 +315,19 @@ func (cc *Controller) initializeDynamicConfigDir() error {
...
@@ -319,6 +315,19 @@ func (cc *Controller) initializeDynamicConfigDir() error {
return
cc
.
checkpointStore
.
Initialize
()
return
cc
.
checkpointStore
.
Initialize
()
}
}
// checkTrial checks whether the trial duration has passed, and updates the last-known-good config if necessary
func
(
cc
*
Controller
)
checkTrial
(
duration
time
.
Duration
)
{
// when the trial period is over, the assigned config becomes the last-known-good
if
trial
,
err
:=
cc
.
inTrial
(
duration
);
err
!=
nil
{
utillog
.
Errorf
(
"failed to check trial period for assigned config, error: %v"
,
err
)
}
else
if
!
trial
{
utillog
.
Infof
(
"assigned config passed trial period, will set as last-known-good"
)
if
err
:=
cc
.
graduateAssignedToLastKnownGood
();
err
!=
nil
{
utillog
.
Errorf
(
"failed to set last-known-good to assigned config, error: %v"
,
err
)
}
}
}
// inTrial returns true if the time elapsed since the last modification of the current config does not exceed `trialDur`, false otherwise
// inTrial returns true if the time elapsed since the last modification of the current config does not exceed `trialDur`, false otherwise
func
(
cc
*
Controller
)
inTrial
(
trialDur
time
.
Duration
)
(
bool
,
error
)
{
func
(
cc
*
Controller
)
inTrial
(
trialDur
time
.
Duration
)
(
bool
,
error
)
{
now
:=
time
.
Now
()
now
:=
time
.
Now
()
...
...
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