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

pkg: support service discovery #5911

Merged
merged 3 commits into from
Feb 9, 2023
Merged

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Feb 6, 2023

Signed-off-by: Ryan Leung rleungx@gmail.com

What problem does this PR solve?

This PR supports service discovery for microservice architecture. The detailed usage can be found in the unit tests.

Issue Number: Ref #5895.

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 Feb 6, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lhy1024

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

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 added do-not-merge/needs-linked-issue release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Feb 6, 2023
@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-linked-issue labels Feb 6, 2023
@codecov
Copy link

codecov bot commented Feb 6, 2023

Codecov Report

Base: 75.38% // Head: 75.23% // Decreases project coverage by -0.15% ⚠️

Coverage data is based on head (a563136) compared to base (0b9395d).
Patch coverage: 59.25% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5911      +/-   ##
==========================================
- Coverage   75.38%   75.23%   -0.15%     
==========================================
  Files         359      362       +3     
  Lines       36167    36221      +54     
==========================================
- Hits        27265    27252      -13     
- Misses       6547     6600      +53     
- Partials     2355     2369      +14     
Flag Coverage Δ
unittests 75.23% <59.25%> (-0.15%) ⬇️

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

Impacted Files Coverage Δ
server/schedule/operator/builder.go 86.60% <ø> (+0.32%) ⬆️
pkg/mcs/discovery/register.go 53.48% <53.48%> (ø)
pkg/mcs/discovery/discover.go 77.77% <77.77%> (ø)
pkg/mcs/discovery/key_path.go 100.00% <100.00%> (ø)
pkg/utils/tempurl/tempurl.go 45.00% <0.00%> (-25.00%) ⬇️
...erver/config/service_middleware_persist_options.go 91.66% <0.00%> (-8.34%) ⬇️
pkg/dashboard/adapter/manager.go 79.31% <0.00%> (-6.90%) ⬇️
pkg/tso/local_allocator.go 71.62% <0.00%> (-6.76%) ⬇️
pkg/tso/allocator_manager.go 63.22% <0.00%> (-5.65%) ⬇️
pkg/election/leadership.go 75.25% <0.00%> (-2.07%) ⬇️
... and 16 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.

@rleungx rleungx marked this pull request as ready for review February 6, 2023 08:35
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 6, 2023
@rleungx
Copy link
Member Author

rleungx commented Feb 6, 2023

@binshi-bing PTAL

@@ -524,7 +524,7 @@ func (b *Builder) prepareBuild() (string, error) {
}

// Although switch witness may have nothing to do with conf change (except switch witness voter to non-witness voter:
Copy link
Contributor

Choose a reason for hiding this comment

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

switching

cancel: cancel,
cli: cli,
key: serviceKey,
value: serviceAddr,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we use range scan to discover, can we use "/pd/microserivce/{service name}/registry/{ip:port}" as the key, weight or a json, which contains host properties and starts with weight, as the value?

Copy link
Contributor

Choose a reason for hiding this comment

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

For more details of my comment, please see my comments in the design doc.

Copy link
Member Author

@rleungx rleungx Feb 7, 2023

Choose a reason for hiding this comment

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

I'm going to change the value to a string, which can be serialized by different services themselves.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good

)

// Discover is used to get all the service instances of the specified service name.
func Discover(cli *clientv3.Client, serviceName string) ([]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The design doc contains server register, service instance discovery and service discovery. This function is the second one. For tenant tso, in the third part "service discover", we need to get the server endpoint for a given key space group. Could you list which functionalities are provided by this PR? And we can implement the remaining functionalities in the next PRs.

Signed-off-by: Ryan Leung <rleungx@gmail.com>
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, though it isn't counted

@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, though it isn't counted

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

@lhy1024 lhy1024 left a comment

Choose a reason for hiding this comment

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

the rest LGTM

registryKey = "registry"
)

func registryPath(serviceName, serviceAddr string) string {
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 tenant now?

Copy link
Contributor

Choose a reason for hiding this comment

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

service instance (node) registry path doesn't contain tenant/keyspace. The tenant/keyspace group primary discovery path does.

@rleungx rleungx requested a review from lhy1024 February 9, 2023 04:50
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 9, 2023
@rleungx
Copy link
Member Author

rleungx commented Feb 9, 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

@rleungx: /merge in this pull request requires 2 approval(s).

In response to this:

/merge

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.

@rleungx rleungx added the require-LGT1 Indicates that the PR requires an LGTM. label Feb 9, 2023
@rleungx
Copy link
Member Author

rleungx commented Feb 9, 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: 1067533

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 9, 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 2be26ff into tikv:master Feb 9, 2023
@rleungx rleungx deleted the service-discovery branch February 10, 2023 02:04
@rleungx rleungx mentioned this pull request Mar 3, 2023
3 tasks
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. require-LGT1 Indicates that the PR requires an LGTM. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants