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

*: Introduce version checking mechanism #1148

Merged
merged 37 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cd02a27
update proto
nolouch Jul 5, 2018
52bee45
add version
nolouch Jul 6, 2018
595f133
update proto
nolouch Jul 12, 2018
2fdd381
on change cluster version
nolouch Jul 12, 2018
efc59f1
use cluster version to switch new feature
nolouch Jul 12, 2018
726ef07
add tests
nolouch Jul 12, 2018
3178fae
address comments
nolouch Jul 13, 2018
cbe6d32
update proto
nolouch Jul 13, 2018
9997f8d
merge master
nolouch Jul 13, 2018
d18d0aa
fix response
nolouch Jul 13, 2018
13bccce
rename version
nolouch Jul 16, 2018
69cf420
use go-semver
nolouch Jul 16, 2018
9d81d84
fix tests
nolouch Jul 16, 2018
9e6866e
clean up
nolouch Jul 16, 2018
f51bacf
handle onchange cluster version failed situation
nolouch Jul 16, 2018
365da06
address comments
nolouch Jul 16, 2018
e1a3e65
rename to OnStoreVersionChange
nolouch Jul 16, 2018
2eaabf1
address comment
nolouch Jul 16, 2018
0a1cea3
supported pd-ctl set cluster version
nolouch Jul 17, 2018
2b73eed
address comments
nolouch Jul 17, 2018
71bbf0f
Merge branch 'master' into version-introduce
nolouch Jul 17, 2018
e15af4f
add show cluster version command
nolouch Jul 17, 2018
7d9a99e
remove background check cluster version
nolouch Jul 17, 2018
5bfb86f
fix learn switch
nolouch Jul 17, 2018
4b007fa
address comments
nolouch Jul 18, 2018
94542d0
Merge remote-tracking branch 'upstream/master' into version-introduce
nolouch Jul 18, 2018
3fa0a54
Merge remote-tracking branch 'upstream/master' into version-introduce
nolouch Jul 18, 2018
4478e41
update proto
nolouch Jul 18, 2018
5eeca3d
address comment
nolouch Jul 19, 2018
3f711b8
fix
nolouch Jul 19, 2018
d099292
address comment
nolouch Jul 19, 2018
e40ff3d
address comment
nolouch Jul 19, 2018
1693736
Merge branch 'master' into version-introduce
nolouch Jul 19, 2018
8dccabd
address comment
nolouch Jul 19, 2018
c7c42ca
Merge branch 'master' into version-introduce
nolouch Jul 23, 2018
89a1d93
tiny clear
nolouch Jul 24, 2018
a01fc8f
Merge branch 'master' into version-introduce
nolouch Jul 24, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions server/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/gorilla/mux"
"github.com/juju/errors"
"github.com/pingcap/pd/pkg/error_code"
"github.com/pingcap/pd/server"
"github.com/unrolled/render"
)
Expand Down Expand Up @@ -180,12 +181,12 @@ func (h *confHandler) SetClusterVersion(w http.ResponseWriter, r *http.Request)
}
version, ok := input["cluster-version"]
if !ok {
h.rd.JSON(w, http.StatusInternalServerError, "not set cluster version")
errorResp(h.rd, w, errcode.NewInvalidInputErr(errors.New("not set cluster-version")))
return
}
err := h.svr.SetClusterVersion(version)
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
errorResp(h.rd, w, errcode.NewInternalErr(err))
return
}
h.rd.JSON(w, http.StatusOK, nil)
Expand Down
5 changes: 4 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,11 @@ func (s *Server) SetClusterVersion(v string) error {
if err != nil {
return errors.Trace(err)
}
err = s.scheduleOpt.persist(s.kv)
if err != nil {
return errors.Trace(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you want to update the version before persisting it.

s.scheduleOpt.SetClusterVersion(*version)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you want to update the version before persisting it.

s.scheduleOpt.persist(s.kv)
log.Infof("cluster version is updated to %s", v)
return nil
}
Expand Down
18 changes: 11 additions & 7 deletions server/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@ type Feature int
const (
Base Feature = iota
Version2_0
// RegionMerge supports the adjacent regions to be merge.
RegionMerge
// RaftLearner supports add a non-voting member in raft members.
RaftLearner
// BatchSplit can speed up the region split.
BatchSplit
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to add some comments to describe the meaning of these features.

)

var featuresDict = map[Feature]semver.Version{
Base: {Major: 1},
Version2_0: {Major: 2},
RegionMerge: {Major: 2, Minor: 0},
RaftLearner: {Major: 2, Minor: 0},
BatchSplit: {Major: 2, Minor: 1},
var featuresDict = map[Feature]string{
Base: "1.0.0",
Version2_0: "2.0.0",
RegionMerge: "2.0.0",
RaftLearner: "2.0.0",
BatchSplit: "2.1.0",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Will it be more readable to use string style? like BatchSplit: "v2.1.0".


// MinSupportedVersion returns the minimum support version for the specified feature.
Expand All @@ -44,7 +47,8 @@ func MinSupportedVersion(v Feature) semver.Version {
if !ok {
log.Fatalf("the corresponding version of the feature %d doesn't exist", v)
}
return target
version := MustParseVersion(target)
return *version
}

// ParseVersion wraps semver.NewVersion and handles compatibility issues.
Expand Down