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 server and mcs #5933

Merged
merged 15 commits into from
Feb 10, 2023

Conversation

lhy1024
Copy link
Contributor

@lhy1024 lhy1024 commented Feb 7, 2023

Signed-off-by: lhy1024 admin@liudos.us

What problem does this PR solve?

Issue Number: Ref #5837

What is changed and how does it work?

  1. move APIServiceGroup to apiutil
  2. replace server with basic_server in mcs
  3. remove init of mcs in main.go

Check List

Tests

  • Unit test
  • Integration test

Release note

 None.

Signed-off-by: lhy1024 <admin@liudos.us>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 7, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • nolouch
  • rleungx

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 release-note-none Denotes a PR that doesn't merit a release note. label Feb 7, 2023
@lhy1024
Copy link
Contributor Author

lhy1024 commented Feb 7, 2023

cc @rleungx @binshi-bing

return dummyServiceRegistry{}
}

type dummyServiceRegistry struct{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer need dummy

@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Base: 75.22% // Head: 75.11% // Decreases project coverage by -0.11% ⚠️

Coverage data is based on head (c80a2a5) compared to base (2be26ff).
Patch coverage: 88.09% of modified lines in pull request are covered.

❗ Current head c80a2a5 differs from pull request most recent head f526604. Consider uploading reports for the commit f526604 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5933      +/-   ##
==========================================
- Coverage   75.22%   75.11%   -0.11%     
==========================================
  Files         362      362              
  Lines       36221    36232      +11     
==========================================
- Hits        27247    27217      -30     
- Misses       6600     6634      +34     
- Partials     2374     2381       +7     
Flag Coverage Δ
unittests 75.11% <88.09%> (-0.11%) ⬇️

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

Impacted Files Coverage Δ
pkg/autoscaling/service.go 100.00% <ø> (ø)
pkg/dashboard/dashboard.go 90.00% <ø> (ø)
pkg/mcs/registry/registry.go 68.00% <ø> (-2.38%) ⬇️
pkg/mcs/resource_manager/server/manager.go 85.61% <ø> (ø)
pkg/swaggerserver/swaggerserver.go 100.00% <ø> (ø)
pkg/utils/apiutil/serverapi/middleware.go 68.25% <ø> (ø)
server/apiv2/router.go 100.00% <ø> (ø)
pkg/mcs/resource_manager/server/grpc_service.go 68.60% <33.33%> (ø)
pkg/utils/apiutil/apiutil.go 69.62% <80.00%> (+1.29%) ⬆️
pkg/mcs/resource_manager/server/apis/v1/api.go 80.00% <100.00%> (ø)
... and 29 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.

@lhy1024 lhy1024 added the type/refactor The issue belongs to a refactor work. label Feb 7, 2023
Signed-off-by: lhy1024 <admin@liudos.us>
@@ -22,7 +21,7 @@ import (
"net/http"

"github.com/pingcap/log"
"github.com/tikv/pd/server"
bs "github.com/tikv/pd/pkg/basic_server"
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
bs "github.com/tikv/pd/pkg/basic_server"
bs "github.com/tikv/pd/pkg/basicserver"

Copy link
Contributor

Choose a reason for hiding this comment

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

how about basicsvr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also think basicserver is better than basicsvr

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.

reverted invalid comment

@ti-chi-bot
Copy link
Member

@binshi-bing: Request changes is only allowed for the reviewers in list.

In response to this:

This pr seems to split from #5858. Regarding this pr, I have the same ask in #5858 and pasted below:

@lhy1024 , could you please split the common part (e.g., move APIServiceGroup from server to pkg/utils/apiutil, registry refactor) required by other services, into a separate pr and check in first. The common part in this pr, including the way to parse subcommand as discussed, and tso mcs have higher priority than resource manager mcs. In this way, we can both work on tso mcs and resource manager mcs more efficiently.

cc @rleungx

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.

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.

This pr seems to split from #5858. Regarding this pr, I have the same ask in #5858 and pasted below:

@lhy1024 , thanks for spliting the common part (e.g., move APIServiceGroup from server to pkg/utils/apiutil, registry refactor) required by other services, from #5833 into this separate pr. They have higher priority than the remaining part in the original pr (mainly resource manager mcs related). Could you merge this one earlier so that we can both work on tso mcs and resource manager mcs more efficiently.

@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:

This pr seems to split from #5858. Regarding this pr, I have the same ask in #5858 and pasted below:

@lhy1024 , thanks for spliting the common part (e.g., move APIServiceGroup from server to pkg/utils/apiutil, registry refactor) required by other services, from #5833 into this separate pr. They have higher priority than the remaining part in the original pr (mainly resource manager mcs related). Could you merge this one earlier so that we can both work on tso mcs and resource manager mcs more efficiently.

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.

// GetMember returns the member information.
GetMember() *member.Member
// AddLeaderCallback adds a callback in the leader campaign phase.
AddLeaderCallback(callbacks ...func(context.Context))
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 need to put this API into basicserver.Server? This API means that this server will elect for leader, correct? It doesn't sound a must-havior behavior of a basic server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also consider to replace it with primary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add todo

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 8, 2023
@lhy1024
Copy link
Contributor Author

lhy1024 commented Feb 9, 2023

This pr seems to split from #5858. Regarding this pr, I have the same ask in #5858 and pasted below:

@lhy1024 , thanks for spliting the common part (e.g., move APIServiceGroup from server to pkg/utils/apiutil, registry refactor) required by other services, from #5833 into this separate pr. They have higher priority than the remaining part in the original pr (mainly resource manager mcs related). Could you merge this one earlier so that we can both work on tso mcs and resource manager mcs more efficiently.

In master branch, resource management is imported by install, which means it will always start however service mode. So we need to change it for tso mode.

Signed-off-by: lhy1024 <admin@liudos.us>

Conflicts:
	cmd/pd-server/main.go
	pkg/mcs/tso/server/server.go
	server/server.go
Signed-off-by: lhy1024 <admin@liudos.us>

Conflicts:
	cmd/pd-server/main.go
	pkg/mcs/tso/server/server.go
	server/server.go
Signed-off-by: lhy1024 <admin@liudos.us>
@lhy1024 lhy1024 removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 9, 2023
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
@rleungx
Copy link
Member

rleungx commented Feb 10, 2023

Please change the file back to 100644

Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 10, 2023
@@ -97,9 +97,3 @@ func (r *ServiceRegistry) InstallAllRESTHandler(srv *server.Server, h map[string
func (r ServiceRegistry) RegisterService(name string, service ServiceBuilder) {
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 turn RegisterService func to pointer receivers
func (r *ServiceRegistry) RegisterService?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: lhy1024 <admin@liudos.us>
@@ -137,3 +140,21 @@ func MustWaitLeader(re *require.Assertions, svrs []*Server) *Server {
})
return leader
}

// CreateMokHandler creates a mock handler for test.
func CreateMokHandler(re *require.Assertions, ip string) HandlerBuilder {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why it was called mok before, is mock written wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

server_test.go and func CreateMokHandler also has some legacy mok

Copy link
Contributor

Choose a reason for hiding this comment

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

ptal @lhy1024

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replace name in url

Signed-off-by: lhy1024 <admin@liudos.us>
@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 Feb 10, 2023
Signed-off-by: lhy1024 <admin@liudos.us>
@disksing
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

@disksing: 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: f526604

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 10, 2023
@ti-chi-bot ti-chi-bot merged commit 60e4594 into tikv:master Feb 10, 2023
@lhy1024 lhy1024 deleted the decouple branch February 10, 2023 12:06
nolouch pushed a commit to nolouch/pd that referenced this pull request Feb 24, 2023
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. type/refactor The issue belongs to a refactor work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants