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

tools: add component subcommand #2092

Merged
merged 22 commits into from
Feb 17, 2020
Merged

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Jan 9, 2020

What problem does this PR solve?

We need a way to support change the config of other components.

What is changed and how it works?

This PR adds a component subcommand to manipulate the config manager's configuration.

Check List

Tests

  • Unit test

@rleungx rleungx force-pushed the config-subcommand branch 2 times, most recently from 12ffe35 to ee3adb8 Compare February 5, 2020 09:04
@codecov-io
Copy link

codecov-io commented Feb 5, 2020

Codecov Report

Merging #2092 into master will decrease coverage by 0.71%.
The diff coverage is 33.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2092      +/-   ##
==========================================
- Coverage   76.68%   75.96%   -0.72%     
==========================================
  Files         191      195       +4     
  Lines       19902    20228     +326     
==========================================
+ Hits        15262    15367     +105     
- Misses       3475     3686     +211     
- Partials     1165     1175      +10
Impacted Files Coverage Δ
server/config/config.go 85.92% <ø> (ø) ⬆️
server/api/util.go 67.69% <ø> (ø) ⬆️
tools/pd-ctl/pdctl/command/global.go 68.46% <0%> (-3.23%) ⬇️
server/api/server.go 100% <100%> (ø) ⬆️
server/region_syncer/client.go 84.48% <100%> (+3.44%) ⬆️
client/base_client.go 84.82% <100%> (ø) ⬆️
pkg/dashboard/apiserver/apiserver.go 81.81% <100%> (ø)
tools/pd-ctl/pdctl/ctl.go 95% <100%> (+0.12%) ⬆️
tools/pd-ctl/pdctl/command/component_command.go 34.54% <34.54%> (ø)
server/api/router.go 81.42% <37.73%> (-17.83%) ⬇️
... and 23 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 23d632c...9dd25d5. Read the comment docs.

@rleungx rleungx added this to the v4.0.0-beta.1 milestone Feb 5, 2020
server/server.go Outdated Show resolved Hide resolved
server/api/router.go Outdated Show resolved Hide resolved
@NingLin-P
Copy link
Member

LGTM

@rleungx
Copy link
Member Author

rleungx commented Feb 10, 2020

/run-all-tests

Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

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

LGTM


type customMarshaler struct{}

func (c *customMarshaler) Marshal(v interface{}) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are they all empty implementations?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because we need to implement Marshaler interface here

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 nopMarshaler

tools/pd-ctl/pdctl/command/component_command.go Outdated Show resolved Hide resolved
client/base_client.go Show resolved Hide resolved
server/api/config_test.go Outdated Show resolved Hide resolved
tools/pd-ctl/pdctl/command/component_command.go Outdated Show resolved Hide resolved
tools/pd-ctl/pdctl/command/component_command.go Outdated Show resolved Hide resolved
}

func (m componentMiddleware) Middleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it is suitable to use middleware here. After all, the logic here is too complicated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Any better idea?

}

func (m componentMiddleware) Middleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it is suitable to use middleware here. After all, the logic here is too complicated.

Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>

type customMarshaler struct{}

func (c *customMarshaler) Marshal(v interface{}) ([]byte, error) {
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 nopMarshaler

@@ -34,7 +45,7 @@ func createIndentRender() *render.Render {
})
}

func createRouter(prefix string, svr *server.Server) *mux.Router {
func createRouter(ctx context.Context, prefix string, svr *server.Server) (*mux.Router, func()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add some comments to clarify what's the returned func() used for?

@@ -188,5 +199,77 @@ func createRouter(prefix string, svr *server.Server) *mux.Router {
// Deprecated
rootRouter.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {}).Methods("GET")

return rootRouter
if svr.GetConfig().EnableDynamicConfig {
f := func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems better define it separetly

Signed-off-by: Ryan Leung <[email protected]>
@rleungx
Copy link
Member Author

rleungx commented Feb 17, 2020

PTAL. @disksing

f := func() {
lazyComponentRouter(ctx, svr, apiRouter)
}
return rootRouter, f
Copy link
Contributor

Choose a reason for hiding this comment

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

return rootRouter, func(){lazyComponentRouter(ctx, svr, apiRouter)}

Signed-off-by: Ryan Leung <[email protected]>
@rleungx
Copy link
Member Author

rleungx commented Feb 17, 2020

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 17, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Feb 17, 2020

/run-all-tests

@sre-bot sre-bot merged commit 249b42d into tikv:master Feb 17, 2020
@rleungx rleungx mentioned this pull request Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants