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

scheduler: add disable to independent config #8567

Merged
merged 11 commits into from
Sep 18, 2024

Conversation

okJiang
Copy link
Member

@okJiang okJiang commented Aug 23, 2024

What problem does this PR solve?

Issue Number: Ref #8474

Before deprecating scheduler-v2, we need to save the disable field of the default scheduler to the etcd xxxx/scheduler_config path. This pr does not modify the use of disable. disable only is added to/deleted from the storage. So it will not affect the existing logic.

What is changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has persistent data change

Release note

None.

Signed-off-by: okJiang <819421878@qq.com>
Copy link
Contributor

ti-chi-bot bot commented Aug 23, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has signed the dco. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 23, 2024
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 93.50649% with 10 lines in your changes missing coverage. Please review.

Project coverage is 77.65%. Comparing base (71f6f96) to head (456bd02).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8567      +/-   ##
==========================================
+ Coverage   77.57%   77.65%   +0.07%     
==========================================
  Files         474      474              
  Lines       62033    62094      +61     
==========================================
+ Hits        48122    48218      +96     
+ Misses      10355    10334      -21     
+ Partials     3556     3542      -14     
Flag Coverage Δ
unittests 77.65% <93.50%> (+0.07%) ⬆️

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

@okJiang okJiang marked this pull request as ready for review August 26, 2024 02:43
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 26, 2024
Signed-off-by: okJiang <819421878@qq.com>
@okJiang
Copy link
Member Author

okJiang commented Aug 26, 2024

/cc @rleungx @nolouch

@ti-chi-bot ti-chi-bot bot requested review from nolouch and rleungx August 26, 2024 03:07
Signed-off-by: okJiang <819421878@qq.com>
Comment on lines 543 to 546
// IsDiable implements the Scheduler interface.
func (l *balanceLeaderScheduler) IsDisable() bool {
return l.conf.isDisable()
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to implement it for every scheduler?

Copy link
Member Author

Choose a reason for hiding this comment

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

base_scheduler.go implemented it.

Copy link
Member

Choose a reason for hiding this comment

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

What I mean is can we implement this common function only once.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we want to implement it once, we need to put isDisable and setDisable into schedulerConfig interface. Do you think you need to do this?

Copy link
Member

Choose a reason for hiding this comment

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

WDYT? Is it possible that we might customize it?

Copy link
Member Author

Choose a reason for hiding this comment

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

In this pr, we only need to make a customized implementation for defaultScheduler. I think this is acceptable and only needs to be implemented four times.

If follow what you said, it does only need to be implemented once, but I feel that setDisable should not be placed in the schedulerConfig interface, because only defaultScheduler can be setDisabled. But if you insist, I can also modify it

@okJiang
Copy link
Member Author

okJiang commented Aug 29, 2024

ptal~ @rleungx @nolouch

@@ -52,8 +51,7 @@ const (
)

type balanceLeaderSchedulerConfig struct {
syncutil.RWMutex
schedulerConfig
baseDefaultSchedulerConfig
Copy link
Member

@rleungx rleungx Sep 3, 2024

Choose a reason for hiding this comment

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

I suggest moving Disabled here.

Copy link
Member Author

@okJiang okJiang Sep 4, 2024

Choose a reason for hiding this comment

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

If this, we need implement isDisable and setDisable four times.

Copy link
Member Author

Choose a reason for hiding this comment

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

friendly ping~

Copy link
Member

Choose a reason for hiding this comment

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

Just like other config?

func (*BaseScheduler) SetDisable(bool) error { return nil }

// IsDefault returns if the scheduler is a default scheduler.
func (*BaseScheduler) IsDefault() bool { return false }
Copy link
Contributor

@nolouch nolouch Sep 6, 2024

Choose a reason for hiding this comment

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

How about:

type hasDefaulSchedulerConfig interface {
  func IsDisable() bool
  func SetDisable(disabled bool) error
}

func (s *BaseScheduler) IsDefault() bool { 
    _, ok := s.conf.(hasDefaulSchedulerConfig)
    return ok
}

func (s *BaseScheduler) SetDisable(v bool) error {
  if c, ok := s.conf.(hasDefaulSchedulerConfig);ok {
     c.SetDisable(v)
  }
  return nil
}

func (*BaseScheduler) IsDisable() bool { 
    if c, ok := s.conf.(hasDefaulSchedulerConfig);ok {
          return c.IsDisable()
    }
     return false 
}

then no need to rewrite the interface for default scheduler.

Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
@@ -621,6 +621,7 @@ func (suite *schedulerTestSuite) checkHotRegionSchedulerConfig(cluster *pdTests.
"min-hot-key-rate": float64(10),
"min-hot-query-rate": float64(10),
"src-tolerance-ratio": 1.05,
"disabled": false,
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 allowed to be set through scheduler config xxx?

Copy link
Member Author

Choose a reason for hiding this comment

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

In current pr, it is allowed. Do we need mask it for users?

Copy link
Member

Choose a reason for hiding this comment

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

I prefer to make it only for internal use purpose.

Copy link
Member Author

Choose a reason for hiding this comment

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

Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
Copy link
Contributor

ti-chi-bot bot commented Sep 14, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-09 07:01:07.417205442 +0000 UTC m=+253337.157629381: ☑️ agreed by nolouch.
  • 2024-09-14 07:35:11.160052335 +0000 UTC m=+687380.900476259: ☑️ agreed by rleungx.

Copy link
Contributor

ti-chi-bot bot commented Sep 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: niubell, nolouch, 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

@ti-chi-bot ti-chi-bot bot added the approved label Sep 18, 2024
@ti-chi-bot ti-chi-bot bot merged commit 23d544f into tikv:master Sep 18, 2024
25 checks passed
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/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.

4 participants