agent/structs: add a bunch more EnterpriseMeta helper functions to help with partitioning (#10669)

This commit is contained in:
R.B. Boyer 2021-07-22 13:20:45 -05:00 committed by GitHub
parent c6859b3fb0
commit 188e8dc51f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
84 changed files with 511 additions and 471 deletions

View File

@ -201,7 +201,7 @@ func (a *Agent) filterMembers(token string, members *[]serf.Member) error {
}
var authzContext acl.AuthorizerContext
structs.DefaultEnterpriseMeta().FillAuthzContext(&authzContext)
structs.DefaultEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
// Filter out members based on the node policy.
m := *members
for i := 0; i < len(m); i++ {
@ -271,7 +271,7 @@ func (a *Agent) filterChecksWithAuthorizer(authz acl.Authorizer, checks *map[str
continue
}
} else {
structs.DefaultEnterpriseMeta().FillAuthzContext(&authzContext)
structs.DefaultEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
if authz.NodeRead(a.config.NodeName, &authzContext) == acl.Allow {
continue
}

View File

@ -116,7 +116,7 @@ func (a *TestACLAgent) ResolveTokenAndDefaultMeta(secretID string, entMeta *stru
if identity != nil {
entMeta.Merge(identity.EnterpriseMetadata())
} else {
entMeta.Merge(structs.DefaultEnterpriseMeta())
entMeta.Merge(structs.DefaultEnterpriseMetaInDefaultPartition())
}
// Use the meta to fill in the ACL authorization context

View File

@ -1684,7 +1684,7 @@ OUTER:
// reapServicesInternal does a single pass, looking for services to reap.
func (a *Agent) reapServicesInternal() {
reaped := make(map[structs.ServiceID]bool)
for checkID, cs := range a.State.CriticalCheckStates(structs.WildcardEnterpriseMeta()) {
for checkID, cs := range a.State.CriticalCheckStates(structs.WildcardEnterpriseMetaInDefaultPartition()) {
serviceID := cs.Check.CompoundServiceID()
// There's nothing to do if there's no service.
@ -2014,7 +2014,7 @@ func (a *Agent) addServiceInternal(req addServiceInternalRequest) error {
// Agent.Start does not have a snapshot, and we don't want to query
// State.Checks each time.
if req.checkStateSnapshot == nil {
req.checkStateSnapshot = a.State.Checks(structs.WildcardEnterpriseMeta())
req.checkStateSnapshot = a.State.Checks(structs.WildcardEnterpriseMetaInDefaultPartition())
}
// Create an associated health check
@ -3307,7 +3307,7 @@ func (a *Agent) loadServices(conf *config.RuntimeConfig, snap map[structs.CheckI
// unloadServices will deregister all services.
func (a *Agent) unloadServices() error {
for id := range a.State.Services(structs.WildcardEnterpriseMeta()) {
for id := range a.State.Services(structs.WildcardEnterpriseMetaInDefaultPartition()) {
if err := a.removeServiceLocked(id, false); err != nil {
return fmt.Errorf("Failed deregistering service '%s': %v", id, err)
}
@ -3421,7 +3421,7 @@ func (a *Agent) loadChecks(conf *config.RuntimeConfig, snap map[structs.CheckID]
// unloadChecks will deregister all checks known to the local agent.
func (a *Agent) unloadChecks() error {
for id := range a.State.Checks(structs.WildcardEnterpriseMeta()) {
for id := range a.State.Checks(structs.WildcardEnterpriseMetaInDefaultPartition()) {
if err := a.removeCheckLocked(id, false); err != nil {
return fmt.Errorf("Failed deregistering check '%s': %s", id, err)
}
@ -3433,7 +3433,7 @@ func (a *Agent) unloadChecks() error {
// checks. This is done before we reload our checks, so that we can properly
// restore into the same state.
func (a *Agent) snapshotCheckState() map[structs.CheckID]*structs.HealthCheck {
return a.State.Checks(structs.WildcardEnterpriseMeta())
return a.State.Checks(structs.WildcardEnterpriseMetaInDefaultPartition())
}
// loadMetadata loads node metadata fields from the agent config and

View File

@ -380,7 +380,7 @@ func TestAgent_Service(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
// Define an updated version. Be careful to copy it.
@ -408,7 +408,7 @@ func TestAgent_Service(t *testing.T) {
Tags: []string{},
Datacenter: "dc1",
}
fillAgentServiceEnterpriseMeta(expectedResponse, structs.DefaultEnterpriseMeta())
fillAgentServiceEnterpriseMeta(expectedResponse, structs.DefaultEnterpriseMetaInDefaultPartition())
// Copy and modify
updatedResponse := *expectedResponse
@ -435,7 +435,7 @@ func TestAgent_Service(t *testing.T) {
Tags: []string{},
Datacenter: "dc1",
}
fillAgentServiceEnterpriseMeta(expectWebResponse, structs.DefaultEnterpriseMeta())
fillAgentServiceEnterpriseMeta(expectWebResponse, structs.DefaultEnterpriseMetaInDefaultPartition())
tests := []struct {
name string
@ -2973,7 +2973,7 @@ func testAgent_RegisterService(t *testing.T, extraHCL string) {
}
// Ensure we have a check mapping
checks := a.State.Checks(structs.WildcardEnterpriseMeta())
checks := a.State.Checks(structs.WildcardEnterpriseMetaInDefaultPartition())
if len(checks) != 3 {
t.Fatalf("bad: %v", checks)
}
@ -3063,7 +3063,7 @@ func testAgent_RegisterService_ReRegister(t *testing.T, extraHCL string) {
_, err = a.srv.AgentRegisterService(nil, req)
require.NoError(t, err)
checks := a.State.Checks(structs.DefaultEnterpriseMeta())
checks := a.State.Checks(structs.DefaultEnterpriseMetaInDefaultPartition())
require.Equal(t, 3, len(checks))
checkIDs := []string{}
@ -3142,7 +3142,7 @@ func testAgent_RegisterService_ReRegister_ReplaceExistingChecks(t *testing.T, ex
_, err = a.srv.AgentRegisterService(nil, req)
require.NoError(t, err)
checks := a.State.Checks(structs.DefaultEnterpriseMeta())
checks := a.State.Checks(structs.DefaultEnterpriseMetaInDefaultPartition())
require.Len(t, checks, 2)
checkIDs := []string{}
@ -3319,7 +3319,7 @@ func testAgent_RegisterService_TranslateKeys(t *testing.T, extraHCL string) {
// there worked by inspecting the registered sidecar below.
SidecarService: nil,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
got := a.State.Service(structs.NewServiceID("test", nil))
@ -3356,7 +3356,7 @@ func testAgent_RegisterService_TranslateKeys(t *testing.T, extraHCL string) {
},
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
gotSidecar := a.State.Service(structs.NewServiceID("test-sidecar-proxy", nil))
hasNoCorrectTCPCheck := true
@ -3567,7 +3567,7 @@ func testDefaultSidecar(svc string, port int, fns ...func(*structs.NodeService))
LocalServiceAddress: "127.0.0.1",
LocalServicePort: port,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
for _, fn := range fns {
fn(ns)
@ -3925,7 +3925,7 @@ func testAgent_RegisterServiceDeregisterService_Sidecar(t *testing.T, extraHCL s
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
// After we deregister the web service above, the fake sidecar with
// clashing ID SHOULD NOT have been removed since it wasn't part of the
@ -3972,7 +3972,7 @@ func testAgent_RegisterServiceDeregisterService_Sidecar(t *testing.T, extraHCL s
LocalServiceAddress: "127.0.0.1",
LocalServicePort: 1111,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
{

View File

@ -422,7 +422,7 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
Tags: []string{"tag1"},
Weights: nil, // nil weights...
Port: 8100,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
// ... should be populated to avoid "IsSame" returning true during AE.
func(ns *structs.NodeService) {
@ -450,7 +450,7 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
ServiceName: "svcname1",
ServiceTags: []string{"tag1"},
Type: "ttl",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -465,7 +465,7 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
},
Tags: []string{"tag2"},
Port: 8200,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
nil, // No change expected
[]*structs.CheckType{
@ -498,7 +498,7 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
Type: "ttl",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
"check-noname": {
Node: "node1",
@ -509,7 +509,7 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
Type: "ttl",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
"service:svcid2:3": {
Node: "node1",
@ -520,7 +520,7 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
Type: "ttl",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
"service:svcid2:4": {
Node: "node1",
@ -531,7 +531,7 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
Type: "ttl",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -696,11 +696,11 @@ func test_createAlias(t *testing.T, agent *TestAgent, chk *structs.CheckType, ex
return func(r *retry.R) {
t.Helper()
found := false
for _, c := range agent.State.CheckStates(structs.WildcardEnterpriseMeta()) {
for _, c := range agent.State.CheckStates(structs.WildcardEnterpriseMetaInDefaultPartition()) {
if c.Check.CheckID == chk.CheckID {
found = true
assert.Equal(t, expectedResult, c.Check.Status, "Check state should be %s, was %s in %#v", expectedResult, c.Check.Status, c.Check)
srvID := structs.NewServiceID(srv.ID, structs.WildcardEnterpriseMeta())
srvID := structs.NewServiceID(srv.ID, structs.WildcardEnterpriseMetaInDefaultPartition())
if err := agent.Agent.State.RemoveService(srvID); err != nil {
fmt.Println("[DEBUG] Fail to remove service", srvID, ", err:=", err)
}
@ -766,7 +766,7 @@ func TestAgent_CheckAliasRPC(t *testing.T) {
err := a.RPC("Catalog.NodeServices", &args, &out)
assert.NoError(r, err)
foundService := false
lookup := structs.NewServiceID("svcid1", structs.WildcardEnterpriseMeta())
lookup := structs.NewServiceID("svcid1", structs.WildcardEnterpriseMetaInDefaultPartition())
for _, srv := range out.NodeServices.Services {
if lookup.Matches(srv.CompoundServiceID()) {
foundService = true
@ -804,7 +804,7 @@ func TestAgent_CheckAliasRPC(t *testing.T) {
for i := 0; i < 50; i++ {
unlockIndexOnNode()
allNonWarning := true
for _, chk := range a.State.Checks(structs.WildcardEnterpriseMeta()) {
for _, chk := range a.State.Checks(structs.WildcardEnterpriseMetaInDefaultPartition()) {
if chk.Status == api.HealthWarning {
allNonWarning = false
}
@ -1217,7 +1217,7 @@ func testAgent_RemoveServiceRemovesAllChecks(t *testing.T, extraHCL string) {
node_name = "node1"
`+extraHCL)
defer a.Shutdown()
svc := &structs.NodeService{ID: "redis", Service: "redis", Port: 8000, EnterpriseMeta: *structs.DefaultEnterpriseMeta()}
svc := &structs.NodeService{ID: "redis", Service: "redis", Port: 8000, EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition()}
chk1 := &structs.CheckType{CheckID: "chk1", Name: "chk1", TTL: time.Minute}
chk2 := &structs.CheckType{CheckID: "chk2", Name: "chk2", TTL: 2 * time.Minute}
hchk1 := &structs.HealthCheck{
@ -1228,7 +1228,7 @@ func testAgent_RemoveServiceRemovesAllChecks(t *testing.T, extraHCL string) {
ServiceID: "redis",
ServiceName: "redis",
Type: "ttl",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
hchk2 := &structs.HealthCheck{Node: "node1",
CheckID: "chk2",
@ -1237,7 +1237,7 @@ func testAgent_RemoveServiceRemovesAllChecks(t *testing.T, extraHCL string) {
ServiceID: "redis",
ServiceName: "redis",
Type: "ttl",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
// register service with chk1
@ -2321,7 +2321,7 @@ func testAgent_persistedService_compat(t *testing.T, extraHCL string) {
Port: 8000,
TaggedAddresses: map[string]structs.ServiceAddress{},
Weights: &structs.Weights{Passing: 1, Warning: 1},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
// Encode the NodeService directly. This is what previous versions
@ -2607,7 +2607,7 @@ func TestAgent_PurgeCheckOnDuplicate(t *testing.T) {
CheckID: "mem",
Name: "memory check",
Status: api.HealthPassing,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
// First persist the check
@ -2648,7 +2648,7 @@ func TestAgent_PurgeCheckOnDuplicate(t *testing.T) {
Name: "memory check",
Status: api.HealthCritical,
Notes: "my cool notes",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
require.Equal(t, expected, result)
}
@ -2679,7 +2679,7 @@ func TestAgent_DeregisterPersistedSidecarAfterRestart(t *testing.T) {
},
Tags: []string{"tag2"},
Port: 8200,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Connect: structs.ServiceConnect{
SidecarService: &structs.ServiceDefinition{},
@ -3051,7 +3051,7 @@ func testAgent_unloadServices(t *testing.T, extraHCL string) {
if err := a.unloadServices(); err != nil {
t.Fatalf("err: %s", err)
}
if len(a.State.Services(structs.WildcardEnterpriseMeta())) != 0 {
if len(a.State.Services(structs.WildcardEnterpriseMetaInDefaultPartition())) != 0 {
t.Fatalf("should have unloaded services")
}
}
@ -3160,7 +3160,7 @@ func TestAgent_Service_Reap(t *testing.T) {
// Make sure it's there and there's no critical check yet.
requireServiceExists(t, a, "redis")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMeta()), 0, "should not have critical checks")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMetaInDefaultPartition()), 0, "should not have critical checks")
// Wait for the check TTL to fail but before the check is reaped.
time.Sleep(100 * time.Millisecond)
@ -3172,17 +3172,17 @@ func TestAgent_Service_Reap(t *testing.T) {
t.Fatalf("err: %v", err)
}
requireServiceExists(t, a, "redis")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMeta()), 0, "should not have critical checks")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMetaInDefaultPartition()), 0, "should not have critical checks")
// Wait for the check TTL to fail again.
time.Sleep(100 * time.Millisecond)
requireServiceExists(t, a, "redis")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMeta()), 1, "should have 1 critical check")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMetaInDefaultPartition()), 1, "should have 1 critical check")
// Wait for the reap.
time.Sleep(400 * time.Millisecond)
requireServiceMissing(t, a, "redis")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMeta()), 0, "should not have critical checks")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMetaInDefaultPartition()), 0, "should not have critical checks")
}
func TestAgent_Service_NoReap(t *testing.T) {
@ -3217,17 +3217,17 @@ func TestAgent_Service_NoReap(t *testing.T) {
// Make sure it's there and there's no critical check yet.
requireServiceExists(t, a, "redis")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMeta()), 0)
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMetaInDefaultPartition()), 0)
// Wait for the check TTL to fail.
time.Sleep(200 * time.Millisecond)
requireServiceExists(t, a, "redis")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMeta()), 1)
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMetaInDefaultPartition()), 1)
// Wait a while and make sure it doesn't reap.
time.Sleep(200 * time.Millisecond)
requireServiceExists(t, a, "redis")
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMeta()), 1)
require.Len(t, a.State.CriticalCheckStates(structs.WildcardEnterpriseMetaInDefaultPartition()), 1)
}
func TestAgent_AddService_restoresSnapshot(t *testing.T) {

View File

@ -31,7 +31,7 @@ func newLeaf(t *testing.T, agentName, datacenter string, ca *structs.CARoot, idx
ValidBefore: cert.NotAfter,
Agent: agentID.Agent,
AgentURI: agentID.URI().String(),
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
RaftIndex: structs.RaftIndex{
CreateIndex: idx,
ModifyIndex: idx,

View File

@ -108,7 +108,7 @@ func (c *CheckAlias) runLocal(stopCh chan struct{}) {
}
updateStatus := func() {
checks := c.Notify.Checks(structs.WildcardEnterpriseMeta())
checks := c.Notify.Checks(structs.WildcardEnterpriseMetaInDefaultPartition())
checksList := make([]*structs.HealthCheck, 0, len(checks))
for _, chk := range checks {
checksList = append(checksList, chk)

View File

@ -2273,7 +2273,7 @@ func (b *builder) autoConfigAuthorizerVal(raw AutoConfigAuthorizationRaw) AutoCo
val.AuthMethod = structs.ACLAuthMethod{
Name: "Auto Config Authorizer",
Type: "jwt",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Config: map[string]interface{}{
"JWTSupportedAlgs": raw.Static.JWTSupportedAlgs,
"BoundAudiences": raw.Static.BoundAudiences,

View File

@ -8,5 +8,5 @@ import "github.com/hashicorp/consul/agent/structs"
type EnterpriseMeta struct{}
func (_ *EnterpriseMeta) ToStructs() structs.EnterpriseMeta {
return *structs.DefaultEnterpriseMeta()
return *structs.DefaultEnterpriseMetaInDefaultPartition()
}

View File

@ -74,7 +74,7 @@ func TestLoad_IntegrationWithFlags(t *testing.T) {
}
}
defaultEntMeta := structs.DefaultEnterpriseMeta()
defaultEntMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
// ------------------------------------------------------------
// cmd line flags
@ -5184,7 +5184,7 @@ func TestLoad_FullConfig(t *testing.T) {
return n
}
defaultEntMeta := structs.DefaultEnterpriseMeta()
defaultEntMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
expected := &RuntimeConfig{
// non-user configurable values
ACLDisabledTTL: 120 * time.Second,
@ -5378,7 +5378,7 @@ func TestLoad_FullConfig(t *testing.T) {
AuthMethod: structs.ACLAuthMethod{
Name: "Auto Config Authorizer",
Type: "jwt",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Config: map[string]interface{}{
"JWTValidationPubKeys": []string{"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAERVchfCZng4mmdvQz1+sJHRN40snC\nYt8NjYOnbnScEXMkyoUmASr88gb7jaVAVt3RYASAbgBjB2Z+EUizWkx5Tg==\n-----END PUBLIC KEY-----"},
"ClaimMappings": map[string]string{

View File

@ -292,11 +292,11 @@ func TestConfig_Apply_TerminatingGateway(t *testing.T) {
CAFile: "/etc/web/ca.crt",
CertFile: "/etc/web/client.crt",
KeyFile: "/etc/web/tls.key",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "api",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
require.Equal(t, expect, got.Services)
@ -361,12 +361,12 @@ func TestConfig_Apply_IngressGateway(t *testing.T) {
Services: []structs.IngressService{
{
Name: "web",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
require.Equal(t, expect, got)
}

View File

@ -141,7 +141,7 @@ func (id *missingIdentity) IsLocal() bool {
}
func (id *missingIdentity) EnterpriseMetadata() *structs.EnterpriseMeta {
return structs.DefaultEnterpriseMeta()
return structs.DefaultEnterpriseMetaInDefaultPartition()
}
func minTTL(a time.Duration, b time.Duration) time.Duration {
@ -1417,7 +1417,7 @@ func (f *aclFilter) filterNodeServices(services **structs.NodeServices) {
}
var authzContext acl.AuthorizerContext
structs.WildcardEnterpriseMeta().FillAuthzContext(&authzContext)
structs.WildcardEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
if !f.allowNode((*services).Node.Node, &authzContext) {
*services = nil
return
@ -1441,7 +1441,7 @@ func (f *aclFilter) filterNodeServiceList(services **structs.NodeServiceList) {
}
var authzContext acl.AuthorizerContext
structs.WildcardEnterpriseMeta().FillAuthzContext(&authzContext)
structs.WildcardEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
if !f.allowNode((*services).Node.Node, &authzContext) {
*services = nil
return
@ -1538,7 +1538,7 @@ func (f *aclFilter) filterSessions(sessions *structs.Sessions) {
func (f *aclFilter) filterCoordinates(coords *structs.Coordinates) {
c := *coords
var authzContext acl.AuthorizerContext
structs.WildcardEnterpriseMeta().FillAuthzContext(&authzContext)
structs.WildcardEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
for i := 0; i < len(c); i++ {
node := c[i].Node
@ -1579,7 +1579,7 @@ func (f *aclFilter) filterNodeDump(dump *structs.NodeDump) {
info := nd[i]
// Filter nodes
structs.WildcardEnterpriseMeta().FillAuthzContext(&authzContext)
structs.WildcardEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
if node := info.Node; !f.allowNode(node, &authzContext) {
f.logger.Debug("dropping node from result due to ACLs", "node", node)
nd = append(nd[:i], nd[i+1:]...)
@ -1647,7 +1647,7 @@ func (f *aclFilter) filterNodes(nodes *structs.Nodes) {
n := *nodes
var authzContext acl.AuthorizerContext
structs.WildcardEnterpriseMeta().FillAuthzContext(&authzContext)
structs.WildcardEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
for i := 0; i < len(n); i++ {
node := n[i].Node
@ -1670,7 +1670,7 @@ func (f *aclFilter) filterNodes(nodes *structs.Nodes) {
func (f *aclFilter) redactPreparedQueryTokens(query **structs.PreparedQuery) {
// Management tokens can see everything with no filtering.
var authzContext acl.AuthorizerContext
structs.DefaultEnterpriseMeta().FillAuthzContext(&authzContext)
structs.DefaultEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
if f.authorizer.ACLWrite(&authzContext) == acl.Allow {
return
}
@ -1696,7 +1696,7 @@ func (f *aclFilter) redactPreparedQueryTokens(query **structs.PreparedQuery) {
// if the user doesn't have a management token.
func (f *aclFilter) filterPreparedQueries(queries *structs.PreparedQueries) {
var authzContext acl.AuthorizerContext
structs.DefaultEnterpriseMeta().FillAuthzContext(&authzContext)
structs.DefaultEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
// Management tokens can see everything with no filtering.
// TODO is this check even necessary - this looks like a search replace from
// the 1.4 ACL rewrite. The global-management token will provide unrestricted query privileges

View File

@ -104,7 +104,7 @@ func (c *Client) ResolveTokenAndDefaultMeta(token string, entMeta *structs.Enter
if identity != nil {
entMeta.Merge(identity.EnterpriseMetadata())
} else {
entMeta.Merge(structs.DefaultEnterpriseMeta())
entMeta.Merge(structs.DefaultEnterpriseMetaInDefaultPartition())
}
// Use the meta to fill in the ACL authorization context

View File

@ -244,7 +244,7 @@ func (a *ACL) BootstrapTokens(args *structs.DCSpecificRequest, reply *structs.AC
Local: false,
// DEPRECATED (ACL-Legacy-Compat) - This is used so that the bootstrap token is still visible via the v1 acl APIs
Type: structs.ACLTokenTypeManagement,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
ResetIndex: specifiedIndex,
}
@ -256,7 +256,7 @@ func (a *ACL) BootstrapTokens(args *structs.DCSpecificRequest, reply *structs.AC
return err
}
if _, token, err := state.ACLTokenGetByAccessor(nil, accessor, structs.DefaultEnterpriseMeta()); err == nil {
if _, token, err := state.ACLTokenGetByAccessor(nil, accessor, structs.DefaultEnterpriseMetaInDefaultPartition()); err == nil {
*reply = *token
}

View File

@ -4991,7 +4991,7 @@ func TestACLEndpoint_Login_with_MaxTokenTTL(t *testing.T) {
got.SecretID = ""
got.Hash = nil
defaultEntMeta := structs.DefaultEnterpriseMeta()
defaultEntMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
expect := &structs.ACLToken{
AuthMethod: method.Name,
Description: `token created via login: {"pod":"pod1"}`,
@ -5102,7 +5102,7 @@ func TestACLEndpoint_Login_with_TokenLocality(t *testing.T) {
got.SecretID = ""
got.Hash = nil
defaultEntMeta := structs.DefaultEnterpriseMeta()
defaultEntMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
expect := &structs.ACLToken{
AuthMethod: method.Name,
Description: `token created via login: {"pod":"pod1"}`,

View File

@ -111,7 +111,7 @@ func (s *Server) canUpgradeToNewACLs(isLeader bool) bool {
// Check to see if we already upgraded the last time we ran by seeing if we
// have a copy of any global management policy stored locally. This should
// always be true because policies always replicate.
_, mgmtPolicy, err := s.fsm.State().ACLPolicyGetByID(nil, structs.ACLPolicyGlobalManagementID, structs.DefaultEnterpriseMeta())
_, mgmtPolicy, err := s.fsm.State().ACLPolicyGetByID(nil, structs.ACLPolicyGlobalManagementID, structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
s.logger.Warn("Failed to get the builtin global-management policy to check for a completed ACL upgrade; skipping this optimization", "error", err)
} else if mgmtPolicy != nil {
@ -252,7 +252,7 @@ func (s *Server) ResolveTokenIdentityAndDefaultMeta(token string, entMeta *struc
if identity != nil {
entMeta.Merge(identity.EnterpriseMetadata())
} else {
entMeta.Merge(structs.DefaultEnterpriseMeta())
entMeta.Merge(structs.DefaultEnterpriseMetaInDefaultPartition())
}
// Use the meta to fill in the ACL authorization context

View File

@ -209,7 +209,7 @@ func (ac *AutoConfig) updateACLsInConfig(opts AutoConfigOptions, resp *pbautocon
Datacenter: ac.config.Datacenter,
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
token, err := ac.backend.CreateACLToken(&template)

View File

@ -138,7 +138,7 @@ func TestAutoConfigInitialConfiguration(t *testing.T) {
c.AutoConfigAuthzAuthMethod = structs.ACLAuthMethod{
Name: "Auth Config Authorizer",
Type: "jwt",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Config: map[string]interface{}{
"BoundAudiences": []string{"consul"},
"BoundIssuer": "consul",
@ -584,7 +584,7 @@ func TestAutoConfig_updateTLSCertificatesInConfig(t *testing.T) {
CertPEM: "not-currently-decoded",
ValidAfter: now,
ValidBefore: later,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
RaftIndex: structs.RaftIndex{
ModifyIndex: 10,
CreateIndex: 10,
@ -797,7 +797,7 @@ func TestAutoConfig_updateACLsInConfig(t *testing.T) {
Datacenter: testDC,
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
testToken := &structs.ACLToken{
@ -811,7 +811,7 @@ func TestAutoConfig_updateACLsInConfig(t *testing.T) {
Datacenter: testDC,
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
if tcase.expectACLToken {

View File

@ -479,7 +479,7 @@ func (c *ConfigEntry) ResolveServiceConfig(args *structs.ServiceConfigRequest, r
cfgMap := make(map[string]interface{})
upstreamDefaults.MergeInto(cfgMap)
wildcard := structs.NewServiceID(structs.WildcardSpecifier, structs.WildcardEnterpriseMeta())
wildcard := structs.NewServiceID(structs.WildcardSpecifier, structs.WildcardEnterpriseMetaInDefaultPartition())
usConfigs[wildcard] = cfgMap
}
}

View File

@ -1020,9 +1020,9 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
}
t.Parallel()
mysql := structs.NewServiceID("mysql", structs.DefaultEnterpriseMeta())
cache := structs.NewServiceID("cache", structs.DefaultEnterpriseMeta())
wildcard := structs.NewServiceID(structs.WildcardSpecifier, structs.WildcardEnterpriseMeta())
mysql := structs.NewServiceID("mysql", structs.DefaultEnterpriseMetaInDefaultPartition())
cache := structs.NewServiceID("cache", structs.DefaultEnterpriseMetaInDefaultPartition())
wildcard := structs.NewServiceID(structs.WildcardSpecifier, structs.WildcardEnterpriseMetaInDefaultPartition())
tt := []struct {
name string
@ -1117,7 +1117,7 @@ func TestConfigEntry_ResolveServiceConfig_Upstreams(t *testing.T) {
{
Upstream: structs.ServiceID{
ID: "mysql",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Config: map[string]interface{}{
"protocol": "http",

View File

@ -186,7 +186,7 @@ func (s *ConnectCA) Sign(
"we are %s", serviceID.Datacenter, s.srv.config.Datacenter)
}
} else if isAgent {
structs.DefaultEnterpriseMeta().FillAuthzContext(&authzContext)
structs.DefaultEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
if rule != nil && rule.NodeWrite(agentID.Agent, &authzContext) != acl.Allow {
return acl.ErrPermissionDenied
}

View File

@ -144,7 +144,7 @@ func (c *Coordinate) Update(args *structs.CoordinateUpdateRequest, reply *struct
}
if authz != nil {
var authzContext acl.AuthorizerContext
structs.DefaultEnterpriseMeta().FillAuthzContext(&authzContext)
structs.DefaultEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
if authz.NodeWrite(args.Node, &authzContext) != acl.Allow {
return acl.ErrPermissionDenied
}
@ -227,7 +227,7 @@ func (c *Coordinate) Node(args *structs.NodeSpecificRequest, reply *structs.Inde
}
if authz != nil {
var authzContext acl.AuthorizerContext
structs.WildcardEnterpriseMeta().FillAuthzContext(&authzContext)
structs.WildcardEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
if authz.NodeRead(args.Node, &authzContext) != acl.Allow {
return acl.ErrPermissionDenied
}

View File

@ -5,5 +5,5 @@ package discoverychain
import "github.com/hashicorp/consul/agent/structs"
func (c *compiler) GetEnterpriseMeta() *structs.EnterpriseMeta {
return structs.DefaultEnterpriseMeta()
return structs.DefaultEnterpriseMetaInDefaultPartition()
}

View File

@ -47,7 +47,7 @@ func (t *txnResultsFilter) Filter(i int) bool {
result.KV.EnterpriseMeta.FillAuthzContext(&authzContext)
return t.authorizer.KeyRead(result.KV.Key, &authzContext) != acl.Allow
case result.Node != nil:
structs.WildcardEnterpriseMeta().FillAuthzContext(&authzContext)
structs.WildcardEnterpriseMetaInDefaultPartition().FillAuthzContext(&authzContext)
return t.authorizer.NodeRead(result.Node.Node, &authzContext) != acl.Allow
case result.Service != nil:
result.Service.EnterpriseMeta.FillAuthzContext(&authzContext)

View File

@ -80,7 +80,7 @@ func TestFSM_RegisterNode(t *testing.T) {
}
// Verify service registered
_, services, err := fsm.state.NodeServices(nil, "foo", structs.DefaultEnterpriseMeta())
_, services, err := fsm.state.NodeServices(nil, "foo", structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -135,7 +135,7 @@ func TestFSM_RegisterNode_Service(t *testing.T) {
}
// Verify service registered
_, services, err := fsm.state.NodeServices(nil, "foo", structs.DefaultEnterpriseMeta())
_, services, err := fsm.state.NodeServices(nil, "foo", structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -144,7 +144,7 @@ func TestFSM_RegisterNode_Service(t *testing.T) {
}
// Verify check
_, checks, err := fsm.state.NodeChecks(nil, "foo", structs.DefaultEnterpriseMeta())
_, checks, err := fsm.state.NodeChecks(nil, "foo", structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -207,7 +207,7 @@ func TestFSM_DeregisterService(t *testing.T) {
}
// Verify service not registered
_, services, err := fsm.state.NodeServices(nil, "foo", structs.DefaultEnterpriseMeta())
_, services, err := fsm.state.NodeServices(nil, "foo", structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -270,7 +270,7 @@ func TestFSM_DeregisterCheck(t *testing.T) {
}
// Verify check not registered
_, checks, err := fsm.state.NodeChecks(nil, "foo", structs.DefaultEnterpriseMeta())
_, checks, err := fsm.state.NodeChecks(nil, "foo", structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -339,7 +339,7 @@ func TestFSM_DeregisterNode(t *testing.T) {
}
// Verify service not registered
_, services, err := fsm.state.NodeServices(nil, "foo", structs.DefaultEnterpriseMeta())
_, services, err := fsm.state.NodeServices(nil, "foo", structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -348,7 +348,7 @@ func TestFSM_DeregisterNode(t *testing.T) {
}
// Verify checks not registered
_, checks, err := fsm.state.NodeChecks(nil, "foo", structs.DefaultEnterpriseMeta())
_, checks, err := fsm.state.NodeChecks(nil, "foo", structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -1441,7 +1441,7 @@ func TestFSM_ConfigEntry(t *testing.T) {
Config: map[string]interface{}{
"foo": "bar",
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
// Create a new request.
@ -1595,7 +1595,7 @@ func TestFSM_Chunking_Lifecycle(t *testing.T) {
assert.NotNil(node)
// Verify service registered
_, services, err := fsm2.state.NodeServices(nil, fmt.Sprintf("foo%d", i), structs.DefaultEnterpriseMeta())
_, services, err := fsm2.state.NodeServices(nil, fmt.Sprintf("foo%d", i), structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(err)
require.NotNil(services)
_, ok := services.Services["db"]

View File

@ -253,7 +253,7 @@ func TestFSM_SnapshotRestore_OSS(t *testing.T) {
},
}
require.NoError(t, fsm.state.EnsureConfigEntry(20, ingress))
_, gatewayServices, err := fsm.state.GatewayServices(nil, "ingress", structs.DefaultEnterpriseMeta())
_, gatewayServices, err := fsm.state.GatewayServices(nil, "ingress", structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
// Raft Chunking
@ -641,7 +641,7 @@ func TestFSM_SnapshotRestore_OSS(t *testing.T) {
require.Equal(t, autopilotConf, restoredConf)
// Verify legacy intentions are restored.
_, ixns, err := fsm2.state.LegacyIntentions(nil, structs.WildcardEnterpriseMeta())
_, ixns, err := fsm2.state.LegacyIntentions(nil, structs.WildcardEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
require.Len(t, ixns, 1)
require.Equal(t, ixn, ixns[0])
@ -663,19 +663,19 @@ func TestFSM_SnapshotRestore_OSS(t *testing.T) {
require.Equal(t, caConfig, caConf)
// Verify config entries are restored
_, serviceConfEntry, err := fsm2.state.ConfigEntry(nil, structs.ServiceDefaults, "foo", structs.DefaultEnterpriseMeta())
_, serviceConfEntry, err := fsm2.state.ConfigEntry(nil, structs.ServiceDefaults, "foo", structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
require.Equal(t, serviceConfig, serviceConfEntry)
_, proxyConfEntry, err := fsm2.state.ConfigEntry(nil, structs.ProxyDefaults, "global", structs.DefaultEnterpriseMeta())
_, proxyConfEntry, err := fsm2.state.ConfigEntry(nil, structs.ProxyDefaults, "global", structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
require.Equal(t, proxyConfig, proxyConfEntry)
_, ingressRestored, err := fsm2.state.ConfigEntry(nil, structs.IngressGateway, "ingress", structs.DefaultEnterpriseMeta())
_, ingressRestored, err := fsm2.state.ConfigEntry(nil, structs.IngressGateway, "ingress", structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
require.Equal(t, ingress, ingressRestored)
_, restoredGatewayServices, err := fsm2.state.GatewayServices(nil, "ingress", structs.DefaultEnterpriseMeta())
_, restoredGatewayServices, err := fsm2.state.GatewayServices(nil, "ingress", structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
require.Equal(t, gatewayServices, restoredGatewayServices)
@ -704,12 +704,12 @@ func TestFSM_SnapshotRestore_OSS(t *testing.T) {
require.Equal(t, systemMetadataEntry, systemMetadataLoaded[0])
// Verify service-intentions is restored
_, serviceIxnEntry, err := fsm2.state.ConfigEntry(nil, structs.ServiceIntentions, "foo", structs.DefaultEnterpriseMeta())
_, serviceIxnEntry, err := fsm2.state.ConfigEntry(nil, structs.ServiceIntentions, "foo", structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
require.Equal(t, serviceIxn, serviceIxnEntry)
// Verify mesh config entry is restored
_, meshConfigEntry, err := fsm2.state.ConfigEntry(nil, structs.MeshConfig, structs.MeshConfigMesh, structs.DefaultEnterpriseMeta())
_, meshConfigEntry, err := fsm2.state.ConfigEntry(nil, structs.MeshConfig, structs.MeshConfigMesh, structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
require.Equal(t, meshConfig, meshConfigEntry)

View File

@ -377,7 +377,7 @@ func TestIntentionApply_WithoutIDs(t *testing.T) {
waitForLeaderEstablishment(t, s1)
defaultEntMeta := structs.DefaultEnterpriseMeta()
defaultEntMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
// Force "test" to be L7-capable.
{
@ -413,7 +413,7 @@ func TestIntentionApply_WithoutIDs(t *testing.T) {
opList := func() (*structs.IndexedIntentions, error) {
req := &structs.IntentionListRequest{
Datacenter: "dc1",
EnterpriseMeta: *structs.WildcardEnterpriseMeta(),
EnterpriseMeta: *structs.WildcardEnterpriseMetaInDefaultPartition(),
}
var resp structs.IndexedIntentions
if err := msgpackrpc.CallWithCodec(codec, "Intention.List", req, &resp); err != nil {

View File

@ -885,7 +885,7 @@ func TestInternal_GatewayServiceDump_Terminating(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Checks: structs.HealthChecks{
{
@ -895,7 +895,7 @@ func TestInternal_GatewayServiceDump_Terminating(t *testing.T) {
Status: "passing",
ServiceID: "db2",
ServiceName: "db",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
GatewayService: &structs.GatewayService{
@ -917,7 +917,7 @@ func TestInternal_GatewayServiceDump_Terminating(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Checks: structs.HealthChecks{
{
@ -927,7 +927,7 @@ func TestInternal_GatewayServiceDump_Terminating(t *testing.T) {
Status: "warning",
ServiceID: "db",
ServiceName: "db",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
GatewayService: &structs.GatewayService{
@ -1225,7 +1225,7 @@ func TestInternal_GatewayServiceDump_Ingress(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Checks: structs.HealthChecks{
{
@ -1235,7 +1235,7 @@ func TestInternal_GatewayServiceDump_Ingress(t *testing.T) {
Status: "warning",
ServiceID: "db",
ServiceName: "db",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
GatewayService: &structs.GatewayService{
@ -1259,7 +1259,7 @@ func TestInternal_GatewayServiceDump_Ingress(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Checks: structs.HealthChecks{
{
@ -1269,7 +1269,7 @@ func TestInternal_GatewayServiceDump_Ingress(t *testing.T) {
Status: "passing",
ServiceID: "db2",
ServiceName: "db",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
GatewayService: &structs.GatewayService{
@ -1706,10 +1706,10 @@ func TestInternal_ServiceTopology(t *testing.T) {
registerTestTopologyEntries(t, codec, "")
var (
ingress = structs.NewServiceName("ingress", structs.DefaultEnterpriseMeta())
api = structs.NewServiceName("api", structs.DefaultEnterpriseMeta())
web = structs.NewServiceName("web", structs.DefaultEnterpriseMeta())
redis = structs.NewServiceName("redis", structs.DefaultEnterpriseMeta())
ingress = structs.NewServiceName("ingress", structs.DefaultEnterpriseMetaInDefaultPartition())
api = structs.NewServiceName("api", structs.DefaultEnterpriseMetaInDefaultPartition())
web = structs.NewServiceName("web", structs.DefaultEnterpriseMetaInDefaultPartition())
redis = structs.NewServiceName("redis", structs.DefaultEnterpriseMetaInDefaultPartition())
)
t.Run("ingress", func(t *testing.T) {
@ -2027,7 +2027,7 @@ func TestInternal_IntentionUpstreams(t *testing.T) {
require.Len(r, out.Services, 1)
expectUp := structs.ServiceList{
structs.NewServiceName("api", structs.DefaultEnterpriseMeta()),
structs.NewServiceName("api", structs.DefaultEnterpriseMetaInDefaultPartition()),
}
require.Equal(r, expectUp, out.Services)
})
@ -2083,7 +2083,7 @@ service_prefix "api" { policy = "read" }
require.Len(r, out.Services, 1)
expectUp := structs.ServiceList{
structs.NewServiceName("api", structs.DefaultEnterpriseMeta()),
structs.NewServiceName("api", structs.DefaultEnterpriseMetaInDefaultPartition()),
}
require.Equal(r, expectUp, out.Services)
})

View File

@ -533,7 +533,7 @@ func (s *Server) initializeACLs(ctx context.Context, upgrade bool) error {
s.logger.Info("initializing acls")
// Create/Upgrade the builtin global-management policy
_, policy, err := s.fsm.State().ACLPolicyGetByID(nil, structs.ACLPolicyGlobalManagementID, structs.DefaultEnterpriseMeta())
_, policy, err := s.fsm.State().ACLPolicyGetByID(nil, structs.ACLPolicyGlobalManagementID, structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
return fmt.Errorf("failed to get the builtin global-management policy")
}
@ -544,7 +544,7 @@ func (s *Server) initializeACLs(ctx context.Context, upgrade bool) error {
Description: "Builtin Policy that grants unlimited access",
Rules: structs.ACLPolicyGlobalManagement,
Syntax: acl.SyntaxCurrent,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
if policy != nil {
newPolicy.Name = policy.Name
@ -595,7 +595,7 @@ func (s *Server) initializeACLs(ctx context.Context, upgrade bool) error {
// DEPRECATED (ACL-Legacy-Compat) - only needed for compatibility
Type: structs.ACLTokenTypeManagement,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
token.SetHash(true)
@ -654,7 +654,7 @@ func (s *Server) initializeACLs(ctx context.Context, upgrade bool) error {
SecretID: anonymousToken,
Description: "Anonymous Token",
CreateTime: time.Now(),
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
token.SetHash(true)
@ -1112,7 +1112,7 @@ func (s *Server) bootstrapConfigEntries(entries []structs.ConfigEntry) error {
// We generate a "reap" event to cause the node to be cleaned up.
func (s *Server) reconcileReaped(known map[string]struct{}) error {
state := s.fsm.State()
_, checks, err := state.ChecksInState(nil, api.HealthAny, structs.DefaultEnterpriseMeta())
_, checks, err := state.ChecksInState(nil, api.HealthAny, structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}
@ -1128,7 +1128,7 @@ func (s *Server) reconcileReaped(known map[string]struct{}) error {
}
// Get the node services, look for ConsulServiceID
_, services, err := state.NodeServices(nil, check.Node, structs.DefaultEnterpriseMeta())
_, services, err := state.NodeServices(nil, check.Node, structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}
@ -1270,7 +1270,7 @@ func (s *Server) handleAliveMember(member serf.Member) error {
// Check if the associated service is available
if service != nil {
match := false
_, services, err := state.NodeServices(nil, member.Name, structs.DefaultEnterpriseMeta())
_, services, err := state.NodeServices(nil, member.Name, structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}
@ -1288,7 +1288,7 @@ func (s *Server) handleAliveMember(member serf.Member) error {
}
// Check if the serfCheck is in the passing state
_, checks, err := state.NodeChecks(nil, member.Name, structs.DefaultEnterpriseMeta())
_, checks, err := state.NodeChecks(nil, member.Name, structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}
@ -1342,7 +1342,7 @@ func (s *Server) handleFailedMember(member serf.Member) error {
if node.Address == member.Addr.String() {
// Check if the serfCheck is in the critical state
_, checks, err := state.NodeChecks(nil, member.Name, structs.DefaultEnterpriseMeta())
_, checks, err := state.NodeChecks(nil, member.Name, structs.DefaultEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}

View File

@ -1430,7 +1430,7 @@ func (c *CAManager) SignCertificate(csr *x509.CertificateRequest, spiffeID conne
csr.URIs = uris
}
entMeta.Merge(structs.DefaultEnterpriseMeta())
entMeta.Merge(structs.DefaultEnterpriseMetaInDefaultPartition())
}
commonCfg, err := config.GetCommonConfig()

View File

@ -156,7 +156,7 @@ func (s *Server) fetchFederationStateAntiEntropyDetails(
}
// Fetch our current list of all mesh gateways.
entMeta := structs.WildcardEnterpriseMeta()
entMeta := structs.WildcardEnterpriseMetaInDefaultPartition()
idx2, raw, err := state.ServiceDump(ws, structs.ServiceKindMeshGateway, true, entMeta)
if err != nil {
return err

View File

@ -38,7 +38,7 @@ func (s *Server) startIntentionConfigEntryMigration(ctx context.Context) error {
// datacenter is composed entirely of compatible servers and there are
// no more legacy intentions.
if s.DatacenterSupportsIntentionsAsConfigEntries() {
_, ixns, err := s.fsm.State().LegacyIntentions(nil, structs.WildcardEnterpriseMeta())
_, ixns, err := s.fsm.State().LegacyIntentions(nil, structs.WildcardEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}
@ -88,7 +88,7 @@ func (s *Server) legacyIntentionMigration(ctx context.Context) error {
}
state := s.fsm.State()
_, ixns, err := state.LegacyIntentions(nil, structs.WildcardEnterpriseMeta())
_, ixns, err := state.LegacyIntentions(nil, structs.WildcardEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}

View File

@ -457,7 +457,7 @@ func TestLeader_LegacyIntentionMigration(t *testing.T) {
checkIntentions := func(t *testing.T, srv *Server, legacyOnly bool, expect map[string]*structs.Intention) {
t.Helper()
wildMeta := structs.WildcardEnterpriseMeta()
wildMeta := structs.WildcardEnterpriseMetaInDefaultPartition()
retry.Run(t, func(r *retry.R) {
var (
got structs.Intentions
@ -556,7 +556,7 @@ func TestLeader_LegacyIntentionMigration(t *testing.T) {
}
// also check config entries
_, gotConfigs, err := s1.fsm.State().ConfigEntriesByKind(nil, structs.ServiceIntentions, structs.WildcardEnterpriseMeta())
_, gotConfigs, err := s1.fsm.State().ConfigEntriesByKind(nil, structs.ServiceIntentions, structs.WildcardEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
gotConfigsM := mapifyConfigs(gotConfigs)

View File

@ -1329,11 +1329,11 @@ func TestLeader_ACLUpgrade_IsStickyEvenIfSerfTagsRegress(t *testing.T) {
// Everybody has the management policy.
retry.Run(t, func(r *retry.R) {
_, policy1, err := s1.fsm.State().ACLPolicyGetByID(nil, structs.ACLPolicyGlobalManagementID, structs.DefaultEnterpriseMeta())
_, policy1, err := s1.fsm.State().ACLPolicyGetByID(nil, structs.ACLPolicyGlobalManagementID, structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(r, err)
require.NotNil(r, policy1)
_, policy2, err := s2.fsm.State().ACLPolicyGetByID(nil, structs.ACLPolicyGlobalManagementID, structs.DefaultEnterpriseMeta())
_, policy2, err := s2.fsm.State().ACLPolicyGetByID(nil, structs.ACLPolicyGlobalManagementID, structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(r, err)
require.NotNil(r, policy2)
})
@ -1392,7 +1392,7 @@ func TestLeader_ConfigEntryBootstrap(t *testing.T) {
testrpc.WaitForTestAgent(t, s1.RPC, "dc1")
retry.Run(t, func(t *retry.R) {
_, entry, err := s1.fsm.State().ConfigEntry(nil, structs.ProxyDefaults, structs.ProxyConfigGlobal, structs.DefaultEnterpriseMeta())
_, entry, err := s1.fsm.State().ConfigEntry(nil, structs.ProxyDefaults, structs.ProxyConfigGlobal, structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
require.NotNil(t, entry)
global, ok := entry.(*structs.ProxyConfigEntry)
@ -1917,7 +1917,7 @@ func TestDatacenterSupportsIntentionsAsConfigEntries(t *testing.T) {
tags["ft_si"] = "0"
}
defaultEntMeta := structs.DefaultEnterpriseMeta()
defaultEntMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
t.Run("one node primary with old version", func(t *testing.T) {
dir1, s1 := testServerWithConfig(t, func(c *Config) {

View File

@ -26,7 +26,7 @@ func TestWalk_ServiceQuery(t *testing.T) {
Near: "_agent",
Tags: []string{"tag1", "tag2", "tag3"},
NodeMeta: map[string]string{"foo": "bar", "role": "server"},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
if err := walk(service, fn); err != nil {
t.Fatalf("err: %v", err)

View File

@ -1493,7 +1493,7 @@ func TestServer_ReloadConfig(t *testing.T) {
}
require.NoError(t, s.ReloadConfig(rc))
_, entry, err := s.fsm.State().ConfigEntry(nil, structs.ProxyDefaults, structs.ProxyConfigGlobal, structs.DefaultEnterpriseMeta())
_, entry, err := s.fsm.State().ConfigEntry(nil, structs.ProxyDefaults, structs.ProxyConfigGlobal, structs.DefaultEnterpriseMetaInDefaultPartition())
require.NoError(t, err)
require.NotNil(t, entry)
global, ok := entry.(*structs.ProxyConfigEntry)

View File

@ -46,7 +46,7 @@ func (s *Server) initializeSessionTimers() error {
// Scan all sessions and reset their timer
state := s.fsm.State()
_, sessions, err := state.SessionList(nil, structs.WildcardEnterpriseMeta())
_, sessions, err := state.SessionList(nil, structs.WildcardEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}

View File

@ -1013,7 +1013,7 @@ func aclTokenDeleteTxn(tx WriteTxn, idx uint64, value, index string, entMeta *st
func aclTokenDeleteAllForAuthMethodTxn(tx WriteTxn, idx uint64, methodName string, methodGlobalLocality bool, methodMeta *structs.EnterpriseMeta) error {
// collect all the tokens linked with the given auth method.
iter, err := aclTokenListByAuthMethod(tx, methodName, methodMeta, structs.WildcardEnterpriseMeta())
iter, err := aclTokenListByAuthMethod(tx, methodName, methodMeta, structs.WildcardEnterpriseMetaInDefaultPartition())
if err != nil {
return fmt.Errorf("failed acl token lookup: %v", err)
}
@ -1143,7 +1143,7 @@ func (s *Store) ACLPolicyGetByName(ws memdb.WatchSet, name string, entMeta *stru
func aclPolicyGetByName(tx ReadTxn, name string, entMeta *structs.EnterpriseMeta) (<-chan struct{}, interface{}, error) {
// todo: accept non-pointer value
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: name, EnterpriseMeta: *entMeta}
return tx.FirstWatch(tableACLPolicies, indexName, q)
@ -1376,7 +1376,7 @@ func (s *Store) ACLRoleGetByName(ws memdb.WatchSet, name string, entMeta *struct
func aclRoleGetByName(tx ReadTxn, name string, entMeta *structs.EnterpriseMeta) (<-chan struct{}, interface{}, error) {
// TODO: accept non-pointer value
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{EnterpriseMeta: *entMeta, Value: name}
return tx.FirstWatch(tableACLRoles, indexName, q)
@ -1445,7 +1445,7 @@ func (s *Store) ACLRoleList(ws memdb.WatchSet, policy string, entMeta *structs.E
// TODO: accept non-pointer value
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
if policy != "" {

View File

@ -2844,7 +2844,7 @@ func TestStateStore_ACLAuthMethod_GlobalNameShadowing_TokenTest(t *testing.T) {
// we'll create our auth method here that shadows the global-token-minting
// one in the primary.
defaultEntMeta := structs.DefaultEnterpriseMeta()
defaultEntMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
lastIndex++
require.NoError(t, s.ACLAuthMethodSet(lastIndex, &structs.ACLAuthMethod{

View File

@ -187,7 +187,7 @@ func ensureNoNodeWithSimilarNameTxn(tx ReadTxn, node *structs.Node, allowClashWi
if strings.EqualFold(node.Node, enode.Node) && node.ID != enode.ID {
// Look up the existing node's Serf health check to see if it's failed.
// If it is, the node can be renamed.
enodeCheck, err := tx.First(tableChecks, indexID, NodeCheckQuery{EnterpriseMeta: *structs.DefaultEnterpriseMeta(), Node: enode.Node, CheckID: string(structs.SerfCheckID)})
enodeCheck, err := tx.First(tableChecks, indexID, NodeCheckQuery{EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(), Node: enode.Node, CheckID: string(structs.SerfCheckID)})
if err != nil {
return fmt.Errorf("Cannot get status of node %s: %s", enode.Node, err)
}
@ -902,7 +902,7 @@ func (s *Store) ConnectServiceNodes(ws memdb.WatchSet, serviceName string, entMe
// TODO: accept non-pointer value
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: serviceName, EnterpriseMeta: *entMeta}
return serviceNodesTxn(tx, ws, indexConnect, q)
@ -915,7 +915,7 @@ func (s *Store) ServiceNodes(ws memdb.WatchSet, serviceName string, entMeta *str
// TODO: accept non-pointer value
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: serviceName, EnterpriseMeta: *entMeta}
return serviceNodesTxn(tx, ws, indexService, q)
@ -989,7 +989,7 @@ func (s *Store) ServiceTagNodes(ws memdb.WatchSet, service string, tags []string
// TODO: accept non-pointer value
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: service, EnterpriseMeta: *entMeta}
@ -1150,7 +1150,7 @@ func (s *Store) NodeService(nodeName string, serviceID string, entMeta *structs.
func getNodeServiceTxn(tx ReadTxn, nodeName, serviceID string, entMeta *structs.EnterpriseMeta) (*structs.NodeService, error) {
// TODO: pass non-pointer type for ent meta
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
// Query the service
@ -1324,7 +1324,7 @@ func (s *Store) deleteServiceCASTxn(tx WriteTxn, idx, cidx uint64, nodeName, ser
func (s *Store) deleteServiceTxn(tx WriteTxn, idx uint64, nodeName, serviceID string, entMeta *structs.EnterpriseMeta) error {
// TODO: pass non-pointer type for ent meta
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
service, err := tx.First(tableServices, indexID, NodeServiceQuery{EnterpriseMeta: *entMeta, Node: nodeName, Service: serviceID})
@ -1337,7 +1337,7 @@ func (s *Store) deleteServiceTxn(tx WriteTxn, idx uint64, nodeName, serviceID st
// TODO: accept a non-pointer value for EnterpriseMeta
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
// Delete any checks associated with the service. This will invalidate
// sessions as necessary.
@ -1586,7 +1586,7 @@ func getNodeCheckTxn(tx ReadTxn, nodeName string, checkID types.CheckID, entMeta
// TODO: accept non-pointer value
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
// Return the check.
@ -1608,7 +1608,7 @@ func (s *Store) NodeChecks(ws memdb.WatchSet, nodeName string, entMeta *structs.
defer tx.Abort()
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
// Get the table index.
@ -1639,7 +1639,7 @@ func (s *Store) ServiceChecks(ws memdb.WatchSet, serviceName string, entMeta *st
idx := catalogChecksMaxIndex(tx, entMeta)
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: serviceName, EnterpriseMeta: *entMeta}
iter, err := tx.Get(tableChecks, indexService, q)
@ -1668,7 +1668,7 @@ func (s *Store) ServiceChecksByNodeMeta(ws memdb.WatchSet, serviceName string,
idx := maxIndexForService(tx, serviceName, true, true, entMeta)
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: serviceName, EnterpriseMeta: *entMeta}
iter, err := tx.Get(tableChecks, indexService, q)
@ -1717,7 +1717,7 @@ func checksInStateTxn(tx ReadTxn, ws memdb.WatchSet, state string, entMeta *stru
idx := catalogChecksMaxIndex(tx, entMeta)
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
// Query all checks if HealthAny is passed, otherwise use the index.
@ -1830,7 +1830,7 @@ func (q NodeServiceQuery) NamespaceOrDefault() string {
// check deletion within an existing transaction.
func (s *Store) deleteCheckTxn(tx WriteTxn, idx uint64, node string, checkID types.CheckID, entMeta *structs.EnterpriseMeta) error {
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
// Try to retrieve the existing health check.
@ -1984,7 +1984,7 @@ func checkServiceNodesTxn(tx ReadTxn, ws memdb.WatchSet, serviceName string, con
// TODO: accept non-pointer
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: serviceName, EnterpriseMeta: *entMeta}
@ -2113,7 +2113,7 @@ func (s *Store) CheckServiceTagNodes(ws memdb.WatchSet, serviceName string, tags
// TODO: accept non-pointer value
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: serviceName, EnterpriseMeta: *entMeta}
@ -2214,7 +2214,7 @@ func parseCheckServiceNodes(
// First add the node-level checks. These always apply to any
// service on the node.
var checks structs.HealthChecks
q := NodeServiceQuery{Node: sn.Node, EnterpriseMeta: *structs.DefaultEnterpriseMeta()}
q := NodeServiceQuery{Node: sn.Node, EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition()}
iter, err := tx.Get(tableChecks, indexNodeService, q)
if err != nil {
return 0, nil, err
@ -2319,7 +2319,7 @@ func serviceDumpKindTxn(tx ReadTxn, ws memdb.WatchSet, kind structs.ServiceKind,
idx := catalogServiceKindMaxIndex(tx, ws, kind, entMeta)
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: string(kind), EnterpriseMeta: *entMeta}
services, err := tx.Get(tableServices, indexKind, q)
@ -2343,7 +2343,7 @@ func parseNodes(tx ReadTxn, ws memdb.WatchSet, idx uint64,
iter memdb.ResultIterator, entMeta *structs.EnterpriseMeta) (uint64, structs.NodeDump, error) {
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
// We don't want to track an unlimited number of services, so we pull a
@ -2566,7 +2566,7 @@ func terminatingConfigGatewayServices(
// updateGatewayNamespace is used to target all services within a namespace
func updateGatewayNamespace(tx WriteTxn, idx uint64, service *structs.GatewayService, entMeta *structs.EnterpriseMeta) error {
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: string(structs.ServiceKindTypical), EnterpriseMeta: *entMeta}
services, err := tx.Get(tableServices, indexKind, q)
@ -2890,7 +2890,7 @@ func (s *Store) ServiceTopology(
// Fetch connect endpoints for the target service in order to learn if its proxies are configured as
// transparent proxies.
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
q := Query{Value: service, EnterpriseMeta: *entMeta}
@ -3250,7 +3250,7 @@ func updateMeshTopology(tx WriteTxn, idx uint64, node string, svc *structs.NodeS
oldUpstreams := make(map[structs.ServiceName]bool)
if e, ok := existing.(*structs.ServiceNode); ok {
for _, u := range e.ServiceProxy.Upstreams {
upstreamMeta := structs.NewEnterpriseMeta(u.DestinationNamespace)
upstreamMeta := structs.NewEnterpriseMetaInDefaultPartition(u.DestinationNamespace)
sn := structs.NewServiceName(u.DestinationName, &upstreamMeta)
oldUpstreams[sn] = true
@ -3266,7 +3266,7 @@ func updateMeshTopology(tx WriteTxn, idx uint64, node string, svc *structs.NodeS
}
// TODO (freddy): Account for upstream datacenter
upstreamMeta := structs.NewEnterpriseMeta(u.DestinationNamespace)
upstreamMeta := structs.NewEnterpriseMetaInDefaultPartition(u.DestinationNamespace)
upstream := structs.NewServiceName(u.DestinationName, &upstreamMeta)
obj, err := tx.First(tableMeshTopology, indexID, upstream, downstream)

View File

@ -60,7 +60,7 @@ func serviceHealthSnapshot(db ReadDB, topic stream.Topic) stream.SnapshotFunc {
defer tx.Abort()
connect := topic == topicServiceHealthConnect
entMeta := structs.NewEnterpriseMeta(req.Namespace)
entMeta := structs.NewEnterpriseMetaInDefaultPartition(req.Namespace)
idx, nodes, err := checkServiceNodesTxn(tx, nil, req.Key, connect, &entMeta)
if err != nil {
return 0, err

View File

@ -91,10 +91,10 @@ func TestServiceHealthSnapshot_ConnectTopic(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "web",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err = store.EnsureConfigEntry(counter.Next(), configEntry)
require.NoError(t, err)
@ -1053,10 +1053,10 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
return ensureConfigEntryTxn(tx, tx.Index, configEntry)
},
@ -1071,14 +1071,14 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "srv2",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
return ensureConfigEntryTxn(tx, tx.Index, configEntry)
},
@ -1130,14 +1130,14 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "srv2",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err := ensureConfigEntryTxn(tx, tx.Index, configEntry)
if err != nil {
@ -1191,14 +1191,14 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "srv2",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
return ensureConfigEntryTxn(tx, tx.Index, configEntry)
},
@ -1224,10 +1224,10 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err := ensureConfigEntryTxn(tx, tx.Index, configEntry)
if err != nil {
@ -1243,14 +1243,14 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "srv2",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
return ensureConfigEntryTxn(tx, tx.Index, configEntry)
},
@ -1271,14 +1271,14 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "srv2",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err := ensureConfigEntryTxn(tx, tx.Index, configEntry)
if err != nil {
@ -1294,10 +1294,10 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv2",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
return ensureConfigEntryTxn(tx, tx.Index, configEntry)
},
@ -1317,10 +1317,10 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err := ensureConfigEntryTxn(tx, tx.Index, configEntry)
if err != nil {
@ -1337,10 +1337,10 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
{
Name: "srv1",
CAFile: "foo.crt",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
return ensureConfigEntryTxn(tx, tx.Index, configEntry)
},
@ -1365,10 +1365,10 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err := ensureConfigEntryTxn(tx, tx.Index, configEntry)
if err != nil {
@ -1384,7 +1384,7 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
testServiceRegistration(t, "tgate1", regTerminatingGateway, regNode2), false)
},
Mutate: func(s *Store, tx *txn) error {
return deleteConfigEntryTxn(tx, tx.Index, structs.TerminatingGateway, "tgate1", structs.DefaultEnterpriseMeta())
return deleteConfigEntryTxn(tx, tx.Index, structs.TerminatingGateway, "tgate1", structs.DefaultEnterpriseMetaInDefaultPartition())
},
WantEvents: []stream.Event{
testServiceHealthDeregistrationEvent(t,
@ -1407,10 +1407,10 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err := ensureConfigEntryTxn(tx, tx.Index, configEntry)
if err != nil {
@ -1435,10 +1435,10 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err := ensureConfigEntryTxn(tx, tx.Index, configEntry)
if err != nil {
@ -1467,10 +1467,10 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err := ensureConfigEntryTxn(tx, tx.Index, configEntry)
if err != nil {
@ -1482,10 +1482,10 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err = ensureConfigEntryTxn(tx, tx.Index, configEntry)
if err != nil {
@ -1537,14 +1537,14 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
Services: []structs.LinkedService{
{
Name: "srv1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "srv2",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
err := ensureConfigEntryTxn(tx, tx.Index, configEntry)
if err != nil {
@ -1554,7 +1554,7 @@ func TestServiceHealthEventsFromChanges(t *testing.T) {
testServiceRegistration(t, "tgate1", regTerminatingGateway), false)
},
Mutate: func(s *Store, tx *txn) error {
return s.deleteServiceTxn(tx, tx.Index, "node1", "tgate1", structs.DefaultEnterpriseMeta())
return s.deleteServiceTxn(tx, tx.Index, "node1", "tgate1", structs.DefaultEnterpriseMetaInDefaultPartition())
},
WantEvents: []stream.Event{
testServiceHealthDeregistrationEvent(t,
@ -2185,7 +2185,7 @@ func newTestEventServiceHealthRegister(index uint64, nodeNum int, svc string) st
CreateIndex: index,
ModifyIndex: index,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Checks: []*structs.HealthCheck{
{
@ -2197,7 +2197,7 @@ func newTestEventServiceHealthRegister(index uint64, nodeNum int, svc string) st
CreateIndex: index,
ModifyIndex: index,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Node: node,
@ -2211,7 +2211,7 @@ func newTestEventServiceHealthRegister(index uint64, nodeNum int, svc string) st
CreateIndex: index,
ModifyIndex: index,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -2253,7 +2253,7 @@ func newTestEventServiceHealthDeregister(index uint64, nodeNum int, svc string)
CreateIndex: 10,
ModifyIndex: 10,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -2365,7 +2365,7 @@ func newPayloadCheckServiceNode(service, namespace string) EventPayloadCheckServ
Value: &structs.CheckServiceNode{
Service: &structs.NodeService{
Service: service,
EnterpriseMeta: structs.NewEnterpriseMeta(namespace),
EnterpriseMeta: structs.NewEnterpriseMetaInDefaultPartition(namespace),
},
},
}
@ -2377,7 +2377,7 @@ func newPayloadCheckServiceNodeWithOverride(
Value: &structs.CheckServiceNode{
Service: &structs.NodeService{
Service: service,
EnterpriseMeta: structs.NewEnterpriseMeta(namespace),
EnterpriseMeta: structs.NewEnterpriseMetaInDefaultPartition(namespace),
},
},
overrideKey: overrideKey,

View File

@ -230,7 +230,7 @@ func TestStateStore_EnsureRegistration(t *testing.T) {
Tags: []string{"primary"},
Weights: &structs.Weights{Passing: 1, Warning: 1},
RaftIndex: structs.RaftIndex{CreateIndex: 2, ModifyIndex: 2},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
@ -268,7 +268,7 @@ func TestStateStore_EnsureRegistration(t *testing.T) {
Name: "check",
Status: "critical",
RaftIndex: structs.RaftIndex{CreateIndex: 3, ModifyIndex: 3},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
@ -313,7 +313,7 @@ func TestStateStore_EnsureRegistration(t *testing.T) {
Name: "check",
Status: "critical",
RaftIndex: structs.RaftIndex{CreateIndex: 3, ModifyIndex: 3},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
&structs.HealthCheck{
Node: "node1",
@ -324,7 +324,7 @@ func TestStateStore_EnsureRegistration(t *testing.T) {
ServiceName: "redis",
ServiceTags: []string{"primary"},
RaftIndex: structs.RaftIndex{CreateIndex: 4, ModifyIndex: 4},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
@ -357,7 +357,7 @@ func TestStateStore_EnsureRegistration(t *testing.T) {
Node: "nope",
CheckID: "check2",
Name: "check",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
err = s.EnsureRegistration(6, req)
@ -1395,7 +1395,7 @@ func TestStateStore_EnsureService(t *testing.T) {
Address: "1.1.1.1",
Port: 1111,
Weights: &structs.Weights{Passing: 1, Warning: 0},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
// Creating a service without a node returns an error.
@ -1531,7 +1531,7 @@ func TestStateStore_EnsureService_connectProxy(t *testing.T) {
Warning: 1,
},
Proxy: structs.ConnectProxyConfig{DestinationServiceName: "foo"},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
// Service successfully registers into the state store.
@ -2259,7 +2259,7 @@ func TestStateStore_Service_Snapshot(t *testing.T) {
Address: "1.1.1.1",
Port: 1111,
Weights: &structs.Weights{Passing: 1, Warning: 0},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
ID: "service2",
@ -2268,7 +2268,7 @@ func TestStateStore_Service_Snapshot(t *testing.T) {
Address: "1.1.1.2",
Port: 1112,
Weights: &structs.Weights{Passing: 1, Warning: 1},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
for i, svc := range ns {
@ -4248,7 +4248,7 @@ func TestStateStore_NodeInfo_NodeDump(t *testing.T) {
CreateIndex: 6,
ModifyIndex: 6,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
&structs.HealthCheck{
Node: "node1",
@ -4260,7 +4260,7 @@ func TestStateStore_NodeInfo_NodeDump(t *testing.T) {
CreateIndex: 8,
ModifyIndex: 8,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
Services: []*structs.NodeService{
@ -4275,7 +4275,7 @@ func TestStateStore_NodeInfo_NodeDump(t *testing.T) {
CreateIndex: 2,
ModifyIndex: 2,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
ID: "service2",
@ -4288,7 +4288,7 @@ func TestStateStore_NodeInfo_NodeDump(t *testing.T) {
CreateIndex: 3,
ModifyIndex: 3,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -4305,7 +4305,7 @@ func TestStateStore_NodeInfo_NodeDump(t *testing.T) {
CreateIndex: 7,
ModifyIndex: 7,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
&structs.HealthCheck{
Node: "node2",
@ -4317,7 +4317,7 @@ func TestStateStore_NodeInfo_NodeDump(t *testing.T) {
CreateIndex: 9,
ModifyIndex: 9,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
Services: []*structs.NodeService{
@ -4332,7 +4332,7 @@ func TestStateStore_NodeInfo_NodeDump(t *testing.T) {
CreateIndex: 4,
ModifyIndex: 4,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
ID: "service2",
@ -4345,7 +4345,7 @@ func TestStateStore_NodeInfo_NodeDump(t *testing.T) {
CreateIndex: 5,
ModifyIndex: 5,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -6151,7 +6151,7 @@ func TestCatalog_catalogDownstreams_Watches(t *testing.T) {
Node: "foo",
}))
defaultMeta := structs.DefaultEnterpriseMeta()
defaultMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
admin := structs.NewServiceName("admin", defaultMeta)
cache := structs.NewServiceName("cache", defaultMeta)
@ -6261,7 +6261,7 @@ func TestCatalog_catalogDownstreams_Watches(t *testing.T) {
}
func TestCatalog_catalogDownstreams(t *testing.T) {
defaultMeta := structs.DefaultEnterpriseMeta()
defaultMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
type expect struct {
idx uint64
@ -6377,7 +6377,7 @@ func TestCatalog_catalogDownstreams(t *testing.T) {
}
tx := s.db.ReadTxn()
idx, names, err := downstreamsFromRegistrationTxn(tx, ws, structs.NewServiceName("admin", structs.DefaultEnterpriseMeta()))
idx, names, err := downstreamsFromRegistrationTxn(tx, ws, structs.NewServiceName("admin", structs.DefaultEnterpriseMetaInDefaultPartition()))
require.NoError(t, err)
require.Equal(t, tc.expect.idx, idx)
@ -6387,7 +6387,7 @@ func TestCatalog_catalogDownstreams(t *testing.T) {
}
func TestCatalog_upstreamsFromRegistration(t *testing.T) {
defaultMeta := structs.DefaultEnterpriseMeta()
defaultMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
type expect struct {
idx uint64
@ -6552,7 +6552,7 @@ func TestCatalog_upstreamsFromRegistration(t *testing.T) {
}
tx := s.db.ReadTxn()
idx, names, err := upstreamsFromRegistrationTxn(tx, ws, structs.NewServiceName("api", structs.DefaultEnterpriseMeta()))
idx, names, err := upstreamsFromRegistrationTxn(tx, ws, structs.NewServiceName("api", structs.DefaultEnterpriseMetaInDefaultPartition()))
require.NoError(t, err)
require.Equal(t, tc.expect.idx, idx)
@ -6574,7 +6574,7 @@ func TestCatalog_upstreamsFromRegistration_Watches(t *testing.T) {
Node: "foo",
}))
defaultMeta := structs.DefaultEnterpriseMeta()
defaultMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
web := structs.NewServiceName("web", defaultMeta)
ws := memdb.NewWatchSet()
@ -6739,7 +6739,7 @@ func TestCatalog_topologyCleanupPanic(t *testing.T) {
Node: "foo",
}))
defaultMeta := structs.DefaultEnterpriseMeta()
defaultMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
web := structs.NewServiceName("web", defaultMeta)
ws := memdb.NewWatchSet()
@ -6816,7 +6816,7 @@ func TestCatalog_upstreamsFromRegistration_Ingress(t *testing.T) {
},
}))
defaultMeta := structs.DefaultEnterpriseMeta()
defaultMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
ingress := structs.NewServiceName("ingress", defaultMeta)
ws := memdb.NewWatchSet()
@ -7023,7 +7023,7 @@ func TestCatalog_cleanupGatewayWildcards_panic(t *testing.T) {
},
}))
defaultMeta := structs.DefaultEnterpriseMeta()
defaultMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
// Register two different gateways that target services via wildcard
require.NoError(t, s.EnsureConfigEntry(2, &structs.TerminatingGatewayConfigEntry{
@ -7078,7 +7078,7 @@ func TestCatalog_cleanupGatewayWildcards_panic(t *testing.T) {
}
func TestCatalog_DownstreamsForService(t *testing.T) {
defaultMeta := structs.DefaultEnterpriseMeta()
defaultMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
type expect struct {
idx uint64
@ -7203,7 +7203,7 @@ func TestCatalog_DownstreamsForService(t *testing.T) {
defer tx.Abort()
ws := memdb.NewWatchSet()
sn := structs.NewServiceName("admin", structs.DefaultEnterpriseMeta())
sn := structs.NewServiceName("admin", structs.DefaultEnterpriseMetaInDefaultPartition())
idx, names, err := s.downstreamsForServiceTxn(tx, ws, "dc1", sn)
require.NoError(t, err)
@ -7215,7 +7215,7 @@ func TestCatalog_DownstreamsForService(t *testing.T) {
func TestCatalog_DownstreamsForService_Updates(t *testing.T) {
var (
defaultMeta = structs.DefaultEnterpriseMeta()
defaultMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
target = structs.NewServiceName("admin", defaultMeta)
)
@ -7509,7 +7509,7 @@ func TestProtocolForIngressGateway(t *testing.T) {
defer tx.Abort()
ws := memdb.NewWatchSet()
sn := structs.NewServiceName("ingress", structs.DefaultEnterpriseMeta())
sn := structs.NewServiceName("ingress", structs.DefaultEnterpriseMetaInDefaultPartition())
idx, protocol, err := metricsProtocolForIngressGateway(tx, ws, sn)
require.NoError(t, err)

View File

@ -401,7 +401,7 @@ func (s *Store) discoveryChainTargetsTxn(tx ReadTxn, ws memdb.WatchSet, dc, serv
var resp []structs.ServiceName
for _, t := range chain.Targets {
em := structs.NewEnterpriseMeta(t.Namespace)
em := structs.NewEnterpriseMetaInDefaultPartition(t.Namespace)
target := structs.NewServiceName(t.Service, &em)
// TODO (freddy): Allow upstream DC and encode in response
@ -457,7 +457,7 @@ func (s *Store) discoveryChainSourcesTxn(tx ReadTxn, ws memdb.WatchSet, dc strin
}
for _, t := range chain.Targets {
em := structs.NewEnterpriseMeta(t.Namespace)
em := structs.NewEnterpriseMetaInDefaultPartition(t.Namespace)
candidate := structs.NewServiceName(t.Service, &em)
if !candidate.Matches(destination) {
@ -495,7 +495,7 @@ func validateProposedConfigEntryInServiceGraph(
// somehow omit the ones that have a default protocol configured.
for _, kind := range serviceGraphKinds {
_, entries, err := configEntriesByKindTxn(tx, nil, kind, structs.WildcardEnterpriseMeta())
_, entries, err := configEntriesByKindTxn(tx, nil, kind, structs.WildcardEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}
@ -504,7 +504,7 @@ func validateProposedConfigEntryInServiceGraph(
}
}
_, ingressEntries, err := configEntriesByKindTxn(tx, nil, structs.IngressGateway, structs.WildcardEnterpriseMeta())
_, ingressEntries, err := configEntriesByKindTxn(tx, nil, structs.IngressGateway, structs.WildcardEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}
@ -516,7 +516,7 @@ func validateProposedConfigEntryInServiceGraph(
checkIngress = append(checkIngress, ingress)
}
_, ixnEntries, err := configEntriesByKindTxn(tx, nil, structs.ServiceIntentions, structs.WildcardEnterpriseMeta())
_, ixnEntries, err := configEntriesByKindTxn(tx, nil, structs.ServiceIntentions, structs.WildcardEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}
@ -573,7 +573,7 @@ func validateProposedConfigEntryInServiceGraph(
checkIntentions = append(checkIntentions, ixn)
}
_, ixnEntries, err := configEntriesByKindTxn(tx, nil, structs.ServiceIntentions, structs.WildcardEnterpriseMeta())
_, ixnEntries, err := configEntriesByKindTxn(tx, nil, structs.ServiceIntentions, structs.WildcardEnterpriseMetaInDefaultPartition())
if err != nil {
return err
}
@ -1232,7 +1232,7 @@ func NewConfigEntryKindName(kind, name string, entMeta *structs.EnterpriseMeta)
Name: name,
}
if entMeta == nil {
entMeta = structs.DefaultEnterpriseMeta()
entMeta = structs.DefaultEnterpriseMetaInDefaultPartition()
}
ret.EnterpriseMeta = *entMeta

View File

@ -128,7 +128,7 @@ func configIntentionsListTxn(tx ReadTxn, ws memdb.WatchSet, entMeta *structs.Ent
idx := maxIndexTxn(tx, tableConfigEntries)
iter, err := getConfigEntryKindsWithTxn(tx, structs.ServiceIntentions, structs.WildcardEnterpriseMeta())
iter, err := getConfigEntryKindsWithTxn(tx, structs.ServiceIntentions, structs.WildcardEnterpriseMetaInDefaultPartition())
if err != nil {
return 0, nil, false, fmt.Errorf("failed config entry lookup: %s", err)
}

View File

@ -331,7 +331,7 @@ func TestStore_ConfigEntry_GraphValidation(t *testing.T) {
Kind: structs.ServiceDefaults,
Name: "main",
Protocol: "http",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
&structs.ServiceResolverConfigEntry{
Kind: structs.ServiceResolver,
@ -354,7 +354,7 @@ func TestStore_ConfigEntry_GraphValidation(t *testing.T) {
{Weight: 90, ServiceSubset: "v1"},
{Weight: 10, ServiceSubset: "v2"},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
return s.EnsureConfigEntry(0, entry)
},
@ -1554,7 +1554,7 @@ func TestStore_ValidateIngressGatewayErrorOnMismatchedProtocols(t *testing.T) {
}
func TestSourcesForTarget(t *testing.T) {
defaultMeta := *structs.DefaultEnterpriseMeta()
defaultMeta := *structs.DefaultEnterpriseMetaInDefaultPartition()
type expect struct {
idx uint64
@ -1829,7 +1829,7 @@ func TestSourcesForTarget(t *testing.T) {
tx := s.db.ReadTxn()
defer tx.Abort()
sn := structs.NewServiceName("sink", structs.DefaultEnterpriseMeta())
sn := structs.NewServiceName("sink", structs.DefaultEnterpriseMetaInDefaultPartition())
idx, names, err := s.discoveryChainSourcesTxn(tx, ws, "dc1", sn)
require.NoError(t, err)
@ -1840,7 +1840,7 @@ func TestSourcesForTarget(t *testing.T) {
}
func TestTargetsForSource(t *testing.T) {
defaultMeta := *structs.DefaultEnterpriseMeta()
defaultMeta := *structs.DefaultEnterpriseMetaInDefaultPartition()
type expect struct {
idx uint64

View File

@ -1008,7 +1008,7 @@ func (s *Store) intentionTopologyTxn(tx ReadTxn, ws memdb.WatchSet,
return true
}
return false
}, structs.WildcardEnterpriseMeta())
}, structs.WildcardEnterpriseMetaInDefaultPartition())
if err != nil {
return index, nil, fmt.Errorf("failed to fetch catalog service list: %v", err)
}

View File

@ -288,7 +288,7 @@ func TestStore_IntentionMutation(t *testing.T) {
func testStore_IntentionMutation(t *testing.T, s *Store) {
lastIndex := uint64(1)
defaultEntMeta := structs.DefaultEnterpriseMeta()
defaultEntMeta := structs.DefaultEnterpriseMetaInDefaultPartition()
var (
id1 = testUUID()
@ -1072,7 +1072,7 @@ func TestStore_IntentionsList(t *testing.T) {
lastIndex = 1 // minor state machine implementation difference
}
entMeta := structs.WildcardEnterpriseMeta()
entMeta := structs.WildcardEnterpriseMetaInDefaultPartition()
// Querying with no results returns nil.
ws := memdb.NewWatchSet()
@ -1686,7 +1686,7 @@ func TestStore_LegacyIntention_Snapshot_Restore(t *testing.T) {
// Intentions are returned precedence sorted unlike the snapshot so we need
// to rearrange the expected slice some.
expected[0], expected[1], expected[2] = expected[1], expected[2], expected[0]
entMeta := structs.WildcardEnterpriseMeta()
entMeta := structs.WildcardEnterpriseMetaInDefaultPartition()
idx, actual, fromConfig, err := s.Intentions(nil, entMeta)
require.NoError(t, err)
require.Equal(t, idx, uint64(6))
@ -1898,46 +1898,46 @@ func TestStore_IntentionTopology(t *testing.T) {
{
ID: structs.ConsulServiceID,
Service: structs.ConsulServiceName,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
ID: "api-1",
Service: "api",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
ID: "mysql-1",
Service: "mysql",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
ID: "web-1",
Service: "web",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Kind: structs.ServiceKindConnectProxy,
ID: "web-proxy-1",
Service: "web-proxy",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Kind: structs.ServiceKindTerminatingGateway,
ID: "terminating-gateway-1",
Service: "terminating-gateway",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Kind: structs.ServiceKindIngressGateway,
ID: "ingress-gateway-1",
Service: "ingress-gateway",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Kind: structs.ServiceKindMeshGateway,
ID: "mesh-gateway-1",
Service: "mesh-gateway",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
@ -1975,7 +1975,7 @@ func TestStore_IntentionTopology(t *testing.T) {
services: structs.ServiceList{
{
Name: "mysql",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -2002,7 +2002,7 @@ func TestStore_IntentionTopology(t *testing.T) {
services: structs.ServiceList{
{
Name: "api",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -2029,11 +2029,11 @@ func TestStore_IntentionTopology(t *testing.T) {
services: structs.ServiceList{
{
Name: "ingress-gateway",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "mysql",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -2060,7 +2060,7 @@ func TestStore_IntentionTopology(t *testing.T) {
services: structs.ServiceList{
{
Name: "web",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -2087,11 +2087,11 @@ func TestStore_IntentionTopology(t *testing.T) {
services: structs.ServiceList{
{
Name: "api",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "mysql",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -2140,11 +2140,11 @@ func TestStore_IntentionTopology(t *testing.T) {
services: structs.ServiceList{
{
Name: "api",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "mysql",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -2190,7 +2190,7 @@ func TestStore_IntentionTopology_Watches(t *testing.T) {
}))
i++
target := structs.NewServiceName("web", structs.DefaultEnterpriseMeta())
target := structs.NewServiceName("web", structs.DefaultEnterpriseMetaInDefaultPartition())
ws := memdb.NewWatchSet()
index, got, err := s.IntentionTopology(ws, target, false, acl.Deny)
@ -2246,7 +2246,7 @@ func TestStore_IntentionTopology_Watches(t *testing.T) {
require.NoError(t, s.EnsureService(i, "foo", &structs.NodeService{
ID: "api-1",
Service: "api",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}))
require.True(t, watchFired(ws))
@ -2259,7 +2259,7 @@ func TestStore_IntentionTopology_Watches(t *testing.T) {
expect := structs.ServiceList{
{
Name: "api",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
require.Equal(t, expect, got)

View File

@ -279,7 +279,7 @@ func TestStateStore_Txn_Service(t *testing.T) {
CreateIndex: 2,
ModifyIndex: 2,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Meta: map[string]string{},
},
},
@ -291,7 +291,7 @@ func TestStateStore_Txn_Service(t *testing.T) {
CreateIndex: 6,
ModifyIndex: 6,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
&structs.TxnResult{
@ -303,7 +303,7 @@ func TestStateStore_Txn_Service(t *testing.T) {
CreateIndex: 3,
ModifyIndex: 6,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
}
@ -336,7 +336,7 @@ func TestStateStore_Txn_Service(t *testing.T) {
ModifyIndex: 2,
},
Weights: &structs.Weights{Passing: 1, Warning: 1},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Meta: map[string]string{},
},
"svc5": {
@ -346,7 +346,7 @@ func TestStateStore_Txn_Service(t *testing.T) {
ModifyIndex: 6,
},
Weights: &structs.Weights{Passing: 1, Warning: 1},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
"svc2": {
ID: "svc2",
@ -356,7 +356,7 @@ func TestStateStore_Txn_Service(t *testing.T) {
ModifyIndex: 6,
},
Weights: &structs.Weights{Passing: 1, Warning: 1},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
}
@ -431,7 +431,7 @@ func TestStateStore_Txn_Checks(t *testing.T) {
CreateIndex: 2,
ModifyIndex: 2,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
&structs.TxnResult{
@ -443,7 +443,7 @@ func TestStateStore_Txn_Checks(t *testing.T) {
CreateIndex: 6,
ModifyIndex: 6,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
&structs.TxnResult{
@ -455,7 +455,7 @@ func TestStateStore_Txn_Checks(t *testing.T) {
CreateIndex: 3,
ModifyIndex: 6,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
}
@ -478,7 +478,7 @@ func TestStateStore_Txn_Checks(t *testing.T) {
CreateIndex: 2,
ModifyIndex: 2,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
&structs.HealthCheck{
Node: "node1",
@ -488,7 +488,7 @@ func TestStateStore_Txn_Checks(t *testing.T) {
CreateIndex: 3,
ModifyIndex: 6,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
&structs.HealthCheck{
Node: "node1",
@ -498,7 +498,7 @@ func TestStateStore_Txn_Checks(t *testing.T) {
CreateIndex: 6,
ModifyIndex: 6,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
require.Equal(t, expectedChecks, actual)

View File

@ -754,14 +754,14 @@ func TestTxn_Read(t *testing.T) {
ID: "svc-foo",
Service: "svc-foo",
Address: "127.0.0.1",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
require.NoError(state.EnsureService(3, "foo", &svc))
check := structs.HealthCheck{
Node: "foo",
CheckID: types.CheckID("check-foo"),
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
state.EnsureCheck(4, &check)

View File

@ -414,7 +414,7 @@ func (d *DNSServer) handlePtr(resp dns.ResponseWriter, req *dns.Msg) {
AllowStale: cfg.AllowStale,
},
ServiceAddress: serviceAddress,
EnterpriseMeta: *structs.WildcardEnterpriseMeta(),
EnterpriseMeta: *structs.WildcardEnterpriseMetaInDefaultPartition(),
}
var sout structs.IndexedServiceNodes
@ -548,7 +548,7 @@ func (d *DNSServer) nameservers(cfg *dnsConfig, maxRecursionLevel int) (ns []dns
Service: structs.ConsulServiceName,
Connect: false,
Ingress: false,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
})
if err != nil {
d.logger.Warn("Unable to get list of servers", "error", err)

View File

@ -887,7 +887,7 @@ func (l *State) updateSyncState() error {
AllowStale: true,
MaxStaleDuration: fullSyncReadMaxStale,
},
EnterpriseMeta: *structs.WildcardEnterpriseMeta(),
EnterpriseMeta: *structs.WildcardEnterpriseMetaInDefaultPartition(),
}
var out1 structs.IndexedNodeServiceList

View File

@ -57,7 +57,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
assert.False(t, a.State.ServiceExists(structs.ServiceID{ID: srv1.ID}))
a.State.AddService(srv1, "")
@ -77,7 +77,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
Passing: 1,
Warning: 0,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddService(srv2, "")
@ -99,7 +99,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddService(srv3, "")
@ -113,7 +113,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
Passing: 1,
Warning: 0,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
args.Service = srv4
if err := a.RPC("Catalog.Register", args, &out); err != nil {
@ -131,7 +131,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddService(srv5, "")
@ -153,7 +153,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
Passing: 1,
Warning: 0,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.SetServiceState(&local.ServiceState{
Service: srv6,
@ -209,7 +209,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
}
}
if err := servicesInSync(a.State, 5, structs.DefaultEnterpriseMeta()); err != nil {
if err := servicesInSync(a.State, 5, structs.DefaultEnterpriseMetaInDefaultPartition()); err != nil {
t.Fatal(err)
}
@ -248,7 +248,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
}
}
if err := servicesInSync(a.State, 4, structs.DefaultEnterpriseMeta()); err != nil {
if err := servicesInSync(a.State, 4, structs.DefaultEnterpriseMetaInDefaultPartition()); err != nil {
t.Fatal(err)
}
}
@ -284,7 +284,7 @@ func TestAgentAntiEntropy_Services_ConnectProxy(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddService(srv1, "")
args.Service = srv1
@ -301,7 +301,7 @@ func TestAgentAntiEntropy_Services_ConnectProxy(t *testing.T) {
Passing: 1,
Warning: 0,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddService(srv2, "")
@ -322,7 +322,7 @@ func TestAgentAntiEntropy_Services_ConnectProxy(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddService(srv3, "")
@ -337,7 +337,7 @@ func TestAgentAntiEntropy_Services_ConnectProxy(t *testing.T) {
Passing: 1,
Warning: 0,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
args.Service = srv4
assert.Nil(a.RPC("Catalog.Register", args, &out))
@ -353,7 +353,7 @@ func TestAgentAntiEntropy_Services_ConnectProxy(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.SetServiceState(&local.ServiceState{
Service: srv5,
@ -391,7 +391,7 @@ func TestAgentAntiEntropy_Services_ConnectProxy(t *testing.T) {
}
}
assert.Nil(servicesInSync(a.State, 4, structs.DefaultEnterpriseMeta()))
assert.Nil(servicesInSync(a.State, 4, structs.DefaultEnterpriseMetaInDefaultPartition()))
// Remove one of the services
a.State.RemoveService(structs.NewServiceID("cache-proxy", nil))
@ -418,7 +418,7 @@ func TestAgentAntiEntropy_Services_ConnectProxy(t *testing.T) {
}
}
assert.Nil(servicesInSync(a.State, 3, structs.DefaultEnterpriseMeta()))
assert.Nil(servicesInSync(a.State, 3, structs.DefaultEnterpriseMetaInDefaultPartition()))
}
func TestAgent_ServiceWatchCh(t *testing.T) {
@ -625,7 +625,7 @@ func TestAgentAntiEntropy_EnableTagOverride(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
assert.Equal(r, want, got)
case "svc_id2":
@ -638,7 +638,7 @@ func TestAgentAntiEntropy_EnableTagOverride(t *testing.T) {
}
}
if err := servicesInSync(a.State, 2, structs.DefaultEnterpriseMeta()); err != nil {
if err := servicesInSync(a.State, 2, structs.DefaultEnterpriseMetaInDefaultPartition()); err != nil {
r.Fatal(err)
}
})
@ -873,7 +873,7 @@ func TestAgentAntiEntropy_Services_ACLDeny(t *testing.T) {
}
}
if err := servicesInSync(a.State, 2, structs.DefaultEnterpriseMeta()); err != nil {
if err := servicesInSync(a.State, 2, structs.DefaultEnterpriseMetaInDefaultPartition()); err != nil {
t.Fatal(err)
}
}
@ -918,7 +918,7 @@ func TestAgentAntiEntropy_Services_ACLDeny(t *testing.T) {
}
}
if err := servicesInSync(a.State, 1, structs.DefaultEnterpriseMeta()); err != nil {
if err := servicesInSync(a.State, 1, structs.DefaultEnterpriseMetaInDefaultPartition()); err != nil {
t.Fatal(err)
}
}
@ -953,7 +953,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
CheckID: "mysql",
Name: "mysql",
Status: api.HealthPassing,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddCheck(chk1, "")
args.Check = chk1
@ -967,7 +967,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
CheckID: "redis",
Name: "redis",
Status: api.HealthPassing,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddCheck(chk2, "")
@ -985,7 +985,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
CheckID: "web",
Name: "web",
Status: api.HealthPassing,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddCheck(chk3, "")
@ -995,7 +995,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
CheckID: "lb",
Name: "lb",
Status: api.HealthPassing,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
args.Check = chk4
if err := a.RPC("Catalog.Register", args, &out); err != nil {
@ -1008,7 +1008,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
CheckID: "cache",
Name: "cache",
Status: api.HealthPassing,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.SetCheckState(&local.CheckState{
Check: chk5,
@ -1056,7 +1056,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
}
}
if err := checksInSync(a.State, 4, structs.DefaultEnterpriseMeta()); err != nil {
if err := checksInSync(a.State, 4, structs.DefaultEnterpriseMetaInDefaultPartition()); err != nil {
r.Fatal(err)
}
})
@ -1119,7 +1119,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
}
}
if err := checksInSync(a.State, 3, structs.DefaultEnterpriseMeta()); err != nil {
if err := checksInSync(a.State, 3, structs.DefaultEnterpriseMetaInDefaultPartition()); err != nil {
r.Fatal(err)
}
})
@ -1165,7 +1165,7 @@ func TestAgentAntiEntropy_RemovingServiceAndCheck(t *testing.T) {
Name: "lb",
ServiceID: svcID,
Status: api.HealthPassing,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
args.Check = chk
@ -1250,7 +1250,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddService(srv1, "root")
srv2 := &structs.NodeService{
@ -1262,7 +1262,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddService(srv2, "root")
@ -1304,7 +1304,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
}
}
if err := servicesInSync(a.State, 2, structs.DefaultEnterpriseMeta()); err != nil {
if err := servicesInSync(a.State, 2, structs.DefaultEnterpriseMetaInDefaultPartition()); err != nil {
t.Fatal(err)
}
}
@ -1318,7 +1318,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
CheckID: "mysql-check",
Name: "mysql",
Status: api.HealthPassing,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddCheck(chk1, token)
@ -1331,7 +1331,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
CheckID: "api-check",
Name: "api",
Status: api.HealthPassing,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
a.State.AddCheck(chk2, token)
@ -1372,7 +1372,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
}
}
if err := checksInSync(a.State, 2, structs.DefaultEnterpriseMeta()); err != nil {
if err := checksInSync(a.State, 2, structs.DefaultEnterpriseMetaInDefaultPartition()); err != nil {
t.Fatal(err)
}
@ -1417,7 +1417,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
}
}
if err := checksInSync(a.State, 1, structs.DefaultEnterpriseMeta()); err != nil {
if err := checksInSync(a.State, 1, structs.DefaultEnterpriseMetaInDefaultPartition()); err != nil {
t.Fatal(err)
}
@ -1863,19 +1863,19 @@ func TestAgent_CheckCriticalTime(t *testing.T) {
Status: api.HealthPassing,
}
l.AddCheck(chk, "")
if checks := l.CriticalCheckStates(structs.DefaultEnterpriseMeta()); len(checks) > 0 {
if checks := l.CriticalCheckStates(structs.DefaultEnterpriseMetaInDefaultPartition()); len(checks) > 0 {
t.Fatalf("should not have any critical checks")
}
// Set it to warning and make sure that doesn't show up as critical.
l.UpdateCheck(structs.NewCheckID(checkID, nil), api.HealthWarning, "")
if checks := l.CriticalCheckStates(structs.DefaultEnterpriseMeta()); len(checks) > 0 {
if checks := l.CriticalCheckStates(structs.DefaultEnterpriseMetaInDefaultPartition()); len(checks) > 0 {
t.Fatalf("should not have any critical checks")
}
// Fail the check and make sure the time looks reasonable.
l.UpdateCheck(structs.NewCheckID(checkID, nil), api.HealthCritical, "")
if c, ok := l.CriticalCheckStates(structs.DefaultEnterpriseMeta())[structs.NewCheckID(checkID, nil)]; !ok {
if c, ok := l.CriticalCheckStates(structs.DefaultEnterpriseMetaInDefaultPartition())[structs.NewCheckID(checkID, nil)]; !ok {
t.Fatalf("should have a critical check")
} else if c.CriticalFor() > time.Millisecond {
t.Fatalf("bad: %#v, check was critical for %v", c, c.CriticalFor())
@ -1886,7 +1886,7 @@ func TestAgent_CheckCriticalTime(t *testing.T) {
// 50ms the check should not be any less than that.
time.Sleep(50 * time.Millisecond)
l.UpdateCheck(chk.CompoundCheckID(), api.HealthCritical, "")
if c, ok := l.CriticalCheckStates(structs.DefaultEnterpriseMeta())[structs.NewCheckID(checkID, nil)]; !ok {
if c, ok := l.CriticalCheckStates(structs.DefaultEnterpriseMetaInDefaultPartition())[structs.NewCheckID(checkID, nil)]; !ok {
t.Fatalf("should have a critical check")
} else if c.CriticalFor() < 50*time.Millisecond {
t.Fatalf("bad: %#v, check was critical for %v", c, c.CriticalFor())
@ -1894,14 +1894,14 @@ func TestAgent_CheckCriticalTime(t *testing.T) {
// Set it passing again.
l.UpdateCheck(structs.NewCheckID(checkID, nil), api.HealthPassing, "")
if checks := l.CriticalCheckStates(structs.DefaultEnterpriseMeta()); len(checks) > 0 {
if checks := l.CriticalCheckStates(structs.DefaultEnterpriseMetaInDefaultPartition()); len(checks) > 0 {
t.Fatalf("should not have any critical checks")
}
// Fail the check and make sure the time looks like it started again
// from the latest failure, not the original one.
l.UpdateCheck(structs.NewCheckID(checkID, nil), api.HealthCritical, "")
if c, ok := l.CriticalCheckStates(structs.DefaultEnterpriseMeta())[structs.NewCheckID(checkID, nil)]; !ok {
if c, ok := l.CriticalCheckStates(structs.DefaultEnterpriseMetaInDefaultPartition())[structs.NewCheckID(checkID, nil)]; !ok {
t.Fatalf("should have a critical check")
} else if c.CriticalFor() > time.Millisecond {
t.Fatalf("bad: %#v, check was critical for %v", c, c.CriticalFor())
@ -2282,7 +2282,7 @@ func TestState_SyncChanges_DuplicateAddServiceOnlySyncsOnce(t *testing.T) {
Kind: structs.ServiceKindTypical,
ID: "the-service-id",
Service: "web",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
checks := []*structs.HealthCheck{
{Node: "this-node", CheckID: "the-id-1", Name: "check-healthy-1"},

View File

@ -86,7 +86,7 @@ func (s *handlerConnectProxy) initialize(ctx context.Context) (ConfigSnapshot, e
Datacenter: s.source.Datacenter,
QueryOptions: structs.QueryOptions{Token: s.token},
ServiceName: s.proxyCfg.DestinationServiceName,
EnterpriseMeta: structs.NewEnterpriseMeta(s.proxyID.NamespaceOrEmpty()),
EnterpriseMeta: structs.NewEnterpriseMetaInDefaultPartition(s.proxyID.NamespaceOrEmpty()),
}, intentionUpstreamsID, s.ch)
if err != nil {
return snap, err
@ -97,7 +97,7 @@ func (s *handlerConnectProxy) initialize(ctx context.Context) (ConfigSnapshot, e
Name: structs.MeshConfigMesh,
Datacenter: s.source.Datacenter,
QueryOptions: structs.QueryOptions{Token: s.token},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}, meshConfigEntryID, s.ch)
if err != nil {
return snap, err
@ -228,7 +228,7 @@ func (s *handlerConnectProxy) handleUpdate(ctx context.Context, u cache.UpdateEv
// Use the centralized upstream defaults if they exist and there isn't specific configuration for this upstream
// This is only relevant to upstreams from intentions because for explicit upstreams the defaulting is handled
// by the ResolveServiceConfig endpoint.
wildcardSID := structs.NewServiceID(structs.WildcardSpecifier, structs.WildcardEnterpriseMeta())
wildcardSID := structs.NewServiceID(structs.WildcardSpecifier, structs.WildcardEnterpriseMetaInDefaultPartition())
defaults, ok := snap.ConnectProxy.UpstreamConfig[wildcardSID.String()]
if ok {
u = defaults

View File

@ -141,7 +141,7 @@ func (m *Manager) syncState() {
defer m.mu.Unlock()
// Traverse the local state and ensure all proxy services are registered
services := m.State.Services(structs.WildcardEnterpriseMeta())
services := m.State.Services(structs.WildcardEnterpriseMetaInDefaultPartition())
for sid, svc := range services {
if svc.Kind != structs.ServiceKindConnectProxy &&
svc.Kind != structs.ServiceKindTerminatingGateway &&

View File

@ -169,7 +169,7 @@ func TestManager_BasicLifecycle(t *testing.T) {
QueryOptions: structs.QueryOptions{Token: "my-token", Filter: ""},
ServiceName: "db",
Connect: true,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
})
db_v1_HealthCacheKey := testGenCacheKey(&structs.ServiceSpecificRequest{
Datacenter: "dc1",
@ -178,7 +178,7 @@ func TestManager_BasicLifecycle(t *testing.T) {
},
ServiceName: "db",
Connect: true,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
})
db_v2_HealthCacheKey := testGenCacheKey(&structs.ServiceSpecificRequest{
Datacenter: "dc1",
@ -187,7 +187,7 @@ func TestManager_BasicLifecycle(t *testing.T) {
},
ServiceName: "db",
Connect: true,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
})
db := structs.NewServiceName("db", nil)

View File

@ -34,7 +34,7 @@ func (s *handlerMeshGateway) initialize(ctx context.Context) (ConfigSnapshot, er
Datacenter: s.source.Datacenter,
QueryOptions: structs.QueryOptions{Token: s.token},
Source: *s.source,
EnterpriseMeta: *structs.WildcardEnterpriseMeta(),
EnterpriseMeta: *structs.WildcardEnterpriseMetaInDefaultPartition(),
}, serviceListWatchID, s.ch)
if err != nil {
@ -85,7 +85,7 @@ func (s *handlerMeshGateway) initialize(ctx context.Context) (ConfigSnapshot, er
Datacenter: s.source.Datacenter,
QueryOptions: structs.QueryOptions{Token: s.token},
Kind: structs.ServiceResolver,
EnterpriseMeta: *structs.WildcardEnterpriseMeta(),
EnterpriseMeta: *structs.WildcardEnterpriseMetaInDefaultPartition(),
}, serviceResolversWatchID, s.ch)
if err != nil {
s.logger.Named(logging.MeshGateway).
@ -205,7 +205,7 @@ func (s *handlerMeshGateway) handleUpdate(ctx context.Context, u cache.UpdateEve
ServiceKind: structs.ServiceKindMeshGateway,
UseServiceKind: true,
Source: *s.source,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}, fmt.Sprintf("mesh-gateway:%s", dc), s.ch)
if err != nil {

View File

@ -312,7 +312,7 @@ func genVerifyGatewayWatch(expectedDatacenter string) verifyWatchRequest {
require.Equal(t, expectedDatacenter, reqReal.Datacenter)
require.True(t, reqReal.UseServiceKind)
require.Equal(t, structs.ServiceKindMeshGateway, reqReal.ServiceKind)
require.Equal(t, structs.DefaultEnterpriseMeta(), &reqReal.EnterpriseMeta)
require.Equal(t, structs.DefaultEnterpriseMetaInDefaultPartition(), &reqReal.EnterpriseMeta)
}
}
@ -1658,7 +1658,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
// Centrally configured upstream defaults should be stored so that upstreams from intentions can inherit them
require.Len(t, snap.ConnectProxy.UpstreamConfig, 1)
wc := structs.NewServiceName(structs.WildcardSpecifier, structs.WildcardEnterpriseMeta())
wc := structs.NewServiceName(structs.WildcardSpecifier, structs.WildcardEnterpriseMetaInDefaultPartition())
require.Contains(t, snap.ConnectProxy.UpstreamConfig, wc.String())
},
},
@ -2011,7 +2011,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
// Centrally configured upstream defaults should be stored so that upstreams from intentions can inherit them
require.Len(t, snap.ConnectProxy.UpstreamConfig, 2)
wc := structs.NewServiceName(structs.WildcardSpecifier, structs.WildcardEnterpriseMeta())
wc := structs.NewServiceName(structs.WildcardSpecifier, structs.WildcardEnterpriseMetaInDefaultPartition())
require.Contains(t, snap.ConnectProxy.UpstreamConfig, wc.String())
require.Contains(t, snap.ConnectProxy.UpstreamConfig, upstreamIDForDC2(db.String()))
},

View File

@ -229,7 +229,7 @@ func (s *handlerUpstreams) resetWatchesFromChain(
// Outside of transparent mode we only watch the chain target, B,
// since A is a virtual service and traffic will not be sent to it.
if !watchedChainEndpoints && s.proxyCfg.Mode == structs.ProxyModeTransparent {
chainEntMeta := structs.NewEnterpriseMeta(chain.Namespace)
chainEntMeta := structs.NewEnterpriseMetaInDefaultPartition(chain.Namespace)
opts := targetWatchOpts{
upstreamID: id,
@ -299,7 +299,7 @@ func (s *handlerUpstreams) watchMeshGateway(ctx context.Context, dc string, upst
ServiceKind: structs.ServiceKindMeshGateway,
UseServiceKind: true,
Source: *s.source,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}, "mesh-gateway:"+dc+":"+upstreamID, s.ch)
}

View File

@ -51,7 +51,7 @@ func (h *Server) Subscribe(req *pbsubscribe.SubscribeRequest, serverStream pbsub
logger.Trace("new subscription")
defer logger.Trace("subscription closed")
entMeta := structs.NewEnterpriseMeta(req.Namespace)
entMeta := structs.NewEnterpriseMetaInDefaultPartition(req.Namespace)
authz, err := h.Backend.ResolveTokenAndDefaultMeta(req.Token, &entMeta, nil)
if err != nil {
return err

View File

@ -51,7 +51,7 @@ func TestSortCheckServiceNodes_OrderIsConsistentWithRPCResponse(t *testing.T) {
CreateIndex: index,
ModifyIndex: index,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Checks: []*structs.HealthCheck{},
}
@ -92,7 +92,7 @@ func TestHealthView_IntegrationWithStore_WithEmptySnapshot(t *testing.T) {
ServiceSpecificRequest: structs.ServiceSpecificRequest{
Datacenter: "dc1",
ServiceName: "web",
EnterpriseMeta: structs.NewEnterpriseMeta(namespace),
EnterpriseMeta: structs.NewEnterpriseMetaInDefaultPartition(namespace),
QueryOptions: structs.QueryOptions{MaxQueryTime: time.Second},
},
},
@ -277,7 +277,7 @@ func TestHealthView_IntegrationWithStore_WithFullSnapshot(t *testing.T) {
ServiceSpecificRequest: structs.ServiceSpecificRequest{
Datacenter: "dc1",
ServiceName: "web",
EnterpriseMeta: structs.NewEnterpriseMeta(namespace),
EnterpriseMeta: structs.NewEnterpriseMetaInDefaultPartition(namespace),
QueryOptions: structs.QueryOptions{MaxQueryTime: time.Second},
},
},
@ -429,7 +429,7 @@ func TestHealthView_IntegrationWithStore_EventBatches(t *testing.T) {
ServiceSpecificRequest: structs.ServiceSpecificRequest{
Datacenter: "dc1",
ServiceName: "web",
EnterpriseMeta: structs.NewEnterpriseMeta(namespace),
EnterpriseMeta: structs.NewEnterpriseMetaInDefaultPartition(namespace),
QueryOptions: structs.QueryOptions{MaxQueryTime: time.Second},
},
},
@ -486,7 +486,7 @@ func TestHealthView_IntegrationWithStore_Filtering(t *testing.T) {
ServiceSpecificRequest: structs.ServiceSpecificRequest{
Datacenter: "dc1",
ServiceName: "web",
EnterpriseMeta: structs.NewEnterpriseMeta(namespace),
EnterpriseMeta: structs.NewEnterpriseMetaInDefaultPartition(namespace),
QueryOptions: structs.QueryOptions{
Filter: `Node.Node == "node2"`,
MaxQueryTime: time.Second,
@ -659,7 +659,7 @@ func newNewSnapshotToFollowEvent() *pbsubscribe.Event {
// returns the empty string. It allows the same tests to work in both oss and ent
// without duplicating the tests.
func getNamespace(ns string) string {
meta := structs.NewEnterpriseMeta(ns)
meta := structs.NewEnterpriseMetaInDefaultPartition(ns)
return meta.NamespaceOrEmpty()
}

View File

@ -3,12 +3,13 @@ package agent
import (
"encoding/json"
"fmt"
"github.com/mitchellh/copystructure"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/mitchellh/copystructure"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -48,7 +49,7 @@ func TestServiceManager_RegisterService(t *testing.T) {
ID: "redis",
Service: "redis",
Port: 8000,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
require.NoError(a.addServiceFromSource(svc, nil, false, "", ConfigSourceLocal))
@ -64,7 +65,7 @@ func TestServiceManager_RegisterService(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}, redisService)
}
@ -120,7 +121,7 @@ func TestServiceManager_RegisterSidecar(t *testing.T) {
},
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
require.NoError(a.addServiceFromSource(svc, nil, false, "", ConfigSourceLocal))
@ -157,7 +158,7 @@ func TestServiceManager_RegisterSidecar(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}, sidecarService)
}
@ -193,7 +194,7 @@ func TestServiceManager_RegisterMeshGateway(t *testing.T) {
ID: "mesh-gateway",
Service: "mesh-gateway",
Port: 443,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
require.NoError(a.addServiceFromSource(svc, nil, false, "", ConfigSourceLocal))
@ -217,7 +218,7 @@ func TestServiceManager_RegisterMeshGateway(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}, gateway)
}
@ -253,7 +254,7 @@ func TestServiceManager_RegisterTerminatingGateway(t *testing.T) {
ID: "terminating-gateway",
Service: "terminating-gateway",
Port: 443,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
require.NoError(a.addServiceFromSource(svc, nil, false, "", ConfigSourceLocal))
@ -277,7 +278,7 @@ func TestServiceManager_RegisterTerminatingGateway(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}, gateway)
}
@ -351,7 +352,7 @@ func TestServiceManager_PersistService_API(t *testing.T) {
},
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
}
@ -385,7 +386,7 @@ func TestServiceManager_PersistService_API(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
svc := newNodeService()
@ -435,7 +436,7 @@ func TestServiceManager_PersistService_API(t *testing.T) {
},
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
expectJSONFile(t, configFile, pcfg, resetDefaultsQueryMeta)
@ -483,7 +484,7 @@ func TestServiceManager_PersistService_API(t *testing.T) {
},
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
expectJSONFile(t, configFile, pcfg, resetDefaultsQueryMeta)
@ -622,7 +623,7 @@ func TestServiceManager_PersistService_ConfigFiles(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
// Now wait until we've re-registered using central config updated data.
@ -660,7 +661,7 @@ func TestServiceManager_PersistService_ConfigFiles(t *testing.T) {
},
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}, resetDefaultsQueryMeta)
// Verify in memory state.
@ -743,7 +744,7 @@ func TestServiceManager_Disabled(t *testing.T) {
},
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}
require.NoError(a.addServiceFromSource(svc, nil, false, "", ConfigSourceLocal))
@ -774,7 +775,7 @@ func TestServiceManager_Disabled(t *testing.T) {
Passing: 1,
Warning: 1,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
}, sidecarService)
}
@ -884,7 +885,7 @@ func Test_mergeServiceConfig_UpstreamOverrides(t *testing.T) {
{
Upstream: structs.ServiceID{
ID: "zap",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Config: map[string]interface{}{
"passive_health_check": map[string]interface{}{
@ -947,7 +948,7 @@ func Test_mergeServiceConfig_UpstreamOverrides(t *testing.T) {
{
Upstream: structs.ServiceID{
ID: "zap",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Config: map[string]interface{}{
"protocol": "grpc",
@ -1019,7 +1020,7 @@ func Test_mergeServiceConfig_UpstreamOverrides(t *testing.T) {
{
Upstream: structs.ServiceID{
ID: "zap",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Config: map[string]interface{}{
"protocol": "grpc",
@ -1075,7 +1076,7 @@ func Test_mergeServiceConfig_UpstreamOverrides(t *testing.T) {
{
Upstream: structs.ServiceID{
ID: "zap",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Config: map[string]interface{}{
"mesh_gateway": map[string]interface{}{
@ -1133,7 +1134,7 @@ func Test_mergeServiceConfig_UpstreamOverrides(t *testing.T) {
{
Upstream: structs.ServiceID{
ID: "zap",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Config: map[string]interface{}{
"mesh_gateway": map[string]interface{}{

View File

@ -126,7 +126,7 @@ func (a *Agent) sidecarServiceFromNodeService(ns *structs.NodeService, token str
// it doesn't seem to be necessary - even with thousands of services this is
// not expensive to compute.
usedPorts := make(map[int]struct{})
for _, otherNS := range a.State.Services(structs.WildcardEnterpriseMeta()) {
for _, otherNS := range a.State.Services(structs.WildcardEnterpriseMetaInDefaultPartition()) {
// Check if other port is in auto-assign range
if otherNS.Port >= a.config.ConnectSidecarMinPort &&
otherNS.Port <= a.config.ConnectSidecarMaxPort {

View File

@ -51,7 +51,7 @@ func TestAgent_sidecarServiceFromNodeService(t *testing.T) {
},
token: "foo",
wantNS: &structs.NodeService{
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Kind: structs.ServiceKindConnectProxy,
ID: "web1-sidecar-proxy",
Service: "web-sidecar-proxy",
@ -111,7 +111,7 @@ func TestAgent_sidecarServiceFromNodeService(t *testing.T) {
},
token: "foo",
wantNS: &structs.NodeService{
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Kind: structs.ServiceKindConnectProxy,
ID: "web1-sidecar-proxy",
Service: "motorbike1",
@ -189,7 +189,7 @@ func TestAgent_sidecarServiceFromNodeService(t *testing.T) {
},
},
wantNS: &structs.NodeService{
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Kind: structs.ServiceKindConnectProxy,
ID: "web1-sidecar-proxy",
Service: "web-sidecar-proxy",
@ -279,7 +279,7 @@ func TestAgent_sidecarServiceFromNodeService(t *testing.T) {
},
token: "foo",
wantNS: &structs.NodeService{
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
Kind: structs.ServiceKindConnectProxy,
ID: "web1-sidecar-proxy",
Service: "web-sidecar-proxy",

View File

@ -229,7 +229,7 @@ func (s *ACLNodeIdentity) SyntheticPolicy() *ACLPolicy {
policy.Rules = rules
policy.Syntax = acl.SyntaxCurrent
policy.Datacenters = []string{s.Datacenter}
policy.EnterpriseMeta = *DefaultEnterpriseMeta()
policy.EnterpriseMeta = *DefaultEnterpriseMetaInDefaultPartition()
policy.SetHash(true)
return policy
}

View File

@ -55,7 +55,7 @@ func (_ *ACLAuthMethodEnterpriseMeta) FillWithEnterpriseMeta(_ *EnterpriseMeta)
}
func (_ *ACLAuthMethodEnterpriseMeta) ToEnterpriseMeta() *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
func aclServiceIdentityRules(svc string, _ *EnterpriseMeta) string {

View File

@ -5,31 +5,31 @@ package structs
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
// fields in the ServiceRouteDestination
func (dest *ServiceRouteDestination) GetEnterpriseMeta(_ *EnterpriseMeta) *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
// fields in the ServiceSplit
func (split *ServiceSplit) GetEnterpriseMeta(_ *EnterpriseMeta) *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
// fields in the ServiceResolverRedirect
func (redir *ServiceResolverRedirect) GetEnterpriseMeta(_ *EnterpriseMeta) *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
// fields in the ServiceResolverFailover
func (failover *ServiceResolverFailover) GetEnterpriseMeta(_ *EnterpriseMeta) *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
// fields in the DiscoveryChainRequest
func (req *DiscoveryChainRequest) GetEnterpriseMeta() *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
// WithEnterpriseMeta will populate the corresponding fields in the

View File

@ -7,7 +7,7 @@ import (
)
func TestIngressGatewayConfigEntry(t *testing.T) {
defaultMeta := DefaultEnterpriseMeta()
defaultMeta := DefaultEnterpriseMetaInDefaultPartition()
cases := map[string]configEntryTestcase{
"normalize: empty protocol": {

View File

@ -45,7 +45,7 @@ func TestServiceIntentionsConfigEntry(t *testing.T) {
generateUUID(),
}
defaultMeta := DefaultEnterpriseMeta()
defaultMeta := DefaultEnterpriseMetaInDefaultPartition()
fooName := NewServiceName("foo", defaultMeta)

View File

@ -1671,21 +1671,21 @@ func TestServiceConfigEntry(t *testing.T) {
expected: &ServiceConfigEntry{
Kind: ServiceDefaults,
Name: "web",
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
UpstreamConfig: &UpstreamConfiguration{
Overrides: []*UpstreamConfig{
{
Name: "good",
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
Protocol: "grpc",
},
{
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
Protocol: "http2",
},
{
Name: "also-good",
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
Protocol: "http",
},
},
@ -1707,7 +1707,7 @@ func TestServiceConfigEntry(t *testing.T) {
expected: &ServiceConfigEntry{
Kind: ServiceDefaults,
Name: "web",
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
UpstreamConfig: &UpstreamConfiguration{
Defaults: &UpstreamConfig{
Name: "also-good",
@ -1724,7 +1724,7 @@ func TestServiceConfigEntry(t *testing.T) {
expected: &ServiceConfigEntry{
Kind: ServiceDefaults,
Name: "web",
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
},
normalizeOnly: true,
},
@ -1738,7 +1738,7 @@ func TestServiceConfigEntry(t *testing.T) {
Kind: ServiceDefaults,
Name: "web",
Protocol: "protocol",
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
},
normalizeOnly: true,
},
@ -1759,7 +1759,7 @@ func TestServiceConfigEntry(t *testing.T) {
},
Defaults: &UpstreamConfig{ConnectTimeoutMs: -20},
},
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
},
expected: &ServiceConfigEntry{
Kind: ServiceDefaults,
@ -1768,13 +1768,13 @@ func TestServiceConfigEntry(t *testing.T) {
Overrides: []*UpstreamConfig{
{
Name: "redis",
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
Protocol: "tcp",
ConnectTimeoutMs: 0,
},
{
Name: "memcached",
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
ConnectTimeoutMs: 0,
},
},
@ -1782,7 +1782,7 @@ func TestServiceConfigEntry(t *testing.T) {
ConnectTimeoutMs: 0,
},
},
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
},
normalizeOnly: true,
},
@ -1842,7 +1842,7 @@ func TestServiceConfigEntry(t *testing.T) {
},
Defaults: &UpstreamConfig{ConnectTimeoutMs: -20},
},
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
},
expected: &ServiceConfigEntry{
Kind: ServiceDefaults,
@ -1851,19 +1851,19 @@ func TestServiceConfigEntry(t *testing.T) {
Overrides: []*UpstreamConfig{
{
Name: "redis",
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
Protocol: "tcp",
ConnectTimeoutMs: 0,
},
{
Name: "memcached",
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
ConnectTimeoutMs: 0,
},
},
Defaults: &UpstreamConfig{ConnectTimeoutMs: 0},
},
EnterpriseMeta: *DefaultEnterpriseMeta(),
EnterpriseMeta: *DefaultEnterpriseMetaInDefaultPartition(),
},
},
}

View File

@ -3,7 +3,7 @@
package structs
func (us *Upstream) GetEnterpriseMeta() *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
func (us *Upstream) DestinationID() ServiceID {

View File

@ -95,7 +95,7 @@ func (c *CompiledDiscoveryChain) ID() string {
}
func (c *CompiledDiscoveryChain) CompoundServiceName() ServiceName {
entMeta := NewEnterpriseMeta(c.Namespace)
entMeta := NewEnterpriseMetaInDefaultPartition(c.Namespace)
return NewServiceName(c.ServiceName, &entMeta)
}

View File

@ -3,5 +3,5 @@
package structs
func (t *DiscoveryTarget) GetEnterpriseMetadata() *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}

View File

@ -7,23 +7,23 @@ import (
)
func (ixn *Intention) SourceEnterpriseMeta() *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
func (ixn *Intention) DestinationEnterpriseMeta() *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
func (e *IntentionMatchEntry) GetEnterpriseMeta() *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
func (e *IntentionQueryExact) SourceEnterpriseMeta() *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
func (e *IntentionQueryExact) DestinationEnterpriseMeta() *EnterpriseMeta {
return DefaultEnterpriseMeta()
return DefaultEnterpriseMetaInDefaultPartition()
}
// FillAuthzContext can fill in an acl.AuthorizerContext object to setup

View File

@ -445,7 +445,7 @@ func TestIntention_String(t *testing.T) {
for name, tc := range cases {
tc := tc
// Add a bunch of required fields.
tc.ixn.DefaultNamespaces(DefaultEnterpriseMeta())
tc.ixn.DefaultNamespaces(DefaultEnterpriseMetaInDefaultPartition())
tc.ixn.UpdatePrecedence()
t.Run(name, func(t *testing.T) {

View File

@ -1817,7 +1817,7 @@ func NewCheckID(id types.CheckID, entMeta *EnterpriseMeta) CheckID {
var cid CheckID
cid.ID = id
if entMeta == nil {
entMeta = DefaultEnterpriseMeta()
entMeta = DefaultEnterpriseMetaInDefaultPartition()
}
cid.EnterpriseMeta = *entMeta
@ -1843,7 +1843,7 @@ func NewServiceID(id string, entMeta *EnterpriseMeta) ServiceID {
var sid ServiceID
sid.ID = id
if entMeta == nil {
entMeta = DefaultEnterpriseMeta()
entMeta = DefaultEnterpriseMetaInDefaultPartition()
}
sid.EnterpriseMeta = *entMeta
@ -1886,7 +1886,7 @@ func NewServiceName(name string, entMeta *EnterpriseMeta) ServiceName {
var ret ServiceName
ret.Name = name
if entMeta == nil {
entMeta = DefaultEnterpriseMeta()
entMeta = DefaultEnterpriseMetaInDefaultPartition()
}
ret.EnterpriseMeta = *entMeta

View File

@ -42,6 +42,31 @@ func (m *EnterpriseMeta) LessThan(_ *EnterpriseMeta) bool {
return false
}
func (m *EnterpriseMeta) WildcardEnterpriseMetaForPartition() *EnterpriseMeta {
return &emptyEnterpriseMeta
}
func (m *EnterpriseMeta) DefaultEnterpriseMetaForPartition() *EnterpriseMeta {
return &emptyEnterpriseMeta
}
func (m *EnterpriseMeta) NodeEnterpriseMetaForPartition() *EnterpriseMeta {
return &emptyEnterpriseMeta
}
func (m *EnterpriseMeta) NewEnterpriseMetaInPartition(_ string) *EnterpriseMeta {
return &emptyEnterpriseMeta
}
// TODO(partition): stop using this
func NewEnterpriseMetaInDefaultPartition(_ string) EnterpriseMeta {
return emptyEnterpriseMeta
}
func NewEnterpriseMetaWithPartition(_, _ string) EnterpriseMeta {
return emptyEnterpriseMeta
}
func (m *EnterpriseMeta) NamespaceOrDefault() string {
return IntentionDefaultNamespace
}
@ -66,22 +91,36 @@ func (m *EnterpriseMeta) PartitionOrEmpty() string {
return ""
}
func NewEnterpriseMeta(_ string) EnterpriseMeta {
return emptyEnterpriseMeta
}
// ReplicationEnterpriseMeta stub
func ReplicationEnterpriseMeta() *EnterpriseMeta {
return &emptyEnterpriseMeta
}
// DefaultEnterpriseMeta stub
func DefaultEnterpriseMeta() *EnterpriseMeta {
// TODO(partition): stop using this
func DefaultEnterpriseMetaInDefaultPartition() *EnterpriseMeta {
return &emptyEnterpriseMeta
}
// WildcardEnterpriseMeta stub
func WildcardEnterpriseMeta() *EnterpriseMeta {
// DefaultEnterpriseMetaInPartition stub
func DefaultEnterpriseMetaInPartition(_ string) *EnterpriseMeta {
return &emptyEnterpriseMeta
}
func NodeEnterpriseMetaInPartition(_ string) *EnterpriseMeta {
return &emptyEnterpriseMeta
}
func NodeEnterpriseMetaInDefaultPartition() *EnterpriseMeta {
return &emptyEnterpriseMeta
}
// TODO(partition): stop using this
func WildcardEnterpriseMetaInDefaultPartition() *EnterpriseMeta {
return &emptyEnterpriseMeta
}
// WildcardEnterpriseMetaInPartition stub
func WildcardEnterpriseMetaInPartition(_ string) *EnterpriseMeta {
return &emptyEnterpriseMeta
}
@ -114,7 +153,7 @@ func ServiceIDString(id string, _ *EnterpriseMeta) string {
}
func ParseServiceIDString(input string) (string, *EnterpriseMeta) {
return input, DefaultEnterpriseMeta()
return input, DefaultEnterpriseMetaInDefaultPartition()
}
func (sid ServiceID) String() string {
@ -127,7 +166,7 @@ func ServiceIDFromString(input string) ServiceID {
}
func ParseServiceNameString(input string) (string, *EnterpriseMeta) {
return input, DefaultEnterpriseMeta()
return input, DefaultEnterpriseMetaInDefaultPartition()
}
func (n ServiceName) String() string {

View File

@ -156,7 +156,7 @@ func (s *HTTPHandlers) convertOps(resp http.ResponseWriter, req *http.Request) (
Value: in.KV.Value,
Flags: in.KV.Flags,
Session: in.KV.Session,
EnterpriseMeta: structs.NewEnterpriseMeta(in.KV.Namespace),
EnterpriseMeta: structs.NewEnterpriseMetaInDefaultPartition(in.KV.Namespace),
RaftIndex: structs.RaftIndex{
ModifyIndex: in.KV.Index,
},
@ -216,7 +216,7 @@ func (s *HTTPHandlers) convertOps(resp http.ResponseWriter, req *http.Request) (
Warning: svc.Weights.Warning,
},
EnableTagOverride: svc.EnableTagOverride,
EnterpriseMeta: structs.NewEnterpriseMeta(svc.Namespace),
EnterpriseMeta: structs.NewEnterpriseMetaInDefaultPartition(svc.Namespace),
RaftIndex: structs.RaftIndex{
ModifyIndex: svc.ModifyIndex,
},
@ -274,7 +274,7 @@ func (s *HTTPHandlers) convertOps(resp http.ResponseWriter, req *http.Request) (
Timeout: timeout,
DeregisterCriticalServiceAfter: deregisterCriticalServiceAfter,
},
EnterpriseMeta: structs.NewEnterpriseMeta(check.Namespace),
EnterpriseMeta: structs.NewEnterpriseMetaInDefaultPartition(check.Namespace),
RaftIndex: structs.RaftIndex{
ModifyIndex: check.ModifyIndex,
},

View File

@ -621,7 +621,7 @@ func TestTxnEndpoint_UpdateCheck(t *testing.T) {
CreateIndex: index,
ModifyIndex: index,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
&structs.TxnResult{
@ -643,7 +643,7 @@ func TestTxnEndpoint_UpdateCheck(t *testing.T) {
CreateIndex: index,
ModifyIndex: index,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
&structs.TxnResult{
@ -665,7 +665,7 @@ func TestTxnEndpoint_UpdateCheck(t *testing.T) {
CreateIndex: index,
ModifyIndex: index,
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},

View File

@ -611,7 +611,7 @@ func (s *HTTPHandlers) UIMetricsProxy(resp http.ResponseWriter, req *http.Reques
// This endpoint requires wildcard read on all services and all nodes.
//
// In enterprise it requires this _in all namespaces_ too.
wildMeta := structs.WildcardEnterpriseMeta()
wildMeta := structs.WildcardEnterpriseMetaInDefaultPartition()
var authzContext acl.AuthorizerContext
wildMeta.FillAuthzContext(&authzContext)

View File

@ -413,7 +413,7 @@ func TestUiServices(t *testing.T) {
ChecksPassing: 2,
ChecksWarning: 1,
ChecksCritical: 0,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
ConnectedWithProxy: true,
ConnectedWithGateway: true,
@ -430,7 +430,7 @@ func TestUiServices(t *testing.T) {
ChecksWarning: 0,
ChecksCritical: 0,
ExternalSources: []string{"k8s"},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
{
@ -444,7 +444,7 @@ func TestUiServices(t *testing.T) {
ChecksPassing: 0,
ChecksWarning: 0,
ChecksCritical: 0,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
ConnectedWithGateway: true,
},
@ -459,7 +459,7 @@ func TestUiServices(t *testing.T) {
ChecksPassing: 1,
ChecksWarning: 0,
ChecksCritical: 0,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
{
@ -474,7 +474,7 @@ func TestUiServices(t *testing.T) {
ChecksWarning: 0,
ChecksCritical: 0,
GatewayConfig: GatewayConfig{AssociatedServiceCount: 2},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
{
@ -489,7 +489,7 @@ func TestUiServices(t *testing.T) {
ChecksWarning: 0,
ChecksCritical: 1,
ExternalSources: []string{"k8s"},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
}
@ -526,7 +526,7 @@ func TestUiServices(t *testing.T) {
ChecksPassing: 1,
ChecksWarning: 1,
ChecksCritical: 0,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
ConnectedWithProxy: false,
ConnectedWithGateway: false,
@ -543,7 +543,7 @@ func TestUiServices(t *testing.T) {
ChecksWarning: 0,
ChecksCritical: 1,
ExternalSources: []string{"k8s"},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
}
@ -687,7 +687,7 @@ func TestUIGatewayServiceNodes_Terminating(t *testing.T) {
expect := []*ServiceSummary{
{
Name: "redis",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "db",
@ -698,7 +698,7 @@ func TestUIGatewayServiceNodes_Terminating(t *testing.T) {
ChecksPassing: 1,
ChecksWarning: 1,
ChecksCritical: 0,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
require.ElementsMatch(t, expect, summary)
@ -836,10 +836,10 @@ func TestUIGatewayServiceNodes_Ingress(t *testing.T) {
// Construct expected addresses so that differences between OSS/Ent are
// handled by code. We specifically don't include the trailing DNS . here as
// we are constructing what we are expecting, not the actual value
webDNS := serviceIngressDNSName("web", "dc1", "consul", structs.DefaultEnterpriseMeta())
webDNSAlt := serviceIngressDNSName("web", "dc1", "alt.consul", structs.DefaultEnterpriseMeta())
dbDNS := serviceIngressDNSName("db", "dc1", "consul", structs.DefaultEnterpriseMeta())
dbDNSAlt := serviceIngressDNSName("db", "dc1", "alt.consul", structs.DefaultEnterpriseMeta())
webDNS := serviceIngressDNSName("web", "dc1", "consul", structs.DefaultEnterpriseMetaInDefaultPartition())
webDNSAlt := serviceIngressDNSName("web", "dc1", "alt.consul", structs.DefaultEnterpriseMetaInDefaultPartition())
dbDNS := serviceIngressDNSName("db", "dc1", "consul", structs.DefaultEnterpriseMetaInDefaultPartition())
dbDNSAlt := serviceIngressDNSName("db", "dc1", "alt.consul", structs.DefaultEnterpriseMetaInDefaultPartition())
dump := obj.([]*ServiceSummary)
expect := []*ServiceSummary{
@ -852,7 +852,7 @@ func TestUIGatewayServiceNodes_Ingress(t *testing.T) {
"*.test.example.com:8081",
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
{
Name: "db",
@ -869,7 +869,7 @@ func TestUIGatewayServiceNodes_Ingress(t *testing.T) {
fmt.Sprintf("%s:8888", dbDNSAlt),
},
},
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
}
@ -1383,7 +1383,7 @@ func TestUIServiceTopology(t *testing.T) {
Services: []structs.IngressService{
{
Name: "api",
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
@ -1435,7 +1435,7 @@ func TestUIServiceTopology(t *testing.T) {
Nodes: []string{"foo"},
InstanceCount: 1,
ChecksPassing: 3,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
TransparentProxy: true,
},
Intention: structs.IntentionDecisionSummary{
@ -1483,7 +1483,7 @@ func TestUIServiceTopology(t *testing.T) {
Nodes: []string{"edge"},
InstanceCount: 1,
ChecksPassing: 1,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
TransparentProxy: false,
},
Intention: structs.IntentionDecisionSummary{
@ -1505,7 +1505,7 @@ func TestUIServiceTopology(t *testing.T) {
ChecksPassing: 3,
ChecksWarning: 1,
ChecksCritical: 2,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
TransparentProxy: false,
},
Intention: structs.IntentionDecisionSummary{
@ -1557,7 +1557,7 @@ func TestUIServiceTopology(t *testing.T) {
InstanceCount: 1,
ChecksPassing: 2,
ChecksCritical: 1,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
TransparentProxy: false,
},
Intention: structs.IntentionDecisionSummary{
@ -1577,7 +1577,7 @@ func TestUIServiceTopology(t *testing.T) {
Nodes: []string{"foo"},
InstanceCount: 1,
ChecksPassing: 3,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
TransparentProxy: true,
},
Intention: structs.IntentionDecisionSummary{
@ -1630,7 +1630,7 @@ func TestUIServiceTopology(t *testing.T) {
ChecksPassing: 3,
ChecksWarning: 1,
ChecksCritical: 2,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
Intention: structs.IntentionDecisionSummary{
DefaultAllow: true,

View File

@ -187,7 +187,7 @@ func (a *Agent) shouldProcessUserEvent(msg *UserEvent) bool {
}
// Scan for a match
services := a.State.Services(structs.DefaultEnterpriseMeta())
services := a.State.Services(structs.DefaultEnterpriseMetaInDefaultPartition())
found := false
OUTER:
for name, info := range services {

View File

@ -598,8 +598,8 @@ func TestListenersFromSnapshot(t *testing.T) {
t, "kafka", "default", "dc1",
connect.TestClusterID+".consul", "dc1", nil)
kafka := structs.NewServiceName("kafka", structs.DefaultEnterpriseMeta())
mongo := structs.NewServiceName("mongo", structs.DefaultEnterpriseMeta())
kafka := structs.NewServiceName("kafka", structs.DefaultEnterpriseMetaInDefaultPartition())
mongo := structs.NewServiceName("mongo", structs.DefaultEnterpriseMetaInDefaultPartition())
// We add a filter chains for each passthrough service name.
// The filter chain will route to a cluster with the same SNI name.

View File

@ -9,5 +9,5 @@ import (
)
func parseEnterpriseMeta(node *envoy_core_v3.Node) *structs.EnterpriseMeta {
return structs.DefaultEnterpriseMeta()
return structs.DefaultEnterpriseMetaInDefaultPartition()
}