From f199a484af03de02f0611d16eddfa43e31e355bd Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Sat, 15 Aug 2015 08:30:06 -0700 Subject: [PATCH] *: only print out major.minor version for cluster version --- etcdserver/cluster.go | 5 +++-- etcdserver/server.go | 6 +++--- version/version.go | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/etcdserver/cluster.go b/etcdserver/cluster.go index 307805165..ed25d3234 100644 --- a/etcdserver/cluster.go +++ b/etcdserver/cluster.go @@ -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 } diff --git a/etcdserver/server.go b/etcdserver/server.go index 0ea8e785f..9d7aa6656 100644 --- a/etcdserver/server.go +++ b/etcdserver/server.go @@ -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", diff --git a/version/version.go b/version/version.go index f5c0330ed..c8fe4a447 100644 --- a/version/version.go +++ b/version/version.go @@ -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]) +}