Skip to content

Commit

Permalink
Add cluster version fix etcd-io#11233, etcd-io#11254, etcd-io#11265
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjiaswe authored and hexfusion committed Mar 21, 2020
1 parent 40d33b4 commit c544ca5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions etcdserver/membership/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -377,8 +378,11 @@ 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)
onSet(ver)
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)
}

func (c *RaftCluster) IsReadyToAddNewMember() bool {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"fmt"
"testing"

"go.etcd.io/etcd/version"
"github.com/coreos/etcd/version"
)

func TestV3MetricsSecure(t *testing.T) {
Expand Down

0 comments on commit c544ca5

Please sign in to comment.