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

*: decouple the dependency between config and schedule #5792

Merged
merged 7 commits into from
Mar 3, 2023

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Dec 16, 2022

What problem does this PR solve?

Issue Number: Ref #5838.

What is changed and how does it work?

Check List

Tests

  • Unit test

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Dec 16, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • HunDunDM
  • nolouch

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 do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. labels Dec 16, 2022
@codecov
Copy link

codecov bot commented Dec 16, 2022

Codecov Report

Patch coverage: 87.61% and project coverage change: -0.12 ⚠️

Comparison is base (6fa2bc9) 74.10% compared to head (988bdcb) 73.99%.

❗ Current head 988bdcb differs from pull request most recent head 5c17fd4. Consider uploading reports for the commit 5c17fd4 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5792      +/-   ##
==========================================
- Coverage   74.10%   73.99%   -0.12%     
==========================================
  Files         381      383       +2     
  Lines       37809    37808       -1     
==========================================
- Hits        28020    27975      -45     
- Misses       7335     7365      +30     
- Partials     2454     2468      +14     
Flag Coverage Δ
unittests 73.99% <87.61%> (-0.12%) ⬇️

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

Impacted Files Coverage Δ
pkg/mock/mockcluster/mockcluster.go 94.25% <ø> (ø)
server/api/scheduler.go 40.48% <ø> (ø)
server/cluster/diagnostic_manager.go 76.34% <ø> (ø)
server/config/config.go 75.92% <ø> (-0.11%) ⬇️
server/config/util.go 82.60% <ø> (-4.06%) ⬇️
server/handler.go 52.78% <ø> (ø)
server/schedule/filter/healthy.go 90.00% <ø> (ø)
server/schedule/operator/builder.go 86.27% <ø> (ø)
server/schedule/scheduler.go 55.26% <ø> (ø)
server/schedule/schedulers/balance_plan.go 86.48% <ø> (ø)
... and 73 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

}

// Config is the interface that wraps the Config related method.
type Config interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Each scheduler also has it's own config, How to distinguish them?

Copy link
Member Author

Choose a reason for hiding this comment

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

A config instance that implements these interfaces can be used to start the scheduling services. And this interface is used for compatibility. As for the scheduler config, it doesn't rely on the server package so it can be defined without implementing this interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can reduce the functions.

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 22, 2022
Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

}

// Config is the interface that wraps the Config related method.
type Config interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can reduce the functions.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 26, 2022
@@ -995,11 +995,6 @@ func (c *ScheduleConfig) Validate() error {
if c.LeaderSchedulePolicy != "count" && c.LeaderSchedulePolicy != "size" {
return errors.Errorf("leader-schedule-policy %v is invalid", c.LeaderSchedulePolicy)
}
for _, scheduleConfig := range c.Schedulers {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.

server/schedule/config/config.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 30, 2022
@rleungx
Copy link
Member Author

rleungx commented Jan 3, 2023

@binshi-bing

@@ -32,6 +32,7 @@ import (
"github.com/tikv/pd/server/config"
"github.com/tikv/pd/server/core"
"github.com/tikv/pd/server/core/storelimit"
sc "github.com/tikv/pd/server/schedule/config"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we favor short name over a full name? 'sc' could be read as store config? "scheduleConfig" seems to be a clearer name to me.

@@ -219,6 +233,14 @@ func (m *StoreConfigManager) GetStoreConfig() *StoreConfig {
return config.(*StoreConfig)
}

// SetStoreConfig sets the store configuration.
func (m *StoreConfigManager) SetStoreConfig(cfg *StoreConfig) {
if m == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

if m != nil {
m.config.Store(cfg)
}

@@ -120,6 +120,14 @@ func (c *StoreConfig) IsEnableRegionBucket() bool {
return c.Coprocessor.EnableRegionBucket
}

// SetRegionBucketEnabled sets if the region bucket is enabled.
func (c *StoreConfig) SetRegionBucketEnabled(enabled bool) {
if c == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

if c != nil {
c.Coprocessor.EnableRegionBucket = enabled
}

var schedulerMap sync.Map

// RegisterScheduler registers the scheduler type.
func RegisterScheduler(typ string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

'type' is a reserved keyword, but I'm wondering if we can use a better name than 'typ'? how about schedulerType?

}

// Config is the interface that wraps the Config related methods.
type Config interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel this part is hard to maintain and is error-prone in the future. Just wondering if we can reuse ScheduleConfig in server/config/config.go and move it to server/scheduler to remove dependency. It seems that we want to remove the dependency (on server/config) from server/scheduler, but I'm sure if we can let server/config depend on server/scheduler/config. I mightn't fully understand our work here. I'll sync with you two after holiday. @rleungx @nolouch ^

Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 2, 2023
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Copy link
Contributor

@binshi-bing binshi-bing 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
Copy link
Member

@binshi-bing: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

LGTM

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 added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 2, 2023
@rleungx
Copy link
Member Author

rleungx commented Mar 3, 2023

/run-all-tests

@rleungx rleungx closed this Mar 3, 2023
@rleungx rleungx reopened this Mar 3, 2023
@rleungx
Copy link
Member Author

rleungx commented Mar 3, 2023

/merge

@ti-chi-bot
Copy link
Member

@rleungx: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

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
Copy link
Member

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

Commit hash: 4509a2c

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 3, 2023
@ti-chi-bot
Copy link
Member

@rleungx: Your PR was out of date, I have automatically updated it for you.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 merged commit 05228ba into tikv:master Mar 3, 2023
@rleungx rleungx deleted the schedule-config branch March 3, 2023 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants