From c46460b99b4ef2f168c55f234456356fd1b10c91 Mon Sep 17 00:00:00 2001 From: Jingyi Hu Date: Thu, 10 Oct 2019 13:23:54 -0700 Subject: [PATCH] etcdserver: unset old cluster version in metrics --- etcdserver/api/membership/cluster.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etcdserver/api/membership/cluster.go b/etcdserver/api/membership/cluster.go index 89a6edd2538c..17169aa5324b 100644 --- a/etcdserver/api/membership/cluster.go +++ b/etcdserver/api/membership/cluster.go @@ -565,6 +565,7 @@ func (c *RaftCluster) SetVersion(ver *semver.Version, onSet func(*zap.Logger, *s plog.Noticef("set the initial cluster version to %v", version.Cluster(ver.String())) } } + oldVer := c.version c.version = ver mustDetectDowngrade(c.lg, c.version) if c.v2store != nil { @@ -574,6 +575,9 @@ func (c *RaftCluster) SetVersion(ver *semver.Version, onSet func(*zap.Logger, *s mustSaveClusterVersionToBackend(c.be, ver) } ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": ver.String()}).Set(1) + if oldVer != nil { + ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": oldVer.String()}).Set(0) + } onSet(c.lg, ver) }