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

*: enable gocritic.exitAfterDefer #8409

Closed
wants to merge 8 commits into from

Conversation

okJiang
Copy link
Member

@okJiang okJiang commented Jul 17, 2024

What problem does this PR solve?

Issue Number: Ref #4322

ref https://www.quasilyte.dev/blog/post/log-fatal-vs-log-panic/

What is changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

Release note

None.

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 17, 2024
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 0% with 41 lines in your changes missing coverage. Please review.

Project coverage is 77.34%. Comparing base (1a20c85) to head (05517dc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8409      +/-   ##
==========================================
+ Coverage   77.21%   77.34%   +0.12%     
==========================================
  Files         471      471              
  Lines       61835    61836       +1     
==========================================
+ Hits        47747    47825      +78     
+ Misses      10499    10420      -79     
- Partials     3589     3591       +2     
Flag Coverage Δ
unittests 77.34% <0.00%> (+0.12%) ⬆️

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

@@ -107,10 +107,10 @@ func newTestServer(isLeader bool) *testServer {
func (s *testServer) run() {
lis, err := net.Listen("tcp", s.addr)
if err != nil {
log.Fatalf("failed to serve: %v", err)
log.Panicf("failed to serve: %v", err)
Copy link
Member

@HuSharp HuSharp Jul 18, 2024

Choose a reason for hiding this comment

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

maybe can log.Panic("...", zap.error(err)) ?

Copy link
Contributor

ti-chi-bot bot commented Jul 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: HuSharp

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

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 18, 2024
Copy link
Contributor

ti-chi-bot bot commented Jul 18, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-18 06:11:33.138146573 +0000 UTC m=+507115.129088043: ☑️ agreed by HuSharp.

@ti-chi-bot ti-chi-bot bot added the approved label Jul 18, 2024
@@ -254,7 +254,7 @@ func start(cmd *cobra.Command, args []string, services ...string) {

err = join.PrepareJoinCluster(cfg)
if err != nil {
log.Fatal("join meet error", errs.ZapError(err))
log.Panic("join meet error", errs.ZapError(err))
Copy link
Member

Choose a reason for hiding this comment

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

I have some questions:

  1. The behavior is different from the previous
  2. Will it be printed out if we set the log level to fatal?
  3. What if the panic has a recover hook?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. Yes
  2. Yes, the log will be printed when log level is fatal
  3. If exist a recover hook, the panic will be caught.

from: https://www.quasilyte.dev/blog/post/log-fatal-vs-log-panic/
The log.Panic vs log.Fatal is essentially panic vs os.Exit(1). The latter will not let deferred calls to run.

@okJiang
Copy link
Member Author

okJiang commented Jul 19, 2024

Since some users might rely on the "fatal" keyword to define alarm rules, we won't make any changes to this.

@okJiang okJiang closed this Jul 19, 2024
@okJiang okJiang deleted the rm-exitAfterDefer branch July 19, 2024 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note-none Denotes a PR that doesn't merit a release note. 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.

3 participants