Run config entry controller routines on leader (#16054)

This commit is contained in:
Nathan Coleman 2023-01-25 13:21:46 -05:00 committed by GitHub
parent 8661b6844f
commit 3e5e03aa95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

View File

@ -5,11 +5,15 @@ import (
"fmt"
"time"
"golang.org/x/sync/errgroup"
"golang.org/x/time/rate"
"github.com/hashicorp/go-version"
"github.com/hashicorp/consul/agent/consul/gateways"
"github.com/hashicorp/consul/agent/structs"
"github.com/hashicorp/consul/logging"
"github.com/hashicorp/go-version"
)
const (
@ -51,6 +55,7 @@ func (s *Server) startConnectLeader(ctx context.Context) error {
s.leaderRoutineManager.Start(ctx, caRootMetricRoutineName, rootCAExpiryMonitor(s).Monitor)
s.leaderRoutineManager.Start(ctx, caSigningMetricRoutineName, signingCAExpiryMonitor(s).Monitor)
s.leaderRoutineManager.Start(ctx, virtualIPCheckRoutineName, s.runVirtualIPVersionCheck)
s.leaderRoutineManager.Start(ctx, configEntryControllersRoutineName, s.runConfigEntryControllers)
return s.startIntentionConfigEntryMigration(ctx)
}
@ -63,6 +68,28 @@ func (s *Server) stopConnectLeader() {
s.leaderRoutineManager.Stop(caRootMetricRoutineName)
s.leaderRoutineManager.Stop(caSigningMetricRoutineName)
s.leaderRoutineManager.Stop(virtualIPCheckRoutineName)
s.leaderRoutineManager.Stop(configEntryControllersRoutineName)
}
func (s *Server) runConfigEntryControllers(ctx context.Context) error {
group, ctx := errgroup.WithContext(ctx)
group.Go(func() error {
logger := s.logger.Named(logging.APIGatewayController)
return gateways.NewAPIGatewayController(s.fsm, s.publisher, logger).Run(ctx)
})
group.Go(func() error {
logger := s.logger.Named(logging.HTTPRouteController)
return gateways.NewHTTPRouteController(s.fsm, s.publisher, logger).Run(ctx)
})
group.Go(func() error {
logger := s.logger.Named(logging.TCPRouteController)
return gateways.NewTCPRouteController(s.fsm, s.publisher, logger).Run(ctx)
})
return group.Wait()
}
func (s *Server) runCARootPruning(ctx context.Context) error {

View File

@ -122,6 +122,7 @@ const (
caRootPruningRoutineName = "CA root pruning"
caRootMetricRoutineName = "CA root expiration metric"
caSigningMetricRoutineName = "CA signing expiration metric"
configEntryControllersRoutineName = "config entry controllers"
configReplicationRoutineName = "config entry replication"
federationStateReplicationRoutineName = "federation state replication"
federationStateAntiEntropyRoutineName = "federation state anti-entropy"

View File

@ -22,8 +22,10 @@ const (
Envoy string = "envoy"
FederationState string = "federation_state"
FSM string = "fsm"
APIGatewayController string = "api_gateway_controller"
GatewayLocator string = "gateway_locator"
HTTP string = "http"
HTTPRouteController string = "http_route_controller"
IngressGateway string = "ingress_gateway"
Intentions string = "intentions"
Internal string = "internal"
@ -52,6 +54,7 @@ const (
Partition string = "partition"
Peering string = "peering"
PeeringMetrics string = "peering_metrics"
TCPRouteController string = "tcp_route_controller"
TerminatingGateway string = "terminating_gateway"
TLSUtil string = "tlsutil"
Transaction string = "txn"