Skip to content

Commit 95f3e64

Browse files
committed
make node lease renew interval more heuristic
1 parent 29669a5 commit 95f3e64

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

pkg/kubelet/kubelet.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
871871
klet.softAdmitHandlers.AddPodAdmitHandler(lifecycle.NewNoNewPrivsAdmitHandler(klet.containerRuntime))
872872

873873
if utilfeature.DefaultFeatureGate.Enabled(features.NodeLease) {
874-
klet.nodeLeaseController = nodelease.NewController(klet.clock, klet.heartbeatClient, string(klet.nodeName), kubeCfg.NodeLeaseDurationSeconds, klet.onRepeatedHeartbeatFailure)
874+
klet.nodeLeaseController = nodelease.NewController(klet.clock, klet.heartbeatClient, string(klet.nodeName), kubeCfg.NodeLeaseDurationSeconds, kubeCfg.NodeStatusUpdateFrequency.Duration, klet.onRepeatedHeartbeatFailure)
875875
}
876876

877877
klet.softAdmitHandlers.AddPodAdmitHandler(lifecycle.NewProcMountAdmitHandler(klet.containerRuntime))

pkg/kubelet/nodelease/controller.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import (
3434
)
3535

3636
const (
37-
// renewInterval is the interval at which the lease is renewed
38-
renewInterval = 10 * time.Second
37+
// defaultRenewInterval is the default interval at which the lease is renewed
38+
defaultRenewInterval = 10 * time.Second
3939
// maxUpdateRetries is the number of immediate, successive retries the Kubelet will attempt
4040
// when renewing the lease before it waits for the renewal interval before trying again,
4141
// similar to what we do for node status retries
@@ -60,11 +60,21 @@ type controller struct {
6060
}
6161

6262
// NewController constructs and returns a controller
63-
func NewController(clock clock.Clock, client clientset.Interface, holderIdentity string, leaseDurationSeconds int32, onRepeatedHeartbeatFailure func()) Controller {
63+
func NewController(clock clock.Clock, client clientset.Interface, holderIdentity string, leaseDurationSeconds int32, nodeStatusUpdateFrequency time.Duration, onRepeatedHeartbeatFailure func()) Controller {
6464
var leaseClient coordclientset.LeaseInterface
6565
if client != nil {
6666
leaseClient = client.CoordinationV1().Leases(corev1.NamespaceNodeLease)
6767
}
68+
renewInterval := defaultRenewInterval
69+
// Users are able to decrease the timeout after which nodes are being
70+
// marked as "Ready: Unknown" by NodeLifecycleController to values
71+
// smaller than defaultRenewInterval. Until the knob to configure
72+
// lease renew interval is exposed to user, we temporarily decrease
73+
// renewInterval based on the NodeStatusUpdateFrequency.
74+
if renewInterval > nodeStatusUpdateFrequency {
75+
renewInterval = nodeStatusUpdateFrequency
76+
}
77+
6878
return &controller{
6979
client: client,
7080
leaseClient: leaseClient,

0 commit comments

Comments
 (0)