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

infoschema: add information_schema.tidb_cluster_info to retrieve cluster topology. #13035

Merged
merged 10 commits into from
Nov 4, 2019
Merged

Conversation

lonng
Copy link
Contributor

@lonng lonng commented Oct 30, 2019

Signed-off-by: Lonng heng@lonng.org

What problem does this PR solve?

In the current version, we don't have a simple way to get cluster information. We need to use different interfaces of different components or even different ways to get topology information.

What is changed and how it works?

This PR introduces the information_schema.tidb_cluster_info and make the user can retrieve cluster topology easier via select * from information_schema.tidb_cluster_info.

Check List

Tests

  • Unit test
  • Manual test
+------+------+--------+-----------------+-----------------+-----------------------------------------+------------------------------------------+
| ID   | TYPE | NAME   | ADDRESS         | STATUS_ADDRESS  | VERSION                                 | GIT_HASH                                 |
+------+------+--------+-----------------+-----------------+-----------------------------------------+------------------------------------------+
|    1 | tidb | tidb-0 | 127.0.0.1:4000  | 127.0.0.1:10080 | 5.7.25-TiDB-v4.0.0-alpha-666-g5b4111881 | 5b4111881ec4a693fdb417e415e4d87df4ed067e |
|    2 | pd   | pd-0   | 127.0.0.1:2379  | 127.0.0.1:2379  | 4.0.0-alpha                             | 8b2225d417f0991c3b11c09d2a2f7b6742e0ca78 |
|    3 | tikv | tikv-0 | 127.0.0.1:20160 | 127.0.0.1:20180 | 4.0.0-alpha                             | 48ac29e3c2302bd75cf2784f4c2f26ff5034db56 |
+------+------+--------+-----------------+-----------------+-----------------------------------------+------------------------------------------+

Release note

  • [feature] Add support for retrieving cluster topology via select * from information_schema.tidb_cluster_info

…ter topology.

Signed-off-by: Lonng <heng@lonng.org>
Signed-off-by: Lonng <heng@lonng.org>
Signed-off-by: Lonng <heng@lonng.org>
@lonng lonng requested a review from crazycs520 October 31, 2019 03:05
@codecov
Copy link

codecov bot commented Oct 31, 2019

Codecov Report

Merging #13035 into master will decrease coverage by 0.2024%.
The diff coverage is 80%.

@@               Coverage Diff                @@
##             master     #13035        +/-   ##
================================================
- Coverage   80.2271%   80.0246%   -0.2025%     
================================================
  Files           468        468                
  Lines        111208     110146      -1062     
================================================
- Hits          89219      88144      -1075     
- Misses        15212      15217         +5     
- Partials       6777       6785         +8

infoschema/tables.go Outdated Show resolved Hide resolved
infoschema/tables.go Outdated Show resolved Hide resolved
infoschema/tables.go Outdated Show resolved Hide resolved
infoschema/tables.go Outdated Show resolved Hide resolved
infoschema/tables.go Outdated Show resolved Hide resolved
if err != nil {
return nil, errors.Trace(err)
}
terror.Log(resp.Body.Close())
Copy link
Contributor

@djshow832 djshow832 Nov 1, 2019

Choose a reason for hiding this comment

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

In this way, it always calls an extra function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

terror.Log it a utility function equals if err != nil {...}.

Signed-off-by: Lonng <heng@lonng.org>
Signed-off-by: Lonng <heng@lonng.org>
Signed-off-by: Lonng <heng@lonng.org>
@djshow832
Copy link
Contributor

LGTM

@djshow832 djshow832 added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 4, 2019

// Get PD git_hash
url = fmt.Sprintf("http://%s%s", addr, pdapi.Status)
resp, err = http.Get(url)
Copy link
Contributor

Choose a reason for hiding this comment

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

The request will always handle by PD leader, should also change PD?
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, seems PD should not redirect all request to leader.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: Lonng <heng@lonng.org>
Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

LGTM

@lonng
Copy link
Contributor Author

lonng commented Nov 4, 2019

/merge

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

/run-all-tests

1 similar comment
@sre-bot
Copy link
Contributor

sre-bot commented Nov 4, 2019

/run-all-tests

@lonng lonng added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 4, 2019
@sre-bot sre-bot merged commit 6dfe2f2 into pingcap:master Nov 4, 2019
@lonng lonng deleted the cluster-info branch November 4, 2019 06:25
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/server 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.

5 participants