Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

dm-master: join a new member into an existing cluster #350

Merged
merged 34 commits into from
Nov 14, 2019

Conversation

csuzhangxc
Copy link
Member

@csuzhangxc csuzhangxc commented Nov 12, 2019

What problem does this PR solve?

join a new member into an existing DM-master cluster.

What is changed and how it works?

prepare config for embed etcd to join an existing cluster

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has exported variable/fields change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation
  • Need to update the dm/dm-ansible
  • Need to be included in the release note

@csuzhangxc csuzhangxc added priority/important Major change, requires approval from ≥2 primary reviewers needs-update-docs Should update docs after this PR is merged. Remove this label once the docs are updated status/WIP This PR is still work in progress type/feature New feature needs-update-release-note This PR should be added into release notes. Remove this label once the release notes are updated should-update-dm-ansible labels Nov 12, 2019
return terror.ErrMasterJoinEmbedEtcdFail.Delegate(err, "read persistent join data")
}
} else {
cfg.InitialCluster = strings.TrimSpace(string(s))
Copy link
Collaborator

@IANTHEREAL IANTHEREAL Nov 13, 2019

Choose a reason for hiding this comment

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

please adding a log here shows that we use data of dir/join as cfg. InitialCluster .

Copy link
Member Author

Choose a reason for hiding this comment

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

added in c9a413f.


// join with persistent data
c.Assert(ioutil.WriteFile(joinFP, []byte(joinCluster), privateDirMode), check.IsNil)
cfgAfter = t.cloneConfig(cfgBefore)
Copy link
Collaborator

@IANTHEREAL IANTHEREAL Nov 13, 2019

Choose a reason for hiding this comment

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

it seems we don't verify logic at L170 of etcd.go

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔 Did you mean

cfg.InitialCluster = strings.Join(ms, ",")

if so, it's verified by // join with existing cluster from L122 to L129 of etcd_test.go

@IANTHEREAL
Copy link
Collaborator

Rest LGTM

@csuzhangxc
Copy link
Member Author

/run-all-tests

@IANTHEREAL
Copy link
Collaborator

LGTM

@IANTHEREAL IANTHEREAL added status/LGT1 One reviewer already commented LGTM and removed status/PTAL This PR is ready for review. Add this label back after committing new changes labels Nov 13, 2019
@csuzhangxc
Copy link
Member Author

@WangXiangUSTC PTAL again

@csuzhangxc
Copy link
Member Author

/run-all-tests tidb=release-3.0

@csuzhangxc
Copy link
Member Author

/run-all-tests tidb=release-3.0

@codecov
Copy link

codecov bot commented Nov 14, 2019

Codecov Report

Merging #350 into master will decrease coverage by 0.9901%.
The diff coverage is 84.8101%.

@@               Coverage Diff                @@
##             master       #350        +/-   ##
================================================
- Coverage   58.6717%   57.6815%   -0.9902%     
================================================
  Files           160        160                
  Lines         17436      16149      -1287     
================================================
- Hits          10230       9315       -915     
+ Misses         6250       5926       -324     
+ Partials        956        908        -48

Copy link
Contributor

@WangXiangUSTC WangXiangUSTC 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

@@ -65,6 +66,7 @@ func NewConfig() *Config {
fs.StringVar(&cfg.InitialCluster, "initial-cluster", "", fmt.Sprintf("initial cluster configuration for bootstrapping, e,g. dm-master=%s", defaultPeerUrls))
fs.StringVar(&cfg.PeerUrls, "peer-urls", defaultPeerUrls, "URLs for peer traffic")
fs.StringVar(&cfg.AdvertisePeerUrls, "advertise-peer-urls", "", `advertise URLs for peer traffic (default "${peer-urls}")`)
fs.StringVar(&cfg.Join, "join", "", `join to an existing cluster (usage: cluster's "${advertise-client-urls}"`)
Copy link
Contributor

Choose a reason for hiding this comment

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

seems don't have config named advertise-client-urls

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's a but, join should be the address of clients (endpoints), but use peer address before, fixed in b0f5332.

// check members
for _, m := range listResp.Members {
if m.Name == "" {
return terror.ErrMasterJoinEmbedEtcdFail.Generate("there is a member that has not joined successfully")
Copy link
Contributor

Choose a reason for hiding this comment

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

this means other member joined failed, but why prevent this member join? And how to fix this error?

Copy link
Member Author

Choose a reason for hiding this comment

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

add some comments to explain it, and update the error message in b0f5332.

later maybe we can embed etcd client in dmctl?

for _, m := range addResp.Members {
name := m.Name
if m.ID == addResp.Member.ID {
name = cfg.Name
Copy link
Contributor

Choose a reason for hiding this comment

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

if name is empty, will it generate err at L142?

@csuzhangxc
Copy link
Member Author

csuzhangxc commented Nov 14, 2019

if name is empty, will it generate err at L142?

@WangXiangUSTC we should check name and other items in the config adjust.

@csuzhangxc
Copy link
Member Author

/run-all-test tidb=release-3.0

@csuzhangxc
Copy link
Member Author

/run-all-tests tidb=release-3.0

@WangXiangUSTC WangXiangUSTC added status/LGT2 Two reviewers already commented LGTM, ready for merge and removed status/LGT1 One reviewer already commented LGTM labels Nov 14, 2019
Copy link
Contributor

@WangXiangUSTC WangXiangUSTC left a comment

Choose a reason for hiding this comment

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

LGTM

@csuzhangxc
Copy link
Member Author

/run-all-tests tidb=release-3.0

1 similar comment
@csuzhangxc
Copy link
Member Author

/run-all-tests tidb=release-3.0

@csuzhangxc csuzhangxc merged commit 4abf519 into pingcap:master Nov 14, 2019
@csuzhangxc csuzhangxc deleted the dm-master-join branch November 14, 2019 12:41
@csuzhangxc csuzhangxc mentioned this pull request Dec 6, 2019
23 tasks
lichunzhu pushed a commit to lichunzhu/dm that referenced this pull request Apr 6, 2020
@csuzhangxc csuzhangxc removed needs-update-dm-ansible needs-update-docs Should update docs after this PR is merged. Remove this label once the docs are updated needs-update-release-note This PR should be added into release notes. Remove this label once the release notes are updated labels Jun 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority/important Major change, requires approval from ≥2 primary reviewers status/LGT2 Two reviewers already commented LGTM, ready for merge type/feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants