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

Report KCM as unhealthy if leader election is wedged. #70971

Merged
merged 1 commit into from
Nov 15, 2018

Conversation

cheftako
Copy link
Member

@cheftako cheftako commented Nov 13, 2018

What type of PR is this?
/kind bug

What this PR does / why we need it:
Mitigation on #70819.
Too late in the cycle to make a large x/net/http2 vendor change.
Adding code to track if the lease election is wedged and report as unhealthy.
That should allow the kubelet to restart the KCM.
Please note that this only works for clusters without --leader-elect turned off. (HA clusters must run leader election, it is theoretically optional in single master clusters )

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Mitigates #70819

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

None

@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/L Denotes a PR that changes 100-499 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 Nov 13, 2018
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 13, 2018
@cheftako
Copy link
Member Author

/assign @lavalamp

// If we are more than 20 seconds after the lease durection that is past the timeout on the lease renew.
// Time to start reporting ourselves as unhealthy. We should have died but conditions like deadlock can
// prevent this. (See #70819)
expiry := l.le.observedTime.Add(l.le.config.LeaseDuration).Add(time.Second * 20)
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little conflicted about a hardcoded 20 second timeout. I think not every user of this library will exit like controller manager does, so maybe it should be configurable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I have pushed it as configurable up one level. However I'm not sure I want to push it all the way to the CLI just yet.

// If we are more than 20 seconds after the lease durection that is past the timeout on the lease renew.
// Time to start reporting ourselves as unhealthy. We should have died but conditions like deadlock can
// prevent this. (See #70819)
expiry := l.le.observedTime.Add(l.le.config.LeaseDuration).Add(time.Second * 20)
Copy link
Member

Choose a reason for hiding this comment

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

If you add a function that exposes observedTime (or the observedRecord's acquireTime), then maybe you can put all of this code in another package?

Copy link
Member Author

Choose a reason for hiding this comment

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

I could but I don't want to expose the inner workings of leaderelection as I feel it should remain obfuscated. The more we expose these details the less room we have to fix it later. I also think that having the optional healthz check which is responsible for/understands the inner workings of leaderelection is a good thing. I agree with not wanting to pull in server code to the client package but I think you other suggestions have essentially accomplished that.

@deads2k
Copy link
Contributor

deads2k commented Nov 13, 2018

I like the idea of this change.

/milestone 1.13

@k8s-ci-robot
Copy link
Contributor

@deads2k: The provided milestone is not valid for this repository. Milestones in this repository: [next-candidate, v1.10, v1.11, v1.12, v1.13, v1.14, v1.4, v1.5, v1.6, v1.7, v1.8, v1.9]

Use /milestone clear to clear the milestone.

In response to this:

I like the idea of this change.

/milestone 1.13

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.

@deads2k deads2k added this to the v1.13 milestone Nov 13, 2018
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 13, 2018
@dims
Copy link
Member

dims commented Nov 14, 2018

/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 14, 2018
@cheftako
Copy link
Member Author

/test pull-kubernetes-integration

Copy link
Member

@lavalamp lavalamp left a comment

Choose a reason for hiding this comment

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

No structural comments this time, just a bunch of little nits.

Copy link
Member

@lavalamp lavalamp left a comment

Choose a reason for hiding this comment

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

Just nits now.

l.le = le
}

// NewHealthzAdaptor creates a basic healthz adaptor to monitor a leader election.
Copy link
Member

Choose a reason for hiding this comment

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

This comment missed :)

Feedback from lavalamp and deads2k.
Changed Check() logic to be central to LeaderElector.
Further changes, especially cleaning up the test code.
@lavalamp
Copy link
Member

/approve
/lgtm

Do we need to provide a way to disable this just in case it is causes a problem? I can't think of a specific thing that can go wrong-- actually, what about daylight savings time getting turned off? I know (hope?) we tell everyone to use UTC for servers, but...

It seems remote so I won't hold this up any more.

I guess folks can use Han's change to stop monitoring this if necessary anyway?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 15, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheftako, lavalamp

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 Nov 15, 2018
@k8s-ci-robot k8s-ci-robot merged commit f48e18f into kubernetes:master Nov 15, 2018
@logicalhan
Copy link
Member

I guess folks can use Han's change to stop monitoring this if necessary anyway?

Verified:

$ curl "localhost:10252/healthz?verbose&exclude=leaderElection"

[+]leaderElection excluded: ok
healthz check passed

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. 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. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants