-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Migrate cluster attributes to use v3 backend #11427
Changes from all commits
dcd622b
0c3401f
5cd2502
ed5a01a
7784ca8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -247,7 +247,12 @@ func (c *RaftCluster) Recover(onSet func(*zap.Logger, *semver.Version)) { | |||||||||||||
defer c.Unlock() | ||||||||||||||
|
||||||||||||||
c.members, c.removed = membersFromStore(c.lg, c.v2store) | ||||||||||||||
c.version = clusterVersionFromStore(c.lg, c.v2store) | ||||||||||||||
if c.be != nil { | ||||||||||||||
c.version = clusterVersionFromBackend(c.lg, c.be) | ||||||||||||||
} else { | ||||||||||||||
c.version = clusterVersionFromStore(c.lg, c.v2store) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need fallback on v2 version data if v3 version is c.version = clusterVersionFromStore(c.lg, c.v2store)
if c.be != nil {
v3Ver := clusterVersionFromBackend(c.lg, c.be)
if v3Ver != nil { c.version = v3Ver }
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about it. When will v3 version data is nil while v2 is not? If v3 backend is available, the v3 version will not be nil except starting a new server? Setting version will store new version info into both v2 store and v3 backend. etcd/etcdserver/api/membership/cluster.go Lines 571 to 576 in 1f8764b
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, that answers my question. Thanks. |
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
mustDetectDowngrade(c.lg, c.version) | ||||||||||||||
onSet(c.lg, c.version) | ||||||||||||||
|
||||||||||||||
|
@@ -753,6 +758,26 @@ func clusterVersionFromStore(lg *zap.Logger, st v2store.Store) *semver.Version { | |||||||||||||
return semver.Must(semver.NewVersion(*e.Node.Value)) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func clusterVersionFromBackend(lg *zap.Logger, be backend.Backend) *semver.Version { | ||||||||||||||
ckey := backendClusterVersionKey() | ||||||||||||||
tx := be.ReadTx() | ||||||||||||||
tx.RLock() | ||||||||||||||
defer tx.RUnlock() | ||||||||||||||
keys, vals := tx.UnsafeRange(clusterBucketName, ckey, nil, 0) | ||||||||||||||
if len(keys) == 0 { | ||||||||||||||
return nil | ||||||||||||||
} | ||||||||||||||
if len(keys) != 1 { | ||||||||||||||
if lg != nil { | ||||||||||||||
lg.Panic( | ||||||||||||||
"unexpected number of keys when getting cluster version from backend", | ||||||||||||||
zap.Int("number-of-key", len(keys)), | ||||||||||||||
) | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
return semver.Must(semver.NewVersion(string(vals[0]))) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// ValidateClusterAndAssignIDs validates the local cluster by matching the PeerURLs | ||||||||||||||
// with the existing cluster. If the validation succeeds, it assigns the IDs | ||||||||||||||
// from the existing cluster to the local cluster. | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, if we keep the previous test data, the test cluster will fail to start. It is because the cluster will make several v3 raft requests like cluster version set during start. Old code will use v2 for starting server which will bypass the check.
etcd/etcdserver/v3_server.go
Lines 633 to 635 in 1f8764b
Changing a larger
maxRequestBytesServer
will not affect the test behavior as long asmaxRequestBytesServer
is smaller thenvalueSize
.