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

placement: add API support #1894

Merged
merged 12 commits into from
Nov 6, 2019
Merged

placement: add API support #1894

merged 12 commits into from
Nov 6, 2019

Conversation

disksing
Copy link
Contributor

@disksing disksing commented Nov 5, 2019

What problem does this PR solve?

continue merge placement rules.

What is changed and how it works?

  • add api support
  • add raml document

Check List

Tests

  • Manual test (add detailed scripts or steps below)

Code changes

  • Has HTTP API interfaces change

Signed-off-by: disksing <i@disksing.com>
Signed-off-by: disksing <i@disksing.com>
Signed-off-by: disksing <i@disksing.com>
Signed-off-by: disksing <i@disksing.com>
@disksing disksing added the component/schedule Scheduling logic. label Nov 5, 2019
@codecov-io
Copy link

codecov-io commented Nov 5, 2019

Codecov Report

Merging #1894 into master will decrease coverage by 0.75%.
The diff coverage is 9.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1894      +/-   ##
==========================================
- Coverage   78.08%   77.32%   -0.76%     
==========================================
  Files         163      164       +1     
  Lines       16338    16468     +130     
==========================================
- Hits        12757    12734      -23     
- Misses       2583     2725     +142     
- Partials      998     1009      +11
Impacted Files Coverage Δ
server/api/router.go 100% <100%> (ø) ⬆️
server/api/rule.go 3.27% <3.27%> (ø)
server/kv/etcd_kv.go 72.72% <0%> (-11.69%) ⬇️
server/region_syncer/client.go 68.42% <0%> (-10.53%) ⬇️
server/tso/tso.go 76.11% <0%> (-3.74%) ⬇️
server/schedulers/shuffle_hot_region.go 60.86% <0%> (-2.18%) ⬇️
server/server.go 82.43% <0%> (-1.66%) ⬇️
client/client.go 68.8% <0%> (-1.29%) ⬇️
server/core/storage.go 74.85% <0%> (-1.2%) ⬇️
server/config/option.go 90.23% <0%> (-0.94%) ⬇️
... and 6 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 05dbc14...51fd74e. Read the comment docs.

@nolouch nolouch added the priority/P1 The issue has P1 priority. label Nov 5, 2019
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.

LGTM. do we need some tests to test these api?

@disksing
Copy link
Contributor Author

disksing commented Nov 5, 2019

@lhy1024 I think we need the test. But I don't have enough time to add it now..

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.

rest LGTM

return
}
if !cluster.IsPlacementRulesEnabled() {
h.rd.JSON(w, http.StatusPreconditionFailed, "placement rules feature is disabled")
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 defining an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea.

Copy link
Contributor

@shafreeck shafreeck left a comment

Choose a reason for hiding this comment

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

I think we could introduce the Middleware to reduce the duplicated code.

In ideal, we should define two middlewares, one for bootstrapping, another for placement rules. However, the bootstrapping middleware has no relationship with this PR, maybe we can combine these middlewares into single one first, and leave the TODOs to future refactoring or as PCP problem.

if !cluster.IsPlacementRulesEnabled() {
h.rd.JSON(w, http.StatusPreconditionFailed, placementDisabledErr.Error())
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It is really verbose of these lines of code. Maybe you want to try the middleware https://github.com/gorilla/mux#middleware

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'll see what I can do for now.

server/api/rule.go Outdated Show resolved Hide resolved
server/api/rule.go Outdated Show resolved Hide resolved
disksing and others added 2 commits November 6, 2019 17:03
Signed-off-by: disksing <i@disksing.com>

Co-Authored-By: Shafreeck Sea <shafreeck@users.noreply.github.com>
Signed-off-by: disksing <i@disksing.com>

Co-Authored-By: Shafreeck Sea <shafreeck@users.noreply.github.com>
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.

LGTM.

@nolouch nolouch added the status/can-merge Indicates a PR has been approved by a committer. label Nov 6, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Nov 6, 2019

/run-all-tests

@sre-bot sre-bot merged commit b7d614e into tikv:master Nov 6, 2019
@disksing disksing deleted the placement8 branch November 7, 2019 06:37
@disksing disksing mentioned this pull request Dec 13, 2019
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/schedule Scheduling logic. priority/P1 The issue has P1 priority. 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