mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3305 from xiang90/c_v
*: only print out major.minor version for cluster version
This commit is contained in:
commit
f615f9a999
@ -31,6 +31,7 @@ import (
|
||||
"github.com/coreos/etcd/raft"
|
||||
"github.com/coreos/etcd/raft/raftpb"
|
||||
"github.com/coreos/etcd/store"
|
||||
"github.com/coreos/etcd/version"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -358,9 +359,9 @@ func (c *cluster) SetVersion(ver *semver.Version) {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
if c.version != nil {
|
||||
plog.Noticef("updated the cluster version from %v to %v", c.version.String(), ver.String())
|
||||
plog.Noticef("updated the cluster version from %v to %v", version.Cluster(c.version.String()), version.Cluster(ver.String()))
|
||||
} else {
|
||||
plog.Noticef("set the initial cluster version to %v", ver.String())
|
||||
plog.Noticef("set the initial cluster version to %v", version.Cluster(ver.String()))
|
||||
}
|
||||
c.version = ver
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ func (s *EtcdServer) start() {
|
||||
s.done = make(chan struct{})
|
||||
s.stop = make(chan struct{})
|
||||
if s.ClusterVersion() != nil {
|
||||
plog.Infof("starting server... [version: %v, cluster version: %v]", version.Version, s.ClusterVersion())
|
||||
plog.Infof("starting server... [version: %v, cluster version: %v]", version.Version, version.Cluster(s.ClusterVersion().String()))
|
||||
} else {
|
||||
plog.Infof("starting server... [version: %v, cluster version: to_be_decided]", version.Version)
|
||||
}
|
||||
@ -991,9 +991,9 @@ func (s *EtcdServer) monitorVersions() {
|
||||
|
||||
func (s *EtcdServer) updateClusterVersion(ver string) {
|
||||
if s.cluster.Version() == nil {
|
||||
plog.Infof("setting up the initial cluster version to %v", ver)
|
||||
plog.Infof("setting up the initial cluster version to %s", version.Cluster(ver))
|
||||
} else {
|
||||
plog.Infof("updating the cluster version from %v to %v", s.cluster.Version(), ver)
|
||||
plog.Infof("updating the cluster version from %s to %s", version.Cluster(s.cluster.Version().String()), version.Cluster(ver))
|
||||
}
|
||||
req := pb.Request{
|
||||
Method: "PUT",
|
||||
|
@ -15,8 +15,10 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/coreos/etcd/pkg/fileutil"
|
||||
"github.com/coreos/etcd/pkg/types"
|
||||
@ -76,3 +78,12 @@ func DetectDataDir(dirpath string) (DataDirVersion, error) {
|
||||
}
|
||||
return DataDirUnknown, nil
|
||||
}
|
||||
|
||||
// Cluster only keeps the major.minor.
|
||||
func Cluster(v string) string {
|
||||
vs := strings.Split(v, ".")
|
||||
if len(vs) <= 2 {
|
||||
return v
|
||||
}
|
||||
return fmt.Sprintf("%s.%s", vs[0], vs[1])
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user