mirror of https://github.com/status-im/consul.git
Revert "Merge pull request #10277 from hashicorp/dnephin/backport-serf-tag-refactor"
This reverts commitf45ab674ce
, reversing changes made to985ca60d35
.
This commit is contained in:
parent
f45ab674ce
commit
442a8efc7f
|
@ -1,3 +0,0 @@
|
||||||
```release-note:bug
|
|
||||||
namespaces: **(Enterprise only)** fixes a problem where the logs would contain many warnings about namespaces not being licensed.
|
|
||||||
```
|
|
|
@ -5,14 +5,13 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/go-hclog"
|
|
||||||
"github.com/hashicorp/serf/serf"
|
|
||||||
|
|
||||||
"github.com/hashicorp/consul/agent/metadata"
|
"github.com/hashicorp/consul/agent/metadata"
|
||||||
"github.com/hashicorp/consul/agent/structs"
|
"github.com/hashicorp/consul/agent/structs"
|
||||||
"github.com/hashicorp/consul/lib"
|
"github.com/hashicorp/consul/lib"
|
||||||
"github.com/hashicorp/consul/logging"
|
"github.com/hashicorp/consul/logging"
|
||||||
"github.com/hashicorp/consul/types"
|
"github.com/hashicorp/consul/types"
|
||||||
|
"github.com/hashicorp/go-hclog"
|
||||||
|
"github.com/hashicorp/serf/serf"
|
||||||
)
|
)
|
||||||
|
|
||||||
// setupSerf is used to setup and initialize a Serf
|
// setupSerf is used to setup and initialize a Serf
|
||||||
|
@ -64,7 +63,7 @@ func (c *Client) setupSerf(conf *serf.Config, ch chan serf.Event, path string) (
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
addEnterpriseSerfTags(conf.Tags)
|
c.addEnterpriseSerfTags(conf.Tags)
|
||||||
|
|
||||||
return serf.Create(conf)
|
return serf.Create(conf)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,3 +23,7 @@ func (c *Client) handleEnterpriseUserEvents(event serf.UserEvent) bool {
|
||||||
func (c *Client) enterpriseStats() map[string]map[string]string {
|
func (c *Client) enterpriseStats() map[string]map[string]string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (_ *Client) addEnterpriseSerfTags(_ map[string]string) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
|
@ -5,11 +5,10 @@ package consul
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/hashicorp/go-version"
|
|
||||||
"github.com/hashicorp/serf/serf"
|
|
||||||
|
|
||||||
"github.com/hashicorp/consul/agent/pool"
|
"github.com/hashicorp/consul/agent/pool"
|
||||||
"github.com/hashicorp/consul/agent/structs"
|
"github.com/hashicorp/consul/agent/structs"
|
||||||
|
"github.com/hashicorp/go-version"
|
||||||
|
"github.com/hashicorp/serf/serf"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -60,7 +59,7 @@ func (s *Server) validateEnterpriseRequest(entMeta *structs.EnterpriseMeta, writ
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func addEnterpriseSerfTags(_ map[string]string) {
|
func (_ *Server) addEnterpriseSerfTags(_ map[string]string) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,9 @@ func (r *IndexReplicator) Replicate(ctx context.Context, lastRemoteIndex uint64,
|
||||||
return 0, false, fmt.Errorf("failed to retrieve %s: %w", r.Delegate.PluralNoun(), err)
|
return 0, false, fmt.Errorf("failed to retrieve %s: %w", r.Delegate.PluralNoun(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Logger.Debug("finished fetching remote objects", "amount", lenRemote)
|
r.Logger.Debug("finished fetching remote objects",
|
||||||
|
"amount", lenRemote,
|
||||||
|
)
|
||||||
|
|
||||||
// Need to check if we should be stopping. This will be common as the fetching process is a blocking
|
// Need to check if we should be stopping. This will be common as the fetching process is a blocking
|
||||||
// RPC which could have been hanging around for a long time and during that time leadership could
|
// RPC which could have been hanging around for a long time and during that time leadership could
|
||||||
|
|
|
@ -7,16 +7,15 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/go-hclog"
|
|
||||||
"github.com/hashicorp/memberlist"
|
|
||||||
"github.com/hashicorp/raft"
|
|
||||||
"github.com/hashicorp/serf/serf"
|
|
||||||
|
|
||||||
"github.com/hashicorp/consul/agent/consul/wanfed"
|
"github.com/hashicorp/consul/agent/consul/wanfed"
|
||||||
"github.com/hashicorp/consul/agent/metadata"
|
"github.com/hashicorp/consul/agent/metadata"
|
||||||
"github.com/hashicorp/consul/agent/structs"
|
"github.com/hashicorp/consul/agent/structs"
|
||||||
"github.com/hashicorp/consul/lib"
|
"github.com/hashicorp/consul/lib"
|
||||||
"github.com/hashicorp/consul/logging"
|
"github.com/hashicorp/consul/logging"
|
||||||
|
"github.com/hashicorp/go-hclog"
|
||||||
|
"github.com/hashicorp/memberlist"
|
||||||
|
"github.com/hashicorp/raft"
|
||||||
|
"github.com/hashicorp/serf/serf"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -166,7 +165,7 @@ func (s *Server) setupSerf(conf *serf.Config, ch chan serf.Event, path string, w
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
addEnterpriseSerfTags(conf.Tags)
|
s.addEnterpriseSerfTags(conf.Tags)
|
||||||
|
|
||||||
return serf.Create(conf)
|
return serf.Create(conf)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,9 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/consul/agent/structs"
|
||||||
"github.com/hashicorp/go-version"
|
"github.com/hashicorp/go-version"
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/agent/structs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Key is used in maps and for equality tests. A key is based on endpoints.
|
// Key is used in maps and for equality tests. A key is based on endpoints.
|
||||||
|
@ -121,8 +120,8 @@ func IsConsulServer(m serf.Member) (bool, *Server) {
|
||||||
segmentName := strings.TrimPrefix(name, "sl_")
|
segmentName := strings.TrimPrefix(name, "sl_")
|
||||||
segmentAddrs[segmentName] = addr
|
segmentAddrs[segmentName] = addr
|
||||||
segmentPorts[segmentName] = segmentPort
|
segmentPorts[segmentName] = segmentPort
|
||||||
} else if strings.HasPrefix(name, featureFlagPrefix) {
|
} else if strings.HasPrefix(name, "ft_") {
|
||||||
featureName := strings.TrimPrefix(name, featureFlagPrefix)
|
featureName := strings.TrimPrefix(name, "ft_")
|
||||||
featureState, err := strconv.Atoi(value)
|
featureState, err := strconv.Atoi(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@ -189,14 +188,3 @@ func IsConsulServer(m serf.Member) (bool, *Server) {
|
||||||
}
|
}
|
||||||
return true, parts
|
return true, parts
|
||||||
}
|
}
|
||||||
|
|
||||||
const featureFlagPrefix = "ft_"
|
|
||||||
|
|
||||||
// AddFeatureFlags to the tags. The tags map is expected to be a serf.Config.Tags.
|
|
||||||
// The feature flags are encoded in the tags so that IsConsulServer can decode them
|
|
||||||
// and populate the Server.FeatureFlags map.
|
|
||||||
func AddFeatureFlags(tags map[string]string, flags ...string) {
|
|
||||||
for _, flag := range flags {
|
|
||||||
tags[featureFlagPrefix+flag] = "1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,10 +4,9 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/consul/agent/metadata"
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/agent/metadata"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestServer_Key_params(t *testing.T) {
|
func TestServer_Key_params(t *testing.T) {
|
||||||
|
@ -182,10 +181,8 @@ func TestIsConsulServer_Optional(t *testing.T) {
|
||||||
if parts.RaftVersion != 0 {
|
if parts.RaftVersion != 0 {
|
||||||
t.Fatalf("bad: %v", parts.RaftVersion)
|
t.Fatalf("bad: %v", parts.RaftVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Tags["bootstrap"] = "1"
|
m.Tags["bootstrap"] = "1"
|
||||||
m.Tags["disabled"] = "1"
|
m.Tags["disabled"] = "1"
|
||||||
m.Tags["ft_ns"] = "1"
|
|
||||||
ok, parts = metadata.IsConsulServer(m)
|
ok, parts = metadata.IsConsulServer(m)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("expected a valid consul server")
|
t.Fatalf("expected a valid consul server")
|
||||||
|
@ -199,9 +196,6 @@ func TestIsConsulServer_Optional(t *testing.T) {
|
||||||
if parts.Version != 1 {
|
if parts.Version != 1 {
|
||||||
t.Fatalf("bad: %v", parts)
|
t.Fatalf("bad: %v", parts)
|
||||||
}
|
}
|
||||||
expectedFlags := map[string]int{"ns": 1}
|
|
||||||
require.Equal(t, expectedFlags, parts.FeatureFlags)
|
|
||||||
|
|
||||||
m.Tags["expect"] = "3"
|
m.Tags["expect"] = "3"
|
||||||
delete(m.Tags, "bootstrap")
|
delete(m.Tags, "bootstrap")
|
||||||
delete(m.Tags, "disabled")
|
delete(m.Tags, "disabled")
|
||||||
|
|
Loading…
Reference in New Issue