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

bugfix: yurthub can not exit when SIGINT/SIGTERM happened #1143

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

rambohe-ch
Copy link
Member

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:
/kind bug
/kind documentation
/kind enhancement
/kind good-first-issue
/kind feature
/kind question
/kind design
/sig ai
/sig iot
/sig network
/sig storage

/kind bug

What this PR does / why we need it:

if you send SIGINT signal(kill -SIGINT pid) to yurthub component, yurthub can not exit and restart.
so i improved the yurthub http/https server by adding graceful stop feature.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


other Note

@openyurt-bot
Copy link
Collaborator

@rambohe-ch: GitHub didn't allow me to assign the following users: your_reviewer.

Note that only openyurtio members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:
/kind bug
/kind documentation
/kind enhancement
/kind good-first-issue
/kind feature
/kind question
/kind design
/sig ai
/sig iot
/sig network
/sig storage

/kind bug

What this PR does / why we need it:

if you send SIGINT signal(kill -SIGINT pid) to yurthub component, yurthub can not exit and restart.
so i improved the yurthub http/https server by adding graceful stop feature.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


other Note

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.

@openyurt-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rambohe-ch

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

@openyurt-bot openyurt-bot added approved approved size/XL size/XL: 500-999 labels Jan 12, 2023
@codecov
Copy link

codecov bot commented Jan 12, 2023

Codecov Report

Merging #1143 (01878a3) into master (5ba736c) will increase coverage by 0.61%.
The diff coverage is 58.23%.

@@            Coverage Diff             @@
##           master    #1143      +/-   ##
==========================================
+ Coverage   54.97%   55.59%   +0.61%     
==========================================
  Files          96       98       +2     
  Lines       12582    12881     +299     
==========================================
+ Hits         6917     7161     +244     
- Misses       5070     5091      +21     
- Partials      595      629      +34     
Flag Coverage Δ
unittests 55.59% <58.23%> (+0.61%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/yurthub/network/iptables.go 0.00% <0.00%> (ø)
pkg/yurthub/network/network.go 0.00% <0.00%> (ø)
pkg/yurthub/server/server.go 0.00% <0.00%> (ø)
pkg/yurthub/util/util.go 72.98% <ø> (ø)
cmd/yurthub/app/config/config.go 52.24% <67.76%> (ø)
cmd/yurthub/app/options/options.go 92.80% <100.00%> (ø)
pkg/yurthub/certificate/token/token.go 64.81% <100.00%> (ø)
pkg/yurthub/filter/manager/manager.go 75.47% <100.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@rambohe-ch rambohe-ch force-pushed the fix-server-graceful-stop branch 3 times, most recently from 5daed7e to edc0d1f Compare January 13, 2023 10:34
// accept traffic to localhost:10261
{iptables.Prepend, iptables.TableFilter, iptables.ChainInput, []string{"-p", "tcp", "--dport", ifPort, "--destination", "localhost", "-j", "ACCEPT"}},
// accept traffic from localhost:10261
{iptables.Prepend, iptables.TableFilter, iptables.ChainOutput, []string{"-p", "tcp", "--sport", ifPort, "-s", "localhost", "-j", "ACCEPT"}},
Copy link
Member

Choose a reason for hiding this comment

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

Could you please give some details about why we change this?

Copy link
Member Author

Choose a reason for hiding this comment

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

traffic to localhost can be accepted in default status, so these iptables settings are dummy setting, so remove them.

@@ -84,30 +81,10 @@ func NewCmdStartYurtHub(stopCh <-chan struct{}) *cobra.Command {

// Run runs the YurtHubConfiguration. This should never exit
func Run(cfg *config.YurtHubConfiguration, stopCh <-chan struct{}) error {
defer cfg.CertManager.Stop()
Copy link
Member

Choose a reason for hiding this comment

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

Could we also use stopCh to stop CertManager?

Copy link
Member Author

@rambohe-ch rambohe-ch Jan 15, 2023

Choose a reason for hiding this comment

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

no, CertManager has stopCh that is created by itself.

@Congrool
Copy link
Member

Congrool commented Jan 14, 2023

Another question:
Originally, we will create 4 servers: proxy server, secure proxy server, dummyProxyServer and secure dummyProxyServer.
But in this PR, we will only create 2 or 3 servers:

  • if enableDummyIf is set, there're proxy server, dummyProxyServer and secure dummyProxyServer
  • if enableDummyIf is not set, there're proxy server and secure proxy server

If it was intentional,could you please also give some explanation?

@rambohe-ch
Copy link
Member Author

rambohe-ch commented Jan 15, 2023

Another question: Originally, we will create 4 servers: proxy server, secure proxy server, dummyProxyServer and secure dummyProxyServer. But in this PR, we will only create 2 or 3 servers:

  • if enableDummyIf is set, there're proxy server, dummyProxyServer and secure dummyProxyServer
  • if enableDummyIf is not set, there're proxy server and secure proxy server

If it was intentional,could you please also give some explanation?

@Congrool originally, we have two https server: secure proxy server and secure dummyProxyServer, but in real scenario, only one secure server is used. in order to reduce the overhead of Yurthub, so we reduce the unused secure server.

btw: two http server: proxy server and dummyProxyServer(if enableDummyIf is true) both are used in real scenario, so we need to keep them unchanged.

@Congrool
Copy link
Member

/lgtm

@openyurt-bot openyurt-bot added the lgtm lgtm label Jan 16, 2023
@openyurt-bot openyurt-bot merged commit a898dea into openyurtio:master Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved approved kind/bug kind/bug lgtm lgtm size/XL size/XL: 500-999
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants