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

*: refine code, decrease indent, and rename #8276

Merged
merged 12 commits into from
Jun 14, 2024
Merged

Conversation

okJiang
Copy link
Member

@okJiang okJiang commented Jun 11, 2024

What problem does this PR solve?

Issue Number: Ref #4399

What is changed and how does it work?

- decrease indent for code readability
- use `continue loop` to instead with `foundDisabled` variable, this is more concise
- no other logic updates
- rename `process` to `progress`

Check List

Tests

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

Release note

None.

okJiang added 5 commits May 28, 2024 14:48
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
@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 Jun 11, 2024
Signed-off-by: okJiang <[email protected]>
Copy link

codecov bot commented Jun 11, 2024

Codecov Report

Attention: Patch coverage is 77.92208% with 17 lines in your changes missing coverage. Please review.

Project coverage is 77.32%. Comparing base (9dff6e6) to head (44c9cb0).

Current head 44c9cb0 differs from pull request most recent head a8685db

Please upload reports for the commit a8685db to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8276      +/-   ##
==========================================
- Coverage   77.35%   77.32%   -0.03%     
==========================================
  Files         470      471       +1     
  Lines       61376    61397      +21     
==========================================
- Hits        47478    47476       -2     
- Misses      10336    10365      +29     
+ Partials     3562     3556       -6     
Flag Coverage Δ
unittests 77.32% <77.92%> (-0.03%) ⬇️

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

return ops
if labelMgr.ScheduleDisabled(region) {
denySchedulersByLabelerCounter.Inc()
continue loop
Copy link
Member

Choose a reason for hiding this comment

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

Did we forget to update s.nextInterval = s.Scheduler.GetMinInterval() when executing ops[0] successfully?

Copy link
Member Author

Choose a reason for hiding this comment

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

L494

Copy link
Member

@HuSharp HuSharp Jun 11, 2024

Choose a reason for hiding this comment

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

maybe continue loop will not pass 494?

Copy link
Member Author

@okJiang okJiang Jun 11, 2024

Choose a reason for hiding this comment

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

fixed in f1c1a1e

Seem the Reset does not work

// Note: we reset the ticker here to support updating configuration dynamically.
ticker.Reset(s.GetInterval())

Interval is fixed.

But it is not related to this pr

Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to make this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you mean the changes of this file or some others?

The changes of this file are:

  1. decrease indent for code readability
  2. use continue loop to instead with foundDisabled variable, this is more concise
  3. no other updates

pkg/schedule/schedulers/scheduler_controller.go Outdated Show resolved Hide resolved
Comment on lines 1843 to 1844
storesSpeedGauge.WithLabelValues(storeAddress, storeLabel, action).Set(leftSeconds)
storesETAGauge.WithLabelValues(storeAddress, storeLabel, action).Set(currentSpeed)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
storesSpeedGauge.WithLabelValues(storeAddress, storeLabel, action).Set(leftSeconds)
storesETAGauge.WithLabelValues(storeAddress, storeLabel, action).Set(currentSpeed)
storesSpeedGauge.WithLabelValues(storeAddress, storeLabel, action).Set(currentSpeed)
storesETAGauge.WithLabelValues(storeAddress, storeLabel, action).Set(leftSeconds)

okJiang added 2 commits June 11, 2024 17:21
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
// try regenerating operators
if foundDisabled {
region := s.cluster.GetRegion(op.RegionID())
if region == nil {
continue
Copy link
Member

Choose a reason for hiding this comment

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

I find that if the region == nil, do we still need to count it in ops?

Copy link
Member Author

@okJiang okJiang Jun 12, 2024

Choose a reason for hiding this comment

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

if i, data := l.rangeList.GetData(region.GetStartKey(), region.GetEndKey()); i != -1 {

seems it will be panic

Copy link
Member Author

Choose a reason for hiding this comment

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

267dc63

region == nil means the ops are not normal right now, so can just retry

@@ -201,39 +204,40 @@ func (m *Manager) GetProgresses(filter func(p string) bool) []string {
m.RLock()
defer m.RUnlock()

processes := []string{}
progresses := []string{}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
progresses := []string{}
progresses := make([]string, 0, len(m.progresses))

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed in c107129

@okJiang
Copy link
Member Author

okJiang commented Jun 14, 2024

Can you take a look again~ @rleungx @HuSharp @JmPotato

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 14, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 14, 2024
Copy link
Contributor

ti-chi-bot bot commented Jun 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JmPotato, rleungx

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

Copy link
Contributor

ti-chi-bot bot commented Jun 14, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-14 06:14:55.417063803 +0000 UTC m=+704449.470375723: ☑️ agreed by rleungx.
  • 2024-06-14 06:24:06.859579548 +0000 UTC m=+705000.912891469: ☑️ agreed by JmPotato.

@JmPotato
Copy link
Member

/merge

Copy link
Contributor

ti-chi-bot bot commented Jun 14, 2024

@JmPotato: We have migrated to builtin LGTM and approve plugins for reviewing.

👉 Please use /approve when you want approve this pull request.

The changes announcement: Proposal: Strengthen configuration change approval.

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot merged commit f1e85de into tikv:master Jun 14, 2024
16 checks passed
@okJiang okJiang deleted the refine branch June 14, 2024 08: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. 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.

4 participants