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

Lazily initialize signal handling for hyperkube apiserver and kubelet #76659

Conversation

S-Chan
Copy link
Contributor

@S-Chan S-Chan commented Apr 16, 2019

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

/kind bug

What this PR does / why we need it:
https://github.com/kubernetes/kubernetes/pull/63859/files#diff-dfaeb837c577bcd60dd9105c43427a35R52 initializes signal handling for all hyperkube commands. The function returns a stopCh that can be used by subcommands (e.g. apiserver, kubelet). However, not all subcommands make use of the stopCh. These subcommands (kube proxy, controller manager, etc) then require sending SIGTERM/SIGINT twice before exiting. Instead, we can initialize signal handling when the subcommand is actually run.

Which issue(s) this PR fixes:

Fixes #72029

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Signal handling is initialized within hyperkube commands that require it (apiserver, kubelet)

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Apr 16, 2019
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not 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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 16, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @S-Chan. 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 area/apiserver area/kubelet sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/release Categorizes an issue or PR as relevant to SIG Release. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 16, 2019
@S-Chan S-Chan force-pushed the stephen_chan--lazy_initialize_signal_handling branch from 8c0a8f7 to 7a75908 Compare April 16, 2019 20:07
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 16, 2019
@S-Chan
Copy link
Contributor Author

S-Chan commented Apr 16, 2019

Signed the CLA

@S-Chan
Copy link
Contributor Author

S-Chan commented Apr 17, 2019

/assign @mikedanese

Copy link
Contributor

@mattjmcnaughton mattjmcnaughton left a comment

Choose a reason for hiding this comment

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

/lgtm
/ok-to-test

Just for discussion - thoughts on if there would be a good way to unit test this? I feel like a full e2e test is overkill, but it would be interesting to think about how much lift it would be to write a unit test.

But also, I'm not sure how much that often happens for Kubernetes cmd.

@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 Apr 17, 2019
@S-Chan
Copy link
Contributor Author

S-Chan commented Apr 18, 2019

Thanks @mattjmcnaughton for the review!

I feel like it's hard to avoid writing an integration test (maybe overkill) or testing implementation details for this fix. Definitely open to suggestions though.

@mattjmcnaughton
Copy link
Contributor

mattjmcnaughton commented Apr 19, 2019 via email

@roycaihw
Copy link
Member

/lgtm

I'm not sure about test convention for cmd

// these have to be functions since the command is polymorphic. Cobra wants you to be top level
// command to get executed
apiserver := func() *cobra.Command {
ret := kubeapiserver.NewAPIServerCommand(stopCh)
ret := kubeapiserver.NewAPIServerCommand(server.SetupSignalHandler)
Copy link
Member

Choose a reason for hiding this comment

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

Just call kubeapiserver.NewAPIServerCommand(server.SetupSignalHandler) here and don't modify the other files? You'll get your laziness without mucking with the signatures of the other app packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean kubeapiserver.NewAPIServerCommand(server.SetupSignalHandler())? This can't be done as all command functions are called during commandFor.

@sttts
Copy link
Contributor

sttts commented Apr 24, 2019

Why don't we move the SetupSignalHandler call into the commands themselves? Having this indirectional looks complex and it's not even used if I have not missed anything.

@sttts sttts added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Apr 24, 2019
@k8s-ci-robot k8s-ci-robot removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Apr 24, 2019
@justaugustus justaugustus added this to Backlog in SIG Release Apr 28, 2019
@S-Chan S-Chan force-pushed the stephen_chan--lazy_initialize_signal_handling branch 2 times, most recently from 5ce0320 to 71687d6 Compare May 6, 2019 22:34
@S-Chan
Copy link
Contributor Author

S-Chan commented May 6, 2019

@sttts thanks for the suggestion, I've moved SetupSignalHandler into kubelet and apiserver.

@S-Chan
Copy link
Contributor Author

S-Chan commented May 7, 2019

/retest

@S-Chan
Copy link
Contributor Author

S-Chan commented May 7, 2019

/test pull-kubernetes-local-e2e

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 9, 2019
@mikedanese
Copy link
Member

mikedanese commented May 10, 2019

/approve

Needs a rebase, otherwise looks good.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mikedanese, S-Chan

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 May 10, 2019
@S-Chan S-Chan force-pushed the stephen_chan--lazy_initialize_signal_handling branch from 71687d6 to 7cbe2d6 Compare May 10, 2019 04:49
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 10, 2019
@S-Chan
Copy link
Contributor Author

S-Chan commented May 10, 2019

/test pull-kubernetes-local-e2e

@mikedanese
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 10, 2019
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit 21bec91 into kubernetes:master May 10, 2019
SIG Release automation moved this from Backlog to Done May 10, 2019
@k8s-ci-robot
Copy link
Contributor

@S-Chan: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-local-e2e 7cbe2d6 link /test pull-kubernetes-local-e2e

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

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/apiserver 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/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/release Categorizes an issue or PR as relevant to SIG Release. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hyperkube sigterm not working for kube-proxy, kube-controller-manager, kube-scheduler
8 participants