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

resource_manager: add service mode server #5994

Merged
merged 28 commits into from
Feb 21, 2023
Merged

Conversation

lhy1024
Copy link
Contributor

@lhy1024 lhy1024 commented Feb 15, 2023

What problem does this PR solve?

Issue Number: Ref #5837

What is changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • manual test
    ./bin/pd-server service resource_manager --backend-endpoints="http://127.0.0.1:35207"
    4f6c9e64-4d9a-477e-9fea-acafb63b2f11

Release note

None.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 15, 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 do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Feb 15, 2023
@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

@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Base: 75.03% // Head: 74.77% // Decreases project coverage by -0.26% ⚠️

Coverage data is based on head (a94eaab) compared to base (31bf4bc).
Patch coverage: 34.82% of modified lines in pull request are covered.

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5994      +/-   ##
==========================================
- Coverage   75.03%   74.77%   -0.26%     
==========================================
  Files         363      365       +2     
  Lines       36339    36552     +213     
==========================================
+ Hits        27266    27331      +65     
- Misses       6687     6820     +133     
- Partials     2386     2401      +15     
Flag Coverage Δ
unittests 74.77% <34.82%> (-0.26%) ⬇️

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

Impacted Files Coverage Δ
client/resource_manager_client.go 66.84% <0.00%> (ø)
pkg/mcs/resource_manager/server/grpc_service.go 68.60% <0.00%> (ø)
pkg/mcs/resource_manager/server/config.go 1.69% <1.69%> (ø)
pkg/mcs/resource_manager/server/server.go 48.05% <48.05%> (ø)
pkg/mcs/resource_manager/server/manager.go 79.73% <100.00%> (-0.79%) ⬇️
server/server.go 73.99% <100.00%> (-0.23%) ⬇️
pkg/errs/errs.go 75.00% <0.00%> (-25.00%) ⬇️
pkg/dashboard/adapter/manager.go 71.26% <0.00%> (-8.05%) ⬇️
server/schedulers/shuffle_hot_region.go 56.66% <0.00%> (-3.34%) ⬇️
server/schedule/labeler/rules.go 87.50% <0.00%> (-2.28%) ⬇️
... and 13 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
Copy link
Member

rleungx commented Feb 16, 2023

Could you please add some simple tests to validate it works?

server/server.go Show resolved Hide resolved
server/server.go Outdated Show resolved Hide resolved
pkg/mcs/resource_manager/server/server.go Outdated Show resolved Hide resolved
pkg/mcs/resource_manager/server/server.go Show resolved Hide resolved
pkg/mcs/resource_manager/server/server.go Outdated Show resolved Hide resolved
pkg/mcs/resource_manager/server/server.go Outdated Show resolved Hide resolved
pkg/mcs/resource_manager/server/server.go Outdated Show resolved Hide resolved
pkg/mcs/resource_manager/server/server.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/needs-linked-issue release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Feb 16, 2023
Signed-off-by: lhy1024 <admin@liudos.us>
@lhy1024 lhy1024 marked this pull request as ready for review February 16, 2023 14:10
@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 16, 2023
@lhy1024 lhy1024 requested a review from rleungx February 16, 2023 14:10
@lhy1024
Copy link
Contributor Author

lhy1024 commented Feb 16, 2023

cc @rleungx @binshi-bing

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>
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.

left some comments

}
// Server has started.
atomic.StoreInt64(&s.isServing, 1)
return mux.Serve()
Copy link
Contributor

Choose a reason for hiding this comment

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

if mux.Serve is a blocking call, we might have a bigger issue. It means it won't stay on <-ctx.Done to wait for the exit signals. if a signal is raised, svr.Run() won't return unless network listener is closed but it mightn't.

var sig os.Signal
go func() {
	sig = <-sc
	cancel()
}()

if err := svr.Run(); err != nil {
	log.Fatal("run server failed", errs.ZapError(err))
}

<-ctx.Done()

pkg/mcs/resource_manager/server/server.go Outdated Show resolved Hide resolved
}

s.grpcServer = grpc.NewServer()
s.service.RegisterGRPCService(s.grpcServer)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that we should support gPRC Gateway. By default, EnableGRPCGateway is true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where will we use it?

pkg/mcs/resource_manager/server/server.go Show resolved Hide resolved
}
// Server has started.
atomic.StoreInt64(&s.isServing, 1)
return mux.Serve()
Copy link
Contributor

Choose a reason for hiding this comment

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

Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
pkg/mcs/resource_manager/server/config.go Outdated Show resolved Hide resolved
pkg/mcs/resource_manager/server/config.go Outdated Show resolved Hide resolved
BackendEndpoints string `toml:"backend-endpoints" json:"backend-endpoints"`
ListenAddr string `toml:"listen-addr" json:"listen-addr"`
Name string `toml:"name" json:"name"`
DataDir string `toml:"data-dir" json:"data-dir"`
Copy link
Member

Choose a reason for hiding this comment

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

What is DataDir used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

L162 log path?

Copy link
Member

Choose a reason for hiding this comment

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

Log.File.Filename does the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will do in another pr

pkg/mcs/resource_manager/server/server.go Outdated Show resolved Hide resolved
s.service.RegisterGRPCService(gs)
err := gs.Serve(l)
if err != cmux.ErrListenerClosed {
log.Fatal("grpc server stops serving unexpectedly.", errs.ZapError(err))
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
log.Fatal("grpc server stops serving unexpectedly.", errs.ZapError(err))
log.Fatal("grpc server stops serving unexpectedly", errs.ZapError(err))

Copy link
Member

Choose a reason for hiding this comment

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

Suggest removing all periods in log

Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
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 the status/LGT1 Indicates that a PR has LGTM 1. label Feb 21, 2023
Signed-off-by: lhy1024 <admin@liudos.us>
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.

Copy link
Member

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

pkg/mcs/resource_manager/server/server.go Outdated Show resolved Hide resolved
pkg/mcs/resource_manager/server/server.go Outdated Show resolved Hide resolved
@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 21, 2023
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
@lhy1024
Copy link
Contributor Author

lhy1024 commented Feb 21, 2023

/merge

@ti-chi-bot
Copy link
Member

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

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 21, 2023
@ti-chi-bot ti-chi-bot merged commit 71f776f into tikv:master Feb 21, 2023
nolouch pushed a commit to nolouch/pd that referenced this pull request Feb 24, 2023
ref tikv#5837

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

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Conflicts:
	go.mod
	pkg/mcs/tso/server/server.go
	tests/client/go.sum
	tests/mcs/go.sum
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