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

http_*: add a HTTP API to list changefeed info #1917

Merged
merged 28 commits into from
Jun 5, 2021

Conversation

asddongmen
Copy link
Contributor

@asddongmen asddongmen commented Jun 2, 2021

What problem does this PR solve?

#1869

What is changed and how it works?

Add a HTTP API to list changefeed info.
Add a HTTP API to check the health of CDC server. (It only return a response with 200 OK and empty body.)

Check List

Tests

  • Manual test (add detailed scripts or steps below)
  1. list default changefeeds
$ curl -X GET http://127.0.0.1:8300/api/v1/changefeeds
[
 {
  "id": "changefeed-test-1",
  "state": "normal",
  "tso": 425364256174112775,
  "checkpoint": "2021-06-02 20:11:04.922",
  "error": null
 },
 {
  "id": "test1",
  "state": "normal",
  "tso": 425364256174112775,
  "checkpoint": "2021-06-02 20:11:04.922",
  "error": null
 }
]
  1. list all changefeeds.
$ curl -X GET http://127.0.0.1:8300/api/v1/changefeeds?state=all
[
 {
  "id": "changefeed-test-1",
  "state": "normal",
  "tso": 425364263569195009,
  "checkpoint": "2021-06-02 20:11:33.132",
  "error": null
 },
 {
  "id": "test1",
  "state": "normal",
  "tso": 425364263569195009,
  "checkpoint": "2021-06-02 20:11:33.132",
  "error": null
 },
 {
  "id": "test2",
  "state": "removed",
  "tso": 425364254063853571,
  "checkpoint": "2021-06-02 20:10:56.872",
  "error": null
 }
]
  1. list normal / stopped / removed changefeed
$ curl -X GET http://127.0.0.1:8300/api/v1/changefeeds?state=normal

[
 {
  "id": "test1",
  "state": "normal",
  "checkpoint-tso": 425413530255884289,
  "checkpoint-time": "2021-06-05 00:23:50.627",
  "error": null
 },
 {
  "id": "test2",
  "state": "normal",
  "checkpoint-tso": 425413530255884289,
  "checkpoint-time": "2021-06-05 00:23:50.627",
  "error": null
 }
]

$ curl -X GET http://127.0.0.1:8300/api/v1/changefeeds?state=stopped

[
 {
  "id": "test4",
  "state": "stopped",
  "checkpoint-tso": 425412960562708481,
  "checkpoint-time": "2021-06-04 23:47:37.420",
  "error": null
 }
]

$ curl -X GET http://127.0.0.1:8300/api/v1/changefeeds?state=removed

[
 {
  "id": "test3",
  "state": "removed",
  "checkpoint-tso": 425412963750903809,
  "checkpoint-time": "2021-06-04 23:47:49.582",
  "error": null
 }
  1. test POST method
$ curl -POST http://127.0.0.1:8300/api/v1/changefeeds

{
 "error": "this api supports GET method only",
 "errorCode": "CDC:ErrSupportGetOnly"
}
  1. check health of CDC server
$ curl -I -X GET  http://127.0.0.1:8300/api/v1/health

HTTP/1.1 200 OK
Date: Fri, 04 Jun 2021 04:05:56 GMT
Content-Length: 0

Code changes

  • Has exported function/method change

Side effects

  • None

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release note

  • No release note

@ti-chi-bot ti-chi-bot requested review from zier-one and overvenus June 2, 2021 12:12
@asddongmen asddongmen added the status/ptal Could you please take a look? label Jun 2, 2021
@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 2, 2021
@asddongmen asddongmen added the needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. label Jun 2, 2021
@asddongmen
Copy link
Contributor Author

I will fix the failed tests as soon as possible

@asddongmen asddongmen removed the request for review from overvenus June 2, 2021 12:52
cdc/http_handler.go Outdated Show resolved Hide resolved
cdc/http_handler.go Outdated Show resolved Hide resolved
cdc/http_handler.go Outdated Show resolved Hide resolved
cdc/http_handler.go Outdated Show resolved Hide resolved
cdc/http_handler.go Outdated Show resolved Hide resolved
cdc/http_handler.go Outdated Show resolved Hide resolved
cdc/http_status.go Outdated Show resolved Hide resolved
cdc/http_status.go Outdated Show resolved Hide resolved
cdc/http_handler.go Outdated Show resolved Hide resolved
cdc/http_status_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@3AceShowHand 3AceShowHand 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 it would be better put in a new file

@asddongmen
Copy link
Contributor Author

/run-unit-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.

rest LGTM

cdc/http_api_handler.go Outdated Show resolved Hide resolved
pkg/httputil/httputil.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 5, 2021
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 👍

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • liuzix
  • overvenus

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 status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 5, 2021
@overvenus
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 42a2518

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 5, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #1917 (e1867df) into master (a1067a0) will increase coverage by 0.2406%.
The diff coverage is 66.0818%.

@@               Coverage Diff                @@
##             master      #1917        +/-   ##
================================================
+ Coverage   53.8503%   54.0910%   +0.2406%     
================================================
  Files           155        164         +9     
  Lines         16479      17404       +925     
================================================
+ Hits           8874       9414       +540     
- Misses         6655       6985       +330     
- Partials        950       1005        +55     

@ti-chi-bot ti-chi-bot merged commit 90116b2 into pingcap:master Jun 5, 2021
ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Jun 5, 2021
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #1955.

@overvenus overvenus added the needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. label Jun 10, 2021
@overvenus
Copy link
Member

/run-cherry-picker

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Jun 10, 2021
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #2022.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. status/ptal Could you please take a look?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants