Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make node lease renew interval more heuristic #80173

Merged
merged 1 commit into from
Jul 18, 2019

Conversation

gaorong
Copy link
Contributor

@gaorong gaorong commented Jul 15, 2019

What type of PR is this?
/kind bug

What this PR does / why we need it:
The node lease feature becomes beta and enables by default in v1.14. After upgrading our cluster to v1.14, we found some nodes become not ready occasionally and later become ready again after a few seconds.
In order to have a quick failure detection and recovery, our kubelet has a flag setting --node-status-update-frequency=5s and controller-manager has another flag setting --node-monitor-grace-period=10s.

If we use node lease feature, the kubelet doesn't report it's status as frequently as specified by flag --node-status-update-frequency, and use node lease mechanism to report that node is alive.
the default interval at which node lease renew is hardcoded 10s, but it can't be exactly 10s and may be a little bit more than 10s because of some network latency. when controller-manager doesn't receive messages from kubelet in every 10s in our case, it will mark this node as unreachable and not ready state, but in the next reconcile cycle, it receives the lease update message and mark this node as reachable again, so the node status is flapping between ready and not ready state.

This seems a breaking change that setting kubelet's lease renewing interval to a hardcoded 10s, even though our node status update frequency has a little bit small value, node lease should align kubelet's previous behavior and renew as frequently as --node-status-update-frequency to reporting alive message, otherwise controller-manager will mark this node as unreachable.

Which issue(s) this PR fixes:

Fixes #80172

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

make node lease renew interval more heuristic based on node-status-update-frequency in kubelet

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jul 15, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @gaorong. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jul 15, 2019
@liggitt
Copy link
Member

liggitt commented Jul 15, 2019

cc @wojtek-t

@liggitt
Copy link
Member

liggitt commented Jul 15, 2019

@wojtek-t can you confirm the interaction between the NodeStatusUpdateFrequency/NodeStatusReportFrequency/NodeLeaseDurationSeconds settings in the kubelet and how the node lease feature interacts with them?

@wojtek-t
Copy link
Member

@wojtek-t can you confirm the interaction between the NodeStatusUpdateFrequency/NodeStatusReportFrequency/NodeLeaseDurationSeconds settings in the kubelet and how the node lease feature interacts with them?

Described that the issue: #80172

I think the cleanest way would be add a field to KubeletConfig to allow configuring it by users.

@liggitt but that can't be cherrypicked back IIUC (because it introduces new fields to api type that KubeletConfig is). So maybe we actually should:

  • add the field to KubeletConfig at head
  • cherrypick a PR like that to 1.14 and 1.15 ?
    WDYT?

@wangzhen127

@gaorong
Copy link
Contributor Author

gaorong commented Jul 16, 2019

I volunteer to implement this feature,if wangzhen127@ has no bandwidth with this.

var leaseClient coordclientset.LeaseInterface
if client != nil {
leaseClient = client.CoordinationV1().Leases(corev1.NamespaceNodeLease)
}
var renewInterval time.Duration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there ever a valid case for renewInterval being >= leaseDurationSeconds?

protecting against a mismatch between leaseDurationSeconds and nodeStatusUpdateFrequency by forcing renewInterval to be at least X seconds before or < X% of leaseDurationSeconds would make sense to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally, not found that case.

IIUC, the leaseDurationSeconds seems to be a redundancy filed and not been used by node healthy-related work at least for now.
As may be used in the future, I agree we should have some restriction to make renewInterval being smaller than leaseDurationSeconds

Copy link
Contributor Author

@gaorong gaorong Jul 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forcing renewInterval to be at least X seconds before or < X% of leaseDurationSeconds

I found it difficult to generate a smart enough renewInterval value based on the leaseDurationSeconds, because different user may have different leaseDurationSeconds.

As leaseDurationSeconds have not been used by node healthy-related work for now, we can ignore that restriction. only forcing this value based on nodeStatusUpdateFrequency is enough.

so we can cherry-pick this PR to v1.14 and 1.15 safely.

After this fix, we should add a new field to KubeletConfig at head, let user customize the renewInterval value based on their own circumstance. we don't need to worry about this value anymore other than write some documents.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wojtek-t what do you think about my proposal?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there ever a valid case for renewInterval being >= leaseDurationSeconds?

No - I don't see any usecase for that.
But yeah - as @gaorong pointed out, leaseDuriationSeconds is currently only propagated as part of Lease object and not really used in any meaningful way.

I'm personally not 100% convinced that connecting "renewInterval" with "nodeStatusUpdateFrequency" is exactly what we want. In the ideal world, this should be connected with "node-monitor-grace-period", but that's not even parameter to kubelet, so we don't have any way to reasonably validate it.

So as a workaround, I'm temporarily fine with the logic you proposed in the PR, if we add a very explicit comment of why we're doing that.
So let's change it something like:

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
}

In the meantime if you could also work on exposing it via kubelet config, it would be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed as comments.

I'm going to working on exposing it via kubelet config.

@wojtek-t
Copy link
Member

/ok-to-test
/lgtm
/approve

Holding to let Jordan also take a look if he wants.
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 17, 2019
@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 17, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gaorong, wojtek-t

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 17, 2019
@wojtek-t wojtek-t removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Jul 18, 2019
@wojtek-t wojtek-t added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Jul 18, 2019
@wojtek-t
Copy link
Member

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 18, 2019
@gaorong
Copy link
Contributor Author

gaorong commented Jul 18, 2019

/retest

@k8s-ci-robot k8s-ci-robot merged commit ab266f7 into kubernetes:master Jul 18, 2019
@gaorong gaorong deleted the node-lease-renew-interval branch July 18, 2019 14:09
@gaorong
Copy link
Contributor Author

gaorong commented Jul 19, 2019

As all 'parent' PRs of a cherry-pick PR must have one of the "release-note" or "release-note-action-required" labels, I changed the release note and cherry-pickied to the previous release.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jul 19, 2019
@liggitt liggitt added this to the v1.16 milestone Aug 6, 2019
k8s-ci-robot added a commit that referenced this pull request Aug 7, 2019
…3-upstream-release-1.14

Automated cherry pick of #80173: make node lease renew interval more heuristic
k8s-ci-robot added a commit that referenced this pull request Aug 7, 2019
…3-upstream-release-1.15

Automated cherry pick of #80173: make node lease renew interval more heuristic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

node status is flapping between ready and not ready state because of long interval at which node lease renew
4 participants