mirror of https://github.com/k3s-io/k3s
make node lease renew interval more heuristic
parent
7936da50c6
commit
77a13eda99
|
@ -865,7 +865,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
|||
klet.softAdmitHandlers.AddPodAdmitHandler(lifecycle.NewNoNewPrivsAdmitHandler(klet.containerRuntime))
|
||||
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.NodeLease) {
|
||||
klet.nodeLeaseController = nodelease.NewController(klet.clock, klet.heartbeatClient, string(klet.nodeName), kubeCfg.NodeLeaseDurationSeconds, klet.onRepeatedHeartbeatFailure)
|
||||
klet.nodeLeaseController = nodelease.NewController(klet.clock, klet.heartbeatClient, string(klet.nodeName), kubeCfg.NodeLeaseDurationSeconds, kubeCfg.NodeStatusUpdateFrequency.Duration, klet.onRepeatedHeartbeatFailure)
|
||||
}
|
||||
|
||||
klet.softAdmitHandlers.AddPodAdmitHandler(lifecycle.NewProcMountAdmitHandler(klet.containerRuntime))
|
||||
|
|
|
@ -33,11 +33,11 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// renewInterval is the interval at which the lease is renewed
|
||||
// defaultRenewInterval is the default interval at which the lease is renewed
|
||||
// TODO(mtaufen): 10s was the decision in the KEP, to keep the behavior as close to the
|
||||
// current default behavior as possible. In the future, we should determine a reasonable
|
||||
// fraction of the lease duration at which to renew, and use that instead.
|
||||
renewInterval = 10 * time.Second
|
||||
defaultRenewInterval = 10 * time.Second
|
||||
// maxUpdateRetries is the number of immediate, successive retries the Kubelet will attempt
|
||||
// when renewing the lease before it waits for the renewal interval before trying again,
|
||||
// similar to what we do for node status retries
|
||||
|
@ -62,11 +62,21 @@ type controller struct {
|
|||
}
|
||||
|
||||
// NewController constructs and returns a controller
|
||||
func NewController(clock clock.Clock, client clientset.Interface, holderIdentity string, leaseDurationSeconds int32, onRepeatedHeartbeatFailure func()) Controller {
|
||||
func NewController(clock clock.Clock, client clientset.Interface, holderIdentity string, leaseDurationSeconds int32, nodeStatusUpdateFrequency time.Duration, onRepeatedHeartbeatFailure func()) Controller {
|
||||
var leaseClient coordclientset.LeaseInterface
|
||||
if client != nil {
|
||||
leaseClient = client.CoordinationV1beta1().Leases(corev1.NamespaceNodeLease)
|
||||
}
|
||||
renewInterval := defaultRenewInterval
|
||||
// Users are able to decrease the timeout after which nodes are being
|
||||
// marked as "Ready: Unknown" by NodeLifecycleController to values
|
||||
// smaller than defaultRenewInterval. Until the knob to configure
|
||||
// lease renew interval is exposed to user, we temporarily decrease
|
||||
// renewInterval based on the NodeStatusUpdateFrequency.
|
||||
if renewInterval > nodeStatusUpdateFrequency {
|
||||
renewInterval = nodeStatusUpdateFrequency
|
||||
}
|
||||
|
||||
return &controller{
|
||||
client: client,
|
||||
leaseClient: leaseClient,
|
||||
|
|
Loading…
Reference in New Issue