Consul Service meta wrongly computes and exposes non_voter meta (#8731)

* Consul Service meta wrongly computes and exposes non_voter meta

In Serf Tags, entreprise members being non-voters use the tag
`nonvoter=1`, not `non_voter = false`, so non-voters in members
were wrongly displayed as voter.

Demonstration:

```
consul members -detailed|grep voter
consul20-hk5 10.200.100.110:8301   alive   acls=1,build=1.8.4+ent,dc=hk5,expect=3,ft_fs=1,ft_ns=1,id=xxxxxxxx-5629-08f2-3a79-10a1ab3849d5,nonvoter=1,port=8300,raft_vsn=3,role=consul,segment=<all>,use_tls=1,vsn=2,vsn_max=3,vsn_min=2,wan_join_port=8302
```

* Added changelog

* Added changelog entry
This commit is contained in:
Pierre Souchay 2020-10-09 23:18:24 +02:00 committed by GitHub
parent f58806fbab
commit 54f9f247f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

3
.changelog/8731.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
raft: (Enterprise only) properly update consul server meta non_voter for non-voting Enterprise Consul servers
```

View File

@ -1208,7 +1208,7 @@ func (s *Server) handleAliveMember(member serf.Member) error {
Warning: 1,
},
Meta: map[string]string{
"non_voter": strconv.FormatBool(member.Tags["non_voter"] == "true"),
"non_voter": strconv.FormatBool(member.Tags["nonvoter"] == "1"),
"raft_version": strconv.Itoa(parts.RaftVersion),
"serf_protocol_current": strconv.FormatUint(uint64(member.ProtocolCur), 10),
"serf_protocol_min": strconv.FormatUint(uint64(member.ProtocolMin), 10),

View File

@ -334,7 +334,7 @@ func TestLeader_CheckServersMeta(t *testing.T) {
versionToExpect := "19.7.9"
retry.Run(t, func(r *retry.R) {
member.Tags["non_voter"] = "true"
member.Tags["nonvoter"] = "1"
member.Tags["build"] = versionToExpect
err := s1.handleAliveMember(member)
if err != nil {
@ -348,7 +348,7 @@ func TestLeader_CheckServersMeta(t *testing.T) {
r.Fatal("client not registered")
}
if service.Meta["non_voter"] != "true" {
r.Fatalf("Expected to be non_voter == false, was: %s", service.Meta["non_voter"])
r.Fatalf("Expected to be non_voter == true, was: %s", service.Meta["non_voter"])
}
newVersion := service.Meta["version"]
if newVersion != versionToExpect {