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

owner: refactor logger and err handling in campaign loop #57705

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented Nov 26, 2024

What problem does this PR solve?

Issue Number: ref #57275

Problem Summary:

What changed and how does it work?

  • Refactoring of the ownerManager struct: Replaced logPrefix and logCtx fields with a logger field of type *zap.Logger.
  • Updated logging calls: All logging calls in the functions were updated to use the new logger field instead of the previous logPrefix and logCtx.
  • Addition of the campaignAndWatch function: Refactored part of the campaignLoop function into a new campaignAndWatch function for better readability and separation of concerns.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 26, 2024
Copy link

tiprow bot commented Nov 26, 2024

Hi @D3Hunter. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

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-sigs/prow repository.

@@ -456,26 +452,17 @@ func (m *ownerManager) refreshSession(retryCnt, ttl int) error {
return nil
}

func (m *ownerManager) revokeSession(leaseID clientv3.LeaseID) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not used anymore

@D3Hunter D3Hunter requested a review from lance6716 November 26, 2024 07:04
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 80.30303% with 13 lines in your changes missing coverage. Please review.

Project coverage is 73.8879%. Comparing base (d02d48a) to head (d29b19e).
Report is 12 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #57705        +/-   ##
================================================
+ Coverage   72.8318%   73.8879%   +1.0560%     
================================================
  Files          1677       1677                
  Lines        463944     468557      +4613     
================================================
+ Hits         337899     346207      +8308     
+ Misses       105169     101674      -3495     
+ Partials      20876      20676       -200     
Flag Coverage Δ
integration 43.9978% <0.0000%> (?)
unit 72.7473% <80.3030%> (+0.5234%) ⬆️

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

Components Coverage Δ
dumpling 52.7673% <ø> (ø)
parser ∅ <ø> (∅)
br 46.2924% <ø> (+0.7812%) ⬆️

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

push my small review because GitHub is unstable

return &ownerManager{
etcdCli: etcdCli,
id: id,
key: key,
ctx: ctx,
prompt: prompt,
logPrefix: logPrefix,
logCtx: logutil.WithKeyValue(context.Background(), "owner info", logPrefix),
logger: logutil.BgLogger().With(zap.String("key", key), zap.String("id", id)),
Copy link
Contributor

Choose a reason for hiding this comment

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

in the old log, prompt is also printed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

key contains enough info, prompt is redundant

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

ti-chi-bot bot commented Nov 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, tangenta

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 approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 27, 2024
Copy link

ti-chi-bot bot commented Nov 27, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-27 03:49:27.224000918 +0000 UTC m=+608354.843655434: ☑️ agreed by lance6716.
  • 2024-11-27 06:39:29.042742322 +0000 UTC m=+618556.662396837: ☑️ agreed by tangenta.

@ti-chi-bot ti-chi-bot bot merged commit 996ce64 into pingcap:master Nov 27, 2024
24 checks passed
@D3Hunter D3Hunter deleted the refactor-owner branch November 27, 2024 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants