diff --git a/etcdserver/membership/cluster.go b/etcdserver/membership/cluster.go index a04bf1d3a3f0..ba5c5411d5fc 100644 --- a/etcdserver/membership/cluster.go +++ b/etcdserver/membership/cluster.go @@ -369,6 +369,7 @@ func (c *RaftCluster) SetVersion(ver *semver.Version, onSet func(*semver.Version } else { plog.Noticef("set the initial cluster version to %v", version.Cluster(ver.String())) } + oldVer := c.version c.version = ver mustDetectDowngrade(c.version) if c.store != nil { @@ -377,7 +378,10 @@ func (c *RaftCluster) SetVersion(ver *semver.Version, onSet func(*semver.Version if c.be != nil { mustSaveClusterVersionToBackend(c.be, ver) } - ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": ver.String()}).Set(1) + if oldVer != nil { + ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": version.Cluster(oldVer.String())}).Set(0) + } + ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": version.Cluster(ver.String())}).Set(1) onSet(ver) }