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

*: update cluster_id to a global variable #8615

Merged
merged 20 commits into from
Oct 29, 2024
Merged

Conversation

okJiang
Copy link
Member

@okJiang okJiang commented Sep 11, 2024

What problem does this PR solve?

Issue Number: Close #8588

What is changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

Copy link
Contributor

ti-chi-bot bot commented Sep 11, 2024

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

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has signed the dco. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 11, 2024
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
Signed-off-by: okJiang <[email protected]>
Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 55.50847% with 210 lines in your changes missing coverage. Please review.

Project coverage is 75.53%. Comparing base (20087e2) to head (75d6e81).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8615      +/-   ##
==========================================
- Coverage   75.61%   75.53%   -0.09%     
==========================================
  Files         460      461       +1     
  Lines       72135    72144       +9     
==========================================
- Hits        54543    54492      -51     
- Misses      14104    14149      +45     
- Partials     3488     3503      +15     
Flag Coverage Δ
unittests 75.53% <55.50%> (-0.09%) ⬇️

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

@okJiang okJiang marked this pull request as ready for review September 12, 2024 03:22
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 12, 2024
@@ -156,25 +156,6 @@ func TestEtcdKVPutWithTTL(t *testing.T) {
re.Equal(int64(0), resp.Count)
}

func TestInitClusterID(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to add a similiar test in utils/keypath?

Copy link
Member Author

@okJiang okJiang Sep 13, 2024

Choose a reason for hiding this comment

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

It has been move to pkg/storage/endpoint/cluster_id_test.go. The path can be discussed.

@@ -62,7 +62,6 @@ func TestSimpleJoin(t *testing.T) {
members, err = etcdutil.ListEtcdMembers(ctx, client)
re.NoError(err)
re.Len(members.Members, 2)
re.Equal(pd1.GetClusterID(), pd2.GetClusterID())
Copy link
Contributor

Choose a reason for hiding this comment

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

why not check it?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is difficult to use ut to test two PD instance's clusterID. In fact, we have test it in pkg/storage/endpoint/cluster_id_test.go, InitClusterID twice and check the two clusterID is same. TestClientClusterIDCheck is the same reason. I plan to add a real_cluster_test to test them.

Copy link
Member Author

@okJiang okJiang Sep 29, 2024

Choose a reason for hiding this comment

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

To avoid to increase the size of this pr, I will file another pr to add the real cluster test about ClusterID. I have to update the test structure because we need to deploy two cluster at the same time. Current test script doesn't meet this demand.

You can continue to review this pr~

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to pkg/utils/keypath

@@ -156,25 +156,6 @@ func TestEtcdKVPutWithTTL(t *testing.T) {
re.Equal(int64(0), resp.Count)
}

func TestInitClusterID(t *testing.T) {
Copy link
Member Author

@okJiang okJiang Sep 13, 2024

Choose a reason for hiding this comment

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

It has been move to pkg/storage/endpoint/cluster_id_test.go. The path can be discussed.

@@ -62,7 +62,6 @@ func TestSimpleJoin(t *testing.T) {
members, err = etcdutil.ListEtcdMembers(ctx, client)
re.NoError(err)
re.Len(members.Members, 2)
re.Equal(pd1.GetClusterID(), pd2.GetClusterID())
Copy link
Member Author

Choose a reason for hiding this comment

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

It is difficult to use ut to test two PD instance's clusterID. In fact, we have test it in pkg/storage/endpoint/cluster_id_test.go, InitClusterID twice and check the two clusterID is same. TestClientClusterIDCheck is the same reason. I plan to add a real_cluster_test to test them.

@okJiang
Copy link
Member Author

okJiang commented Sep 29, 2024

/cc @rleungx

@ti-chi-bot ti-chi-bot bot requested a review from rleungx September 29, 2024 09:02
@rleungx
Copy link
Member

rleungx commented Sep 29, 2024

If I remember correctly, we do not recommend using the global variable for cluster ID in the meeting.

@okJiang
Copy link
Member Author

okJiang commented Sep 29, 2024

If I remember correctly, we do not recommend using the global variable for cluster ID in the meeting.

@rleungx It was CallerID at that time. We can evaluate whether ClusterID is proper to be a global variable in #8588

@okJiang
Copy link
Member Author

okJiang commented Oct 23, 2024

/cc @rleungx @lhy1024

@ti-chi-bot ti-chi-bot bot requested a review from lhy1024 October 23, 2024 02:39
@okJiang
Copy link
Member Author

okJiang commented Oct 25, 2024

ptal @rleungx @lhy1024

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Oct 29, 2024
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.

the rest LGTM

}
// If no key exist, generate a random cluster ID.
if clusterID != 0 {
log.Info("Existed cluster id", zap.Uint64("cluster-id", clusterID))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log.Info("Existed cluster id", zap.Uint64("cluster-id", clusterID))
log.Info("existed cluster id", zap.Uint64("cluster-id", clusterID))

Signed-off-by: okJiang <[email protected]>
Copy link
Contributor

ti-chi-bot bot commented Oct 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lhy1024, rleungx

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 29, 2024
Copy link
Contributor

ti-chi-bot bot commented Oct 29, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-10-29 03:01:34.093548749 +0000 UTC m=+318806.932704292: ☑️ agreed by rleungx.
  • 2024-10-29 08:14:51.602748676 +0000 UTC m=+337604.441904223: ☑️ agreed by lhy1024.

@ti-chi-bot ti-chi-bot bot merged commit e257097 into tikv:master Oct 29, 2024
23 of 25 checks passed
@okJiang okJiang deleted the cluster-id branch October 29, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClusterID has been saved in too many places
3 participants