From 62ac98b564bc8e5c3747f96482e90a4338bb5d12 Mon Sep 17 00:00:00 2001 From: "R.B. Boyer" <4903+rboyer@users.noreply.github.com> Date: Thu, 22 Jul 2021 13:20:45 -0500 Subject: [PATCH] agent/structs: add a bunch more EnterpriseMeta helper functions to help with partitioning (#10669) --- agent/acl.go | 4 +- agent/acl_test.go | 2 +- agent/agent.go | 10 +- agent/agent_endpoint_test.go | 22 ++--- agent/agent_test.go | 52 +++++----- agent/auto-config/tls_test.go | 2 +- agent/checks/alias.go | 2 +- agent/config/builder.go | 2 +- agent/config/config_oss.go | 2 +- agent/config/runtime_test.go | 6 +- agent/config_endpoint_test.go | 8 +- agent/consul/acl.go | 16 ++-- agent/consul/acl_client.go | 2 +- agent/consul/acl_endpoint.go | 4 +- agent/consul/acl_endpoint_test.go | 4 +- agent/consul/acl_server.go | 4 +- agent/consul/auto_config_endpoint.go | 2 +- agent/consul/auto_config_endpoint_test.go | 8 +- agent/consul/config_endpoint.go | 2 +- agent/consul/config_endpoint_test.go | 8 +- agent/consul/connect_ca_endpoint.go | 2 +- agent/consul/coordinate_endpoint.go | 4 +- agent/consul/discoverychain/compile_oss.go | 2 +- agent/consul/filter.go | 2 +- agent/consul/fsm/commands_oss_test.go | 18 ++-- agent/consul/fsm/snapshot_oss_test.go | 16 ++-- agent/consul/intention_endpoint_test.go | 4 +- agent/consul/internal_endpoint_test.go | 28 +++--- agent/consul/leader.go | 18 ++-- agent/consul/leader_connect_ca.go | 2 +- agent/consul/leader_federation_state_ae.go | 2 +- agent/consul/leader_intentions.go | 4 +- agent/consul/leader_intentions_test.go | 4 +- agent/consul/leader_test.go | 8 +- agent/consul/prepared_query/walk_test.go | 2 +- agent/consul/server_test.go | 2 +- agent/consul/session_ttl.go | 2 +- agent/consul/state/acl.go | 8 +- agent/consul/state/acl_test.go | 2 +- agent/consul/state/catalog.go | 44 ++++----- agent/consul/state/catalog_events.go | 2 +- agent/consul/state/catalog_events_test.go | 96 +++++++++---------- agent/consul/state/catalog_test.go | 60 ++++++------ agent/consul/state/config_entry.go | 14 +-- agent/consul/state/config_entry_intention.go | 2 +- agent/consul/state/config_entry_test.go | 10 +- agent/consul/state/intention.go | 2 +- agent/consul/state/intention_test.go | 46 ++++----- agent/consul/state/txn_test.go | 24 ++--- agent/consul/txn_endpoint_test.go | 4 +- agent/dns.go | 4 +- agent/local/state.go | 2 +- agent/local/state_test.go | 82 ++++++++-------- agent/proxycfg/connect_proxy.go | 6 +- agent/proxycfg/manager.go | 2 +- agent/proxycfg/manager_test.go | 6 +- agent/proxycfg/mesh_gateway.go | 6 +- agent/proxycfg/state_test.go | 6 +- agent/proxycfg/upstreams.go | 4 +- agent/rpc/subscribe/subscribe.go | 2 +- agent/rpcclient/health/view_test.go | 12 +-- agent/service_manager_test.go | 45 ++++----- agent/sidecar_service.go | 2 +- agent/sidecar_service_test.go | 8 +- agent/structs/acl.go | 2 +- agent/structs/acl_oss.go | 2 +- .../config_entry_discoverychain_oss.go | 10 +- agent/structs/config_entry_gateways_test.go | 2 +- agent/structs/config_entry_intentions_test.go | 2 +- agent/structs/config_entry_test.go | 30 +++--- agent/structs/connect_proxy_config_oss.go | 2 +- agent/structs/discovery_chain.go | 2 +- agent/structs/discovery_chain_oss.go | 2 +- agent/structs/intention_oss.go | 10 +- agent/structs/intention_test.go | 2 +- agent/structs/structs.go | 6 +- agent/structs/structs_oss.go | 59 ++++++++++-- agent/txn_endpoint.go | 6 +- agent/txn_endpoint_test.go | 6 +- agent/ui_endpoint.go | 2 +- agent/ui_endpoint_test.go | 46 ++++----- agent/user_event.go | 2 +- agent/xds/listeners_test.go | 4 +- agent/xds/server_oss.go | 2 +- 84 files changed, 511 insertions(+), 471 deletions(-) diff --git a/agent/acl.go b/agent/acl.go index ad67f86c1..6eaeadc74 100644 --- a/agent/acl.go +++ b/agent/acl.go @@ -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 } diff --git a/agent/acl_test.go b/agent/acl_test.go index a1cf461f1..d1ad3edfe 100644 --- a/agent/acl_test.go +++ b/agent/acl_test.go @@ -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 diff --git a/agent/agent.go b/agent/agent.go index 784f69e53..ac81fb9a5 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -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 diff --git a/agent/agent_endpoint_test.go b/agent/agent_endpoint_test.go index 796b977e3..77dbb9489 100644 --- a/agent/agent_endpoint_test.go +++ b/agent/agent_endpoint_test.go @@ -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(), }, }, { diff --git a/agent/agent_test.go b/agent/agent_test.go index 67a6adf33..c7567f533 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -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) { diff --git a/agent/auto-config/tls_test.go b/agent/auto-config/tls_test.go index 400d7be0d..7b0e75c58 100644 --- a/agent/auto-config/tls_test.go +++ b/agent/auto-config/tls_test.go @@ -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, diff --git a/agent/checks/alias.go b/agent/checks/alias.go index af6155517..b2fb9c049 100644 --- a/agent/checks/alias.go +++ b/agent/checks/alias.go @@ -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) diff --git a/agent/config/builder.go b/agent/config/builder.go index fae31bac6..92171a8eb 100644 --- a/agent/config/builder.go +++ b/agent/config/builder.go @@ -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, diff --git a/agent/config/config_oss.go b/agent/config/config_oss.go index b54fc0dd4..95b1599dd 100644 --- a/agent/config/config_oss.go +++ b/agent/config/config_oss.go @@ -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() } diff --git a/agent/config/runtime_test.go b/agent/config/runtime_test.go index b4364983d..dad9cf723 100644 --- a/agent/config/runtime_test.go +++ b/agent/config/runtime_test.go @@ -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{ diff --git a/agent/config_endpoint_test.go b/agent/config_endpoint_test.go index 52e83b78a..8dc01ed8a 100644 --- a/agent/config_endpoint_test.go +++ b/agent/config_endpoint_test.go @@ -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) } diff --git a/agent/consul/acl.go b/agent/consul/acl.go index b440e7899..456a6efa2 100644 --- a/agent/consul/acl.go +++ b/agent/consul/acl.go @@ -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 diff --git a/agent/consul/acl_client.go b/agent/consul/acl_client.go index a1bb58adf..21106f37c 100644 --- a/agent/consul/acl_client.go +++ b/agent/consul/acl_client.go @@ -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 diff --git a/agent/consul/acl_endpoint.go b/agent/consul/acl_endpoint.go index a49ba0501..582a23631 100644 --- a/agent/consul/acl_endpoint.go +++ b/agent/consul/acl_endpoint.go @@ -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 } diff --git a/agent/consul/acl_endpoint_test.go b/agent/consul/acl_endpoint_test.go index 591d95f4e..e15cd0c6e 100644 --- a/agent/consul/acl_endpoint_test.go +++ b/agent/consul/acl_endpoint_test.go @@ -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"}`, diff --git a/agent/consul/acl_server.go b/agent/consul/acl_server.go index e59e9ede3..57c7a24e5 100644 --- a/agent/consul/acl_server.go +++ b/agent/consul/acl_server.go @@ -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 diff --git a/agent/consul/auto_config_endpoint.go b/agent/consul/auto_config_endpoint.go index b03c57493..82c13acbc 100644 --- a/agent/consul/auto_config_endpoint.go +++ b/agent/consul/auto_config_endpoint.go @@ -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) diff --git a/agent/consul/auto_config_endpoint_test.go b/agent/consul/auto_config_endpoint_test.go index d8e7049da..929bd9146 100644 --- a/agent/consul/auto_config_endpoint_test.go +++ b/agent/consul/auto_config_endpoint_test.go @@ -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 { diff --git a/agent/consul/config_endpoint.go b/agent/consul/config_endpoint.go index 6c8e0ff9a..e433e79e1 100644 --- a/agent/consul/config_endpoint.go +++ b/agent/consul/config_endpoint.go @@ -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 } } diff --git a/agent/consul/config_endpoint_test.go b/agent/consul/config_endpoint_test.go index f94660598..a5e92ad33 100644 --- a/agent/consul/config_endpoint_test.go +++ b/agent/consul/config_endpoint_test.go @@ -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", diff --git a/agent/consul/connect_ca_endpoint.go b/agent/consul/connect_ca_endpoint.go index 9110a5bd3..ab361f1a3 100644 --- a/agent/consul/connect_ca_endpoint.go +++ b/agent/consul/connect_ca_endpoint.go @@ -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 } diff --git a/agent/consul/coordinate_endpoint.go b/agent/consul/coordinate_endpoint.go index f276215df..eb999fbdc 100644 --- a/agent/consul/coordinate_endpoint.go +++ b/agent/consul/coordinate_endpoint.go @@ -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 } diff --git a/agent/consul/discoverychain/compile_oss.go b/agent/consul/discoverychain/compile_oss.go index b0ae3460e..51949daf2 100644 --- a/agent/consul/discoverychain/compile_oss.go +++ b/agent/consul/discoverychain/compile_oss.go @@ -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() } diff --git a/agent/consul/filter.go b/agent/consul/filter.go index 1466dabaa..f650059e9 100644 --- a/agent/consul/filter.go +++ b/agent/consul/filter.go @@ -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) diff --git a/agent/consul/fsm/commands_oss_test.go b/agent/consul/fsm/commands_oss_test.go index fb6fc1ef1..4b6855835 100644 --- a/agent/consul/fsm/commands_oss_test.go +++ b/agent/consul/fsm/commands_oss_test.go @@ -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"] diff --git a/agent/consul/fsm/snapshot_oss_test.go b/agent/consul/fsm/snapshot_oss_test.go index 667696407..2f3171558 100644 --- a/agent/consul/fsm/snapshot_oss_test.go +++ b/agent/consul/fsm/snapshot_oss_test.go @@ -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) diff --git a/agent/consul/intention_endpoint_test.go b/agent/consul/intention_endpoint_test.go index 669ae1d65..1af81751c 100644 --- a/agent/consul/intention_endpoint_test.go +++ b/agent/consul/intention_endpoint_test.go @@ -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 { diff --git a/agent/consul/internal_endpoint_test.go b/agent/consul/internal_endpoint_test.go index f8baf083a..a3f389fcd 100644 --- a/agent/consul/internal_endpoint_test.go +++ b/agent/consul/internal_endpoint_test.go @@ -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) }) diff --git a/agent/consul/leader.go b/agent/consul/leader.go index 7a7967b31..00ba77ebb 100644 --- a/agent/consul/leader.go +++ b/agent/consul/leader.go @@ -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 } diff --git a/agent/consul/leader_connect_ca.go b/agent/consul/leader_connect_ca.go index 51d157a61..aa17bf646 100644 --- a/agent/consul/leader_connect_ca.go +++ b/agent/consul/leader_connect_ca.go @@ -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() diff --git a/agent/consul/leader_federation_state_ae.go b/agent/consul/leader_federation_state_ae.go index e28374421..c4d8dc126 100644 --- a/agent/consul/leader_federation_state_ae.go +++ b/agent/consul/leader_federation_state_ae.go @@ -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 diff --git a/agent/consul/leader_intentions.go b/agent/consul/leader_intentions.go index 24afc5e09..3c07de63d 100644 --- a/agent/consul/leader_intentions.go +++ b/agent/consul/leader_intentions.go @@ -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 } diff --git a/agent/consul/leader_intentions_test.go b/agent/consul/leader_intentions_test.go index 02a24cf7f..2447cf08e 100644 --- a/agent/consul/leader_intentions_test.go +++ b/agent/consul/leader_intentions_test.go @@ -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) diff --git a/agent/consul/leader_test.go b/agent/consul/leader_test.go index 08466c840..134ca0e53 100644 --- a/agent/consul/leader_test.go +++ b/agent/consul/leader_test.go @@ -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) { diff --git a/agent/consul/prepared_query/walk_test.go b/agent/consul/prepared_query/walk_test.go index de7916af8..2c6920afd 100644 --- a/agent/consul/prepared_query/walk_test.go +++ b/agent/consul/prepared_query/walk_test.go @@ -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) diff --git a/agent/consul/server_test.go b/agent/consul/server_test.go index 398310f12..de7221f86 100644 --- a/agent/consul/server_test.go +++ b/agent/consul/server_test.go @@ -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) diff --git a/agent/consul/session_ttl.go b/agent/consul/session_ttl.go index 27f7d79d4..497fc7b54 100644 --- a/agent/consul/session_ttl.go +++ b/agent/consul/session_ttl.go @@ -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 } diff --git a/agent/consul/state/acl.go b/agent/consul/state/acl.go index 3fe8a98ca..1914ef52b 100644 --- a/agent/consul/state/acl.go +++ b/agent/consul/state/acl.go @@ -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 != "" { diff --git a/agent/consul/state/acl_test.go b/agent/consul/state/acl_test.go index 71d7cdd21..0efbf4a06 100644 --- a/agent/consul/state/acl_test.go +++ b/agent/consul/state/acl_test.go @@ -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{ diff --git a/agent/consul/state/catalog.go b/agent/consul/state/catalog.go index 249c9df27..a518d6239 100644 --- a/agent/consul/state/catalog.go +++ b/agent/consul/state/catalog.go @@ -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) diff --git a/agent/consul/state/catalog_events.go b/agent/consul/state/catalog_events.go index 038f8ea15..97be4638b 100644 --- a/agent/consul/state/catalog_events.go +++ b/agent/consul/state/catalog_events.go @@ -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 diff --git a/agent/consul/state/catalog_events_test.go b/agent/consul/state/catalog_events_test.go index 2d901388f..0e267315c 100644 --- a/agent/consul/state/catalog_events_test.go +++ b/agent/consul/state/catalog_events_test.go @@ -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, diff --git a/agent/consul/state/catalog_test.go b/agent/consul/state/catalog_test.go index 514caadcc..09472c84f 100644 --- a/agent/consul/state/catalog_test.go +++ b/agent/consul/state/catalog_test.go @@ -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) diff --git a/agent/consul/state/config_entry.go b/agent/consul/state/config_entry.go index 15faeaad1..287773d9a 100644 --- a/agent/consul/state/config_entry.go +++ b/agent/consul/state/config_entry.go @@ -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 diff --git a/agent/consul/state/config_entry_intention.go b/agent/consul/state/config_entry_intention.go index 98fcecbfa..c509ac38a 100644 --- a/agent/consul/state/config_entry_intention.go +++ b/agent/consul/state/config_entry_intention.go @@ -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) } diff --git a/agent/consul/state/config_entry_test.go b/agent/consul/state/config_entry_test.go index fa63e5199..8b1627f8f 100644 --- a/agent/consul/state/config_entry_test.go +++ b/agent/consul/state/config_entry_test.go @@ -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 diff --git a/agent/consul/state/intention.go b/agent/consul/state/intention.go index 2c0b1e0a5..2f0eca61d 100644 --- a/agent/consul/state/intention.go +++ b/agent/consul/state/intention.go @@ -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) } diff --git a/agent/consul/state/intention_test.go b/agent/consul/state/intention_test.go index ffd5c9674..5c24725c9 100644 --- a/agent/consul/state/intention_test.go +++ b/agent/consul/state/intention_test.go @@ -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) diff --git a/agent/consul/state/txn_test.go b/agent/consul/state/txn_test.go index 9bc0fed20..5352d05d5 100644 --- a/agent/consul/state/txn_test.go +++ b/agent/consul/state/txn_test.go @@ -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) diff --git a/agent/consul/txn_endpoint_test.go b/agent/consul/txn_endpoint_test.go index d9ba987b6..291532067 100644 --- a/agent/consul/txn_endpoint_test.go +++ b/agent/consul/txn_endpoint_test.go @@ -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) diff --git a/agent/dns.go b/agent/dns.go index 992a0e467..8224b2730 100644 --- a/agent/dns.go +++ b/agent/dns.go @@ -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) diff --git a/agent/local/state.go b/agent/local/state.go index 5b9d0cc7f..5908c4af2 100644 --- a/agent/local/state.go +++ b/agent/local/state.go @@ -887,7 +887,7 @@ func (l *State) updateSyncState() error { AllowStale: true, MaxStaleDuration: fullSyncReadMaxStale, }, - EnterpriseMeta: *structs.WildcardEnterpriseMeta(), + EnterpriseMeta: *structs.WildcardEnterpriseMetaInDefaultPartition(), } var out1 structs.IndexedNodeServiceList diff --git a/agent/local/state_test.go b/agent/local/state_test.go index f5829f1fc..bcc0e1102 100644 --- a/agent/local/state_test.go +++ b/agent/local/state_test.go @@ -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"}, diff --git a/agent/proxycfg/connect_proxy.go b/agent/proxycfg/connect_proxy.go index 1c00fd7fa..2a2e1e684 100644 --- a/agent/proxycfg/connect_proxy.go +++ b/agent/proxycfg/connect_proxy.go @@ -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 diff --git a/agent/proxycfg/manager.go b/agent/proxycfg/manager.go index e6aa080c6..922e73ed5 100644 --- a/agent/proxycfg/manager.go +++ b/agent/proxycfg/manager.go @@ -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 && diff --git a/agent/proxycfg/manager_test.go b/agent/proxycfg/manager_test.go index 268bf3ee7..658bad43b 100644 --- a/agent/proxycfg/manager_test.go +++ b/agent/proxycfg/manager_test.go @@ -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) diff --git a/agent/proxycfg/mesh_gateway.go b/agent/proxycfg/mesh_gateway.go index 4aa54a7f5..7a402441b 100644 --- a/agent/proxycfg/mesh_gateway.go +++ b/agent/proxycfg/mesh_gateway.go @@ -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 { diff --git a/agent/proxycfg/state_test.go b/agent/proxycfg/state_test.go index 9bb4895fa..45e4040fb 100644 --- a/agent/proxycfg/state_test.go +++ b/agent/proxycfg/state_test.go @@ -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())) }, diff --git a/agent/proxycfg/upstreams.go b/agent/proxycfg/upstreams.go index f634cf0a7..ff0f1f2cd 100644 --- a/agent/proxycfg/upstreams.go +++ b/agent/proxycfg/upstreams.go @@ -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) } diff --git a/agent/rpc/subscribe/subscribe.go b/agent/rpc/subscribe/subscribe.go index 71bede729..acd434486 100644 --- a/agent/rpc/subscribe/subscribe.go +++ b/agent/rpc/subscribe/subscribe.go @@ -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 diff --git a/agent/rpcclient/health/view_test.go b/agent/rpcclient/health/view_test.go index beba03d88..841669858 100644 --- a/agent/rpcclient/health/view_test.go +++ b/agent/rpcclient/health/view_test.go @@ -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() } diff --git a/agent/service_manager_test.go b/agent/service_manager_test.go index 8ab54bc5b..14ead2a8a 100644 --- a/agent/service_manager_test.go +++ b/agent/service_manager_test.go @@ -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{}{ diff --git a/agent/sidecar_service.go b/agent/sidecar_service.go index 1217d3033..aa9b897c7 100644 --- a/agent/sidecar_service.go +++ b/agent/sidecar_service.go @@ -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 { diff --git a/agent/sidecar_service_test.go b/agent/sidecar_service_test.go index 0840d8044..6b17599da 100644 --- a/agent/sidecar_service_test.go +++ b/agent/sidecar_service_test.go @@ -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", diff --git a/agent/structs/acl.go b/agent/structs/acl.go index aba9a1688..056d7e718 100644 --- a/agent/structs/acl.go +++ b/agent/structs/acl.go @@ -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 } diff --git a/agent/structs/acl_oss.go b/agent/structs/acl_oss.go index 0a43ee0b4..9681488ab 100644 --- a/agent/structs/acl_oss.go +++ b/agent/structs/acl_oss.go @@ -55,7 +55,7 @@ func (_ *ACLAuthMethodEnterpriseMeta) FillWithEnterpriseMeta(_ *EnterpriseMeta) } func (_ *ACLAuthMethodEnterpriseMeta) ToEnterpriseMeta() *EnterpriseMeta { - return DefaultEnterpriseMeta() + return DefaultEnterpriseMetaInDefaultPartition() } func aclServiceIdentityRules(svc string, _ *EnterpriseMeta) string { diff --git a/agent/structs/config_entry_discoverychain_oss.go b/agent/structs/config_entry_discoverychain_oss.go index a325c3d34..17f8b8473 100644 --- a/agent/structs/config_entry_discoverychain_oss.go +++ b/agent/structs/config_entry_discoverychain_oss.go @@ -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 diff --git a/agent/structs/config_entry_gateways_test.go b/agent/structs/config_entry_gateways_test.go index 3d5f66246..d69e1387f 100644 --- a/agent/structs/config_entry_gateways_test.go +++ b/agent/structs/config_entry_gateways_test.go @@ -7,7 +7,7 @@ import ( ) func TestIngressGatewayConfigEntry(t *testing.T) { - defaultMeta := DefaultEnterpriseMeta() + defaultMeta := DefaultEnterpriseMetaInDefaultPartition() cases := map[string]configEntryTestcase{ "normalize: empty protocol": { diff --git a/agent/structs/config_entry_intentions_test.go b/agent/structs/config_entry_intentions_test.go index 652f80c31..68e54dcb8 100644 --- a/agent/structs/config_entry_intentions_test.go +++ b/agent/structs/config_entry_intentions_test.go @@ -45,7 +45,7 @@ func TestServiceIntentionsConfigEntry(t *testing.T) { generateUUID(), } - defaultMeta := DefaultEnterpriseMeta() + defaultMeta := DefaultEnterpriseMetaInDefaultPartition() fooName := NewServiceName("foo", defaultMeta) diff --git a/agent/structs/config_entry_test.go b/agent/structs/config_entry_test.go index cf38bb2fa..d76fc3b23 100644 --- a/agent/structs/config_entry_test.go +++ b/agent/structs/config_entry_test.go @@ -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(), }, }, } diff --git a/agent/structs/connect_proxy_config_oss.go b/agent/structs/connect_proxy_config_oss.go index 9ce5e2679..d930420fa 100644 --- a/agent/structs/connect_proxy_config_oss.go +++ b/agent/structs/connect_proxy_config_oss.go @@ -3,7 +3,7 @@ package structs func (us *Upstream) GetEnterpriseMeta() *EnterpriseMeta { - return DefaultEnterpriseMeta() + return DefaultEnterpriseMetaInDefaultPartition() } func (us *Upstream) DestinationID() ServiceID { diff --git a/agent/structs/discovery_chain.go b/agent/structs/discovery_chain.go index ded0e1726..b79e74fa5 100644 --- a/agent/structs/discovery_chain.go +++ b/agent/structs/discovery_chain.go @@ -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) } diff --git a/agent/structs/discovery_chain_oss.go b/agent/structs/discovery_chain_oss.go index dbee83be4..f8c44ac99 100644 --- a/agent/structs/discovery_chain_oss.go +++ b/agent/structs/discovery_chain_oss.go @@ -3,5 +3,5 @@ package structs func (t *DiscoveryTarget) GetEnterpriseMetadata() *EnterpriseMeta { - return DefaultEnterpriseMeta() + return DefaultEnterpriseMetaInDefaultPartition() } diff --git a/agent/structs/intention_oss.go b/agent/structs/intention_oss.go index 91421a632..7f2f45b98 100644 --- a/agent/structs/intention_oss.go +++ b/agent/structs/intention_oss.go @@ -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 diff --git a/agent/structs/intention_test.go b/agent/structs/intention_test.go index 7e94db352..5b321cc51 100644 --- a/agent/structs/intention_test.go +++ b/agent/structs/intention_test.go @@ -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) { diff --git a/agent/structs/structs.go b/agent/structs/structs.go index a0d3e1033..3d59ac83f 100644 --- a/agent/structs/structs.go +++ b/agent/structs/structs.go @@ -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 diff --git a/agent/structs/structs_oss.go b/agent/structs/structs_oss.go index 2aeb01674..0d298d68b 100644 --- a/agent/structs/structs_oss.go +++ b/agent/structs/structs_oss.go @@ -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 { diff --git a/agent/txn_endpoint.go b/agent/txn_endpoint.go index d01b23bac..42c2251c6 100644 --- a/agent/txn_endpoint.go +++ b/agent/txn_endpoint.go @@ -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, }, diff --git a/agent/txn_endpoint_test.go b/agent/txn_endpoint_test.go index d22e080e7..b3770fb16 100644 --- a/agent/txn_endpoint_test.go +++ b/agent/txn_endpoint_test.go @@ -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(), }, }, }, diff --git a/agent/ui_endpoint.go b/agent/ui_endpoint.go index f623770a7..7660177d5 100644 --- a/agent/ui_endpoint.go +++ b/agent/ui_endpoint.go @@ -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) diff --git a/agent/ui_endpoint_test.go b/agent/ui_endpoint_test.go index 519770841..b9ef3f0ac 100644 --- a/agent/ui_endpoint_test.go +++ b/agent/ui_endpoint_test.go @@ -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, diff --git a/agent/user_event.go b/agent/user_event.go index 32e5876d6..d3b6224b0 100644 --- a/agent/user_event.go +++ b/agent/user_event.go @@ -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 { diff --git a/agent/xds/listeners_test.go b/agent/xds/listeners_test.go index ab4aafb41..30a98145a 100644 --- a/agent/xds/listeners_test.go +++ b/agent/xds/listeners_test.go @@ -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. diff --git a/agent/xds/server_oss.go b/agent/xds/server_oss.go index 0724351c3..ef5adcec1 100644 --- a/agent/xds/server_oss.go +++ b/agent/xds/server_oss.go @@ -9,5 +9,5 @@ import ( ) func parseEnterpriseMeta(node *envoy_core_v3.Node) *structs.EnterpriseMeta { - return structs.DefaultEnterpriseMeta() + return structs.DefaultEnterpriseMetaInDefaultPartition() }