From 4b8b2a4291e894658d520dabda87336b386ac095 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 23 Dec 2020 13:08:23 -0500 Subject: [PATCH] xds: remove Server.Initialize Requiring a call to initialize to set a single field is not really substantially different from having to set that field to a value. --- agent/agent.go | 12 ++++++------ agent/xds/server.go | 7 ------- agent/xds/server_test.go | 5 ----- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 9d98d02768..79ec38fadf 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -650,13 +650,13 @@ func (a *Agent) listenAndServeGRPC() error { } xdsServer := &xds.Server{ - Logger: a.logger.Named(logging.Envoy), - CfgMgr: a.proxyConfig, - ResolveToken: a.resolveToken, - CheckFetcher: a, - CfgFetcher: a, + Logger: a.logger.Named(logging.Envoy), + CfgMgr: a.proxyConfig, + ResolveToken: a.resolveToken, + CheckFetcher: a, + CfgFetcher: a, + AuthCheckFrequency: xds.DefaultAuthCheckFrequency, } - xdsServer.Initialize() var err error if a.config.HTTPSPort > 0 { diff --git a/agent/xds/server.go b/agent/xds/server.go index e07595bdbd..d8a7ecbe51 100644 --- a/agent/xds/server.go +++ b/agent/xds/server.go @@ -125,13 +125,6 @@ type Server struct { CfgFetcher ConfigFetcher } -// Initialize will finish configuring the Server for first use. -func (s *Server) Initialize() { - if s.AuthCheckFrequency == 0 { - s.AuthCheckFrequency = DefaultAuthCheckFrequency - } -} - // StreamAggregatedResources implements // envoydisco.AggregatedDiscoveryServiceServer. This is the ADS endpoint which is // the only xDS API we directly support for now. diff --git a/agent/xds/server_test.go b/agent/xds/server_test.go index f619628079..3d714e2d4e 100644 --- a/agent/xds/server_test.go +++ b/agent/xds/server_test.go @@ -102,7 +102,6 @@ func TestServer_StreamAggregatedResources_BasicProtocol(t *testing.T) { CfgMgr: mgr, ResolveToken: aclResolve, } - s.Initialize() sid := structs.NewServiceID("web-sidecar-proxy", nil) @@ -454,7 +453,6 @@ func TestServer_StreamAggregatedResources_ACLEnforcement(t *testing.T) { CfgMgr: mgr, ResolveToken: aclResolve, } - s.Initialize() errCh := make(chan error, 1) go func() { @@ -528,7 +526,6 @@ func TestServer_StreamAggregatedResources_ACLTokenDeleted_StreamTerminatedDuring ResolveToken: aclResolve, AuthCheckFrequency: 1 * time.Hour, // make sure this doesn't kick in } - s.Initialize() errCh := make(chan error, 1) go func() { @@ -622,7 +619,6 @@ func TestServer_StreamAggregatedResources_ACLTokenDeleted_StreamTerminatedInBack ResolveToken: aclResolve, AuthCheckFrequency: 100 * time.Millisecond, // Make this short. } - s.Initialize() errCh := make(chan error, 1) go func() { @@ -707,7 +703,6 @@ func TestServer_StreamAggregatedResources_IngressEmptyResponse(t *testing.T) { CfgMgr: mgr, ResolveToken: aclResolve, } - s.Initialize() sid := structs.NewServiceID("ingress-gateway", nil)