-
Notifications
You must be signed in to change notification settings - Fork 727
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
*: Introduce version checking mechanism #1148
Merged
Merged
Changes from 28 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
cd02a27
update proto
nolouch 52bee45
add version
nolouch 595f133
update proto
nolouch 2fdd381
on change cluster version
nolouch efc59f1
use cluster version to switch new feature
nolouch 726ef07
add tests
nolouch 3178fae
address comments
nolouch cbe6d32
update proto
nolouch 9997f8d
merge master
nolouch d18d0aa
fix response
nolouch 13bccce
rename version
nolouch 69cf420
use go-semver
nolouch 9d81d84
fix tests
nolouch 9e6866e
clean up
nolouch f51bacf
handle onchange cluster version failed situation
nolouch 365da06
address comments
nolouch e1a3e65
rename to OnStoreVersionChange
nolouch 2eaabf1
address comment
nolouch 0a1cea3
supported pd-ctl set cluster version
nolouch 2b73eed
address comments
nolouch 71bbf0f
Merge branch 'master' into version-introduce
nolouch e15af4f
add show cluster version command
nolouch 7d9a99e
remove background check cluster version
nolouch 5bfb86f
fix learn switch
nolouch 4b007fa
address comments
nolouch 94542d0
Merge remote-tracking branch 'upstream/master' into version-introduce
nolouch 3fa0a54
Merge remote-tracking branch 'upstream/master' into version-introduce
nolouch 4478e41
update proto
nolouch 5eeca3d
address comment
nolouch 3f711b8
fix
nolouch d099292
address comment
nolouch e40ff3d
address comment
nolouch 1693736
Merge branch 'master' into version-introduce
nolouch 8dccabd
address comment
nolouch c7c42ca
Merge branch 'master' into version-introduce
nolouch 89a1d93
tiny clear
nolouch a01fc8f
Merge branch 'master' into version-introduce
nolouch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,3 @@ | |
[[constraint]] | ||
name = "github.com/pingcap/kvproto" | ||
branch = "master" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
// Copyright 2018 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package integration | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/coreos/go-semver/semver" | ||
. "github.com/pingcap/check" | ||
"github.com/pingcap/kvproto/pkg/metapb" | ||
"github.com/pingcap/kvproto/pkg/pdpb" | ||
) | ||
|
||
func (s *integrationTestSuite) bootstrapCluster(server *testServer, c *C) { | ||
bootstrapReq := &pdpb.BootstrapRequest{ | ||
Header: &pdpb.RequestHeader{ClusterId: server.GetClusterID()}, | ||
Store: &metapb.Store{Id: 1, Address: "mock://1"}, | ||
Region: &metapb.Region{Id: 2, Peers: []*metapb.Peer{{3, 1, false}}}, | ||
} | ||
_, err := server.server.Bootstrap(context.Background(), bootstrapReq) | ||
c.Assert(err, IsNil) | ||
} | ||
|
||
func (s *integrationTestSuite) TestStoreRegister(c *C) { | ||
c.Parallel() | ||
cluster, err := newTestCluster(3) | ||
c.Assert(err, IsNil) | ||
defer cluster.Destory() | ||
|
||
err = cluster.RunInitialServers() | ||
c.Assert(err, IsNil) | ||
cluster.WaitLeader() | ||
leaderServer := cluster.GetServer(cluster.GetLeader()) | ||
s.bootstrapCluster(leaderServer, c) | ||
|
||
putStoreRequest := &pdpb.PutStoreRequest{ | ||
Header: &pdpb.RequestHeader{ClusterId: leaderServer.GetClusterID()}, | ||
Store: &metapb.Store{ | ||
Id: 1, | ||
Address: "mock-1", | ||
Version: "2.0.1", | ||
}, | ||
} | ||
_, err = leaderServer.server.PutStore(context.Background(), putStoreRequest) | ||
c.Assert(err, IsNil) | ||
// FIX ME: read v0.0.0 in sometime | ||
cluster.WaitLeader() | ||
version := leaderServer.GetClusterVersion() | ||
// Restart all PDs. | ||
err = cluster.StopAll() | ||
c.Assert(err, IsNil) | ||
err = cluster.RunInitialServers() | ||
c.Assert(err, IsNil) | ||
cluster.WaitLeader() | ||
|
||
leaderServer = cluster.GetServer(cluster.GetLeader()) | ||
newVersion := leaderServer.GetClusterVersion() | ||
c.Assert(version, Equals, newVersion) | ||
|
||
// putNewStore with old version | ||
putStoreRequest = &pdpb.PutStoreRequest{ | ||
Header: &pdpb.RequestHeader{ClusterId: leaderServer.GetClusterID()}, | ||
Store: &metapb.Store{ | ||
Id: 4, | ||
Address: "mock-4", | ||
Version: "1.0.1", | ||
}, | ||
} | ||
_, err = leaderServer.server.PutStore(context.Background(), putStoreRequest) | ||
c.Assert(err, NotNil) | ||
} | ||
|
||
func (s *integrationTestSuite) TestRollingUpgrade(c *C) { | ||
c.Parallel() | ||
cluster, err := newTestCluster(3) | ||
c.Assert(err, IsNil) | ||
defer cluster.Destory() | ||
err = cluster.RunInitialServers() | ||
c.Assert(err, IsNil) | ||
cluster.WaitLeader() | ||
leaderServer := cluster.GetServer(cluster.GetLeader()) | ||
s.bootstrapCluster(leaderServer, c) | ||
|
||
stores := []*pdpb.PutStoreRequest{ | ||
{ | ||
Header: &pdpb.RequestHeader{ClusterId: leaderServer.GetClusterID()}, | ||
Store: &metapb.Store{ | ||
Id: 1, | ||
Address: "mock-1", | ||
Version: "2.0.1", | ||
}, | ||
}, | ||
{ | ||
Header: &pdpb.RequestHeader{ClusterId: leaderServer.GetClusterID()}, | ||
Store: &metapb.Store{ | ||
Id: 4, | ||
Address: "mock-4", | ||
Version: "2.0.1", | ||
}, | ||
}, | ||
{ | ||
Header: &pdpb.RequestHeader{ClusterId: leaderServer.GetClusterID()}, | ||
Store: &metapb.Store{ | ||
Id: 6, | ||
Address: "mock-6", | ||
Version: "2.0.1", | ||
}, | ||
}, | ||
{ | ||
Header: &pdpb.RequestHeader{ClusterId: leaderServer.GetClusterID()}, | ||
Store: &metapb.Store{ | ||
Id: 7, | ||
Address: "mock-7", | ||
Version: "2.0.1", | ||
}, | ||
}, | ||
} | ||
for _, store := range stores { | ||
_, err = leaderServer.server.PutStore(context.Background(), store) | ||
c.Assert(err, IsNil) | ||
} | ||
c.Assert(leaderServer.GetClusterVersion(), Equals, semver.Version{Major: 2, Minor: 0, Patch: 1}) | ||
// rolling update | ||
for i, store := range stores { | ||
if i == 0 { | ||
store.Store.State = metapb.StoreState_Tombstone | ||
} | ||
store.Store.Version = "2.1.0" | ||
resp, err := leaderServer.server.PutStore(context.Background(), store) | ||
c.Assert(err, IsNil) | ||
if i != len(stores)-1 { | ||
c.Assert(leaderServer.GetClusterVersion(), Equals, semver.Version{Major: 2, Minor: 0, Patch: 1}) | ||
c.Assert(resp.GetHeader().GetError(), IsNil) | ||
} | ||
} | ||
c.Assert(leaderServer.GetClusterVersion(), Equals, semver.Version{Major: 2, Minor: 1}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Use 400 instead.
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.
Message should use the exact key name "cluster-version". A helper function for this case would create consistent messages.