mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
periodically check whether assigned kubelet config should become last-known-good
This commit is contained in:
parent
de0643106c
commit
fe17387f1b
@ -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 {
|
|||||||
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()
|
||||||
|
Loading…
Reference in New Issue
Block a user