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

util/logutil: Remove useless grpc log in production #25454

Merged
merged 15 commits into from
Aug 16, 2021

Conversation

SabaPing
Copy link
Contributor

@SabaPing SabaPing commented Jun 15, 2021

What problem does this PR solve?

There is a pr #23534, refactors the log code. It rewrites the initialization logic of the grpc logger, resulting in annoying grpc logs.

This pr remove those useless logs.

What is changed and how it works?

What's Changed:

Refactor the grpc logger initialization logic.

Related changes

#23534

  • Need to cherry-pick to the release branch

Check List

Tests

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

Release note

  • No release note

@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 15, 2021
@sre-bot
Copy link
Contributor

sre-bot commented Jun 15, 2021

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

@ti-srebot
Copy link
Contributor

@SabaPing SabaPing changed the title [util/log]Remove useless grpc log in production util/log: Remove useless grpc log in production Jun 15, 2021
@SabaPing SabaPing changed the title util/log: Remove useless grpc log in production util/logutil: Remove useless grpc log in production Jun 15, 2021
@SabaPing
Copy link
Contributor Author

/rebuild

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jun 16, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • breeswish
  • zimulala

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 16, 2021
// copy Config struct by assignment
config := cfg.Config
// hack: force stdout
config.File.Filename = ""
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to force output grpc log to stdout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The old logic directs all grpc log to std. Please take a look at

if len(os.Getenv("GRPC_DEBUG")) > 0 {

Copy link
Member

Choose a reason for hiding this comment

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

Nice catch. Then there is a problem: the old logic output to stderr. In the tiup deployment, stderr will be piped to the tidb_stderr.log file eventually. But if you redirect them to the stdout as in this PR, then you will just lose your outputs, as stdout is not collected anywhere..

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 find it hard to print to stderr then I think it is fine to print in the log file. There is no much difference from my perspective.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@breezewish breezewish added the type/bugfix This PR fixes a bug. label Jun 16, 2021
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 17, 2021
@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 17, 2021
conf := NewLogConfig("info", DefaultLogFormat, "", EmptyFileLogConfig, false)
copiedConfig := *conf
// assert that the new conf's address not same as the old one
c.Assert(&copiedConfig != conf, Equals, true)
Copy link
Member

Choose a reason for hiding this comment

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

how about aseerting that after calling the function the original config's level remains unchanged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

if err != nil {
return nil, nil, errors.Trace(err)
}
gzap.ReplaceGrpcLoggerV2WithVerbosity(l, 999)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change the value of verbosity?

Copy link
Contributor Author

@SabaPing SabaPing Jun 17, 2021

Choose a reason for hiding this comment

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

grpclog.SetLoggerV2(grpclog.NewLoggerV2WithVerbosity(os.Stderr, os.Stderr, os.Stderr, 999))

The original logic set the verbosity to 999. I just migrated the code and kept it unchanged.

}

func initGRPCLogger(cfg *LogConfig) (*zap.Logger, *log.ZapProperties, error) {
// copy Config struct by assignment
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// copy Config struct by assignment
// Copy Config struct by assignment.

@SabaPing
Copy link
Contributor Author

I'll pick up this issue tomorrow.

@SabaPing
Copy link
Contributor Author

PTAL @tisonkun @breeswish @zimulala

Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 13, 2021
@breezewish
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 19660f4

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 15, 2021
@breezewish
Copy link
Member

/merge

@ti-chi-bot ti-chi-bot merged commit ed88b54 into pingcap:master Aug 16, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 16, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.1 in PR #27238

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 16, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.2 in PR #27239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.1 needs-cherry-pick-release-5.2 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants