Skip to content

Commit

Permalink
Merge branch 'main' into consul-er-ecs-update
Browse files Browse the repository at this point in the history
  • Loading branch information
eddie-rowe authored Aug 9, 2023
2 parents 0f355b0 + facd5b0 commit 009b38a
Show file tree
Hide file tree
Showing 12 changed files with 996 additions and 7 deletions.
8 changes: 6 additions & 2 deletions agent/agent_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,9 @@ func TestHTTPHandlers_AgentMetricsStream_ACLDeny(t *testing.T) {
bd.MetricsConfig = &lib.MetricsConfig{
Handler: sink,
}
d := fakeResolveTokenDelegate{delegate: &delegateMock{}, authorizer: acl.DenyAll()}
mockDelegate := delegateMock{}
mockDelegate.On("LicenseCheck").Return()
d := fakeResolveTokenDelegate{delegate: &mockDelegate, authorizer: acl.DenyAll()}
agent := &Agent{
baseDeps: bd,
delegate: d,
Expand Down Expand Up @@ -1658,7 +1660,9 @@ func TestHTTPHandlers_AgentMetricsStream(t *testing.T) {
bd.MetricsConfig = &lib.MetricsConfig{
Handler: sink,
}
d := fakeResolveTokenDelegate{delegate: &delegateMock{}, authorizer: acl.ManageAll()}
mockDelegate := delegateMock{}
mockDelegate.On("LicenseCheck").Return()
d := fakeResolveTokenDelegate{delegate: &mockDelegate, authorizer: acl.ManageAll()}
agent := &Agent{
baseDeps: bd,
delegate: d,
Expand Down
20 changes: 15 additions & 5 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ func TestAgent_HTTPMaxHeaderBytes(t *testing.T) {
require.NoError(t, err)

a, err := New(bd)
a.delegate = &delegateMock{}
mockDelegate := delegateMock{}
mockDelegate.On("LicenseCheck").Return()
a.delegate = &mockDelegate
require.NoError(t, err)

a.startLicenseManager(testutil.TestContext(t))
Expand Down Expand Up @@ -5503,7 +5505,9 @@ func TestAgent_ListenHTTP_MultipleAddresses(t *testing.T) {
require.NoError(t, err)

agent, err := New(bd)
agent.delegate = &delegateMock{}
mockDelegate := delegateMock{}
mockDelegate.On("LicenseCheck").Return()
agent.delegate = &mockDelegate
require.NoError(t, err)

agent.startLicenseManager(testutil.TestContext(t))
Expand Down Expand Up @@ -6097,7 +6101,9 @@ func TestAgent_startListeners(t *testing.T) {
require.NoError(t, err)

agent, err := New(bd)
agent.delegate = &delegateMock{}
mockDelegate := delegateMock{}
mockDelegate.On("LicenseCheck").Return()
agent.delegate = &mockDelegate
require.NoError(t, err)

// use up an address
Expand Down Expand Up @@ -6238,7 +6244,9 @@ func TestAgent_startListeners_scada(t *testing.T) {
require.NoError(t, err)

agent, err := New(bd)
agent.delegate = &delegateMock{}
mockDelegate := delegateMock{}
mockDelegate.On("LicenseCheck").Return()
agent.delegate = &mockDelegate
require.NoError(t, err)

_, err = agent.startListeners([]net.Addr{c})
Expand Down Expand Up @@ -6294,7 +6302,9 @@ func TestAgent_checkServerLastSeen(t *testing.T) {
Config: leafcert.Config{},
})
agent, err := New(bd)
agent.delegate = &delegateMock{}
mockDelegate := delegateMock{}
mockDelegate.On("LicenseCheck").Return()
agent.delegate = &mockDelegate
require.NoError(t, err)

// Test that an ErrNotExist OS error is treated as ok.
Expand Down
25 changes: 25 additions & 0 deletions internal/catalog/exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ package catalog
import (
"github.com/hashicorp/consul/internal/catalog/internal/controllers"
"github.com/hashicorp/consul/internal/catalog/internal/controllers/endpoints"
"github.com/hashicorp/consul/internal/catalog/internal/controllers/failover"
"github.com/hashicorp/consul/internal/catalog/internal/controllers/nodehealth"
"github.com/hashicorp/consul/internal/catalog/internal/controllers/workloadhealth"
"github.com/hashicorp/consul/internal/catalog/internal/mappers/failovermapper"
"github.com/hashicorp/consul/internal/catalog/internal/mappers/nodemapper"
"github.com/hashicorp/consul/internal/catalog/internal/mappers/selectiontracker"
"github.com/hashicorp/consul/internal/catalog/internal/types"
"github.com/hashicorp/consul/internal/controller"
"github.com/hashicorp/consul/internal/resource"
pbcatalog "github.com/hashicorp/consul/proto-public/pbcatalog/v1alpha1"
"github.com/hashicorp/consul/proto-public/pbresource"
)

var (
Expand Down Expand Up @@ -73,6 +76,15 @@ var (
EndpointsStatusConditionEndpointsManaged = endpoints.StatusConditionEndpointsManaged
EndpointsStatusConditionManaged = endpoints.ConditionManaged
EndpointsStatusConditionUnmanaged = endpoints.ConditionUnmanaged

FailoverStatusKey = failover.StatusKey
FailoverStatusConditionAccepted = failover.StatusConditionAccepted
FailoverStatusConditionAcceptedOKReason = failover.OKReason
FailoverStatusConditionAcceptedMissingServiceReason = failover.MissingServiceReason
FailoverStatusConditionAcceptedUnknownPortReason = failover.UnknownPortReason
FailoverStatusConditionAcceptedMissingDestinationServiceReason = failover.MissingDestinationServiceReason
FailoverStatusConditionAcceptedUnknownDestinationPortReason = failover.UnknownDestinationPortReason
FailoverStatusConditionAcceptedUsingMeshDestinationPortReason = failover.UsingMeshDestinationPortReason
)

// RegisterTypes adds all resource types within the "catalog" API group
Expand All @@ -87,6 +99,7 @@ func DefaultControllerDependencies() ControllerDependencies {
return ControllerDependencies{
WorkloadHealthNodeMapper: nodemapper.New(),
EndpointsWorkloadMapper: selectiontracker.New(),
FailoverMapper: failovermapper.New(),
}
}

Expand All @@ -101,3 +114,15 @@ func RegisterControllers(mgr *controller.Manager, deps ControllerDependencies) {
func SimplifyFailoverPolicy(svc *pbcatalog.Service, failover *pbcatalog.FailoverPolicy) *pbcatalog.FailoverPolicy {
return types.SimplifyFailoverPolicy(svc, failover)
}

// FailoverPolicyMapper maintains the bidirectional tracking relationship of a
// FailoverPolicy to the Services related to it.
type FailoverPolicyMapper interface {
TrackFailover(failover *resource.DecodedResource[pbcatalog.FailoverPolicy, *pbcatalog.FailoverPolicy])
UntrackFailover(failoverID *pbresource.ID)
FailoverIDsByService(svcID *pbresource.ID) []*pbresource.ID
}

func NewFailoverPolicyMapper() FailoverPolicyMapper {
return failovermapper.New()
}
Loading

0 comments on commit 009b38a

Please sign in to comment.