From f510c2c9facddb9f4d408f3627847bc873a41c1c Mon Sep 17 00:00:00 2001 From: Tim Ross Date: Fri, 10 Jan 2025 08:38:56 -0500 Subject: [PATCH] Remove unused servicecfg.Config.Console field Depends on https://github.com/gravitational/teleport.e/pull/5829 --- e2e/aws/fixtures_test.go | 1 - integration/appaccess/fixtures.go | 2 -- integration/appaccess/pack.go | 2 -- integration/helpers/instance.go | 4 +--- integration/hostuser_test.go | 4 ++-- integration/integration_test.go | 23 +++++++++-------------- integration/kube_integration_test.go | 2 -- integration/port_forwarding_test.go | 1 - integration/proxy/proxy_helpers.go | 1 - lib/client/api_login_test.go | 4 ---- lib/config/configuration.go | 6 ------ lib/service/servicecfg/config.go | 9 --------- tool/teleport/common/teleport_test.go | 1 - 13 files changed, 12 insertions(+), 48 deletions(-) diff --git a/e2e/aws/fixtures_test.go b/e2e/aws/fixtures_test.go index 1b30f64f382a5..95373466c237e 100644 --- a/e2e/aws/fixtures_test.go +++ b/e2e/aws/fixtures_test.go @@ -198,7 +198,6 @@ func newTeleportConfig(t *testing.T) *servicecfg.Config { tconf := servicecfg.MakeDefaultConfig() // Replace the default auth and proxy listeners with the ones so we can // run multiple tests in parallel. - tconf.Console = nil tconf.Proxy.DisableWebInterface = true tconf.PollingPeriod = 500 * time.Millisecond tconf.Testing.ClientTimeout = time.Second diff --git a/integration/appaccess/fixtures.go b/integration/appaccess/fixtures.go index eee6390c471f5..e6876e7cbdaec 100644 --- a/integration/appaccess/fixtures.go +++ b/integration/appaccess/fixtures.go @@ -346,7 +346,6 @@ func SetupWithOptions(t *testing.T, opts AppTestOptions) *Pack { p.leafCluster = helpers.NewInstance(t, leafCfg) rcConf := servicecfg.MakeDefaultConfig() - rcConf.Console = nil rcConf.Logger = log rcConf.DataDir = t.TempDir() rcConf.Auth.Enabled = true @@ -364,7 +363,6 @@ func SetupWithOptions(t *testing.T, opts AppTestOptions) *Pack { rcConf.Clock = opts.Clock lcConf := servicecfg.MakeDefaultConfig() - lcConf.Console = nil lcConf.Logger = log lcConf.DataDir = t.TempDir() lcConf.Auth.Enabled = true diff --git a/integration/appaccess/pack.go b/integration/appaccess/pack.go index 5deabac208c4c..fc753887e2ceb 100644 --- a/integration/appaccess/pack.go +++ b/integration/appaccess/pack.go @@ -703,7 +703,6 @@ func (p *Pack) startRootAppServers(t *testing.T, count int, opts AppTestOptions) for i := 0; i < count; i++ { raConf := servicecfg.MakeDefaultConfig() raConf.Clock = opts.Clock - raConf.Console = nil raConf.Logger = utils.NewSlogLoggerForTests() raConf.DataDir = t.TempDir() raConf.SetToken("static-token-value") @@ -873,7 +872,6 @@ func (p *Pack) startLeafAppServers(t *testing.T, count int, opts AppTestOptions) for i := 0; i < count; i++ { laConf := servicecfg.MakeDefaultConfig() laConf.Clock = opts.Clock - laConf.Console = nil laConf.Logger = utils.NewSlogLoggerForTests() laConf.DataDir = t.TempDir() laConf.SetToken("static-token-value") diff --git a/integration/helpers/instance.go b/integration/helpers/instance.go index 6d375387a02f6..7e7deb03567a8 100644 --- a/integration/helpers/instance.go +++ b/integration/helpers/instance.go @@ -447,10 +447,9 @@ func (i *TeleInstance) GetSiteAPI(siteName string) authclient.ClientI { // Create creates a new instance of Teleport which trusts a list of other clusters (other // instances) -func (i *TeleInstance) Create(t *testing.T, trustedSecrets []*InstanceSecrets, enableSSH bool, console io.Writer) error { +func (i *TeleInstance) Create(t *testing.T, trustedSecrets []*InstanceSecrets, enableSSH bool) error { tconf := servicecfg.MakeDefaultConfig() tconf.SSH.Enabled = enableSSH - tconf.Console = console tconf.Logger = i.Log tconf.Proxy.DisableWebService = true tconf.Proxy.DisableWebInterface = true @@ -1129,7 +1128,6 @@ func (i *TeleInstance) StartProxy(cfg ProxyConfig, opts ...Option) (reversetunne i.tempDirs = append(i.tempDirs, dataDir) tconf := servicecfg.MakeDefaultConfig() - tconf.Console = nil tconf.Logger = i.Log authServer := utils.MustParseAddr(i.Auth) tconf.SetAuthServerAddress(*authServer) diff --git a/integration/hostuser_test.go b/integration/hostuser_test.go index 02145bc38274e..540ae35a59c48 100644 --- a/integration/hostuser_test.go +++ b/integration/hostuser_test.go @@ -661,7 +661,7 @@ func TestRootLoginAsHostUser(t *testing.T) { Roles: []types.Role{role}, } - require.NoError(t, instance.Create(t, nil, true, nil)) + require.NoError(t, instance.Create(t, nil, true)) require.NoError(t, instance.Start()) t.Cleanup(func() { require.NoError(t, instance.StopAll()) @@ -740,7 +740,7 @@ func TestRootStaticHostUsers(t *testing.T) { Logger: utils.NewSlogLoggerForTests(), }) - require.NoError(t, instance.Create(t, nil, false, nil)) + require.NoError(t, instance.Create(t, nil, false)) require.NoError(t, instance.Start()) t.Cleanup(func() { require.NoError(t, instance.StopAll()) diff --git a/integration/integration_test.go b/integration/integration_test.go index 0b48c90b46f39..4e2c4bed4974e 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -711,7 +711,7 @@ func (s *integrationTestSuite) newUnstartedTeleport(t *testing.T, logins []strin for _, login := range logins { teleport.AddUser(login, []string{login}) } - require.NoError(t, teleport.Create(t, nil, enableSSH, nil)) + require.NoError(t, teleport.Create(t, nil, enableSSH)) return teleport } @@ -2564,9 +2564,9 @@ func testTwoClustersProxy(t *testing.T, suite *integrationTestSuite) { a.AddUser(username, []string{username}) b.AddUser(username, []string{username}) - require.NoError(t, b.Create(t, a.Secrets.AsSlice(), false, nil)) + require.NoError(t, b.Create(t, a.Secrets.AsSlice(), false)) defer b.StopAll() - require.NoError(t, a.Create(t, b.Secrets.AsSlice(), true, nil)) + require.NoError(t, a.Create(t, b.Secrets.AsSlice(), true)) defer a.StopAll() require.NoError(t, b.Start()) @@ -2602,8 +2602,8 @@ func testHA(t *testing.T, suite *integrationTestSuite) { a.AddUser(username, []string{username}) b.AddUser(username, []string{username}) - require.NoError(t, b.Create(t, a.Secrets.AsSlice(), true, nil)) - require.NoError(t, a.Create(t, b.Secrets.AsSlice(), true, nil)) + require.NoError(t, b.Create(t, a.Secrets.AsSlice(), true)) + require.NoError(t, a.Create(t, b.Secrets.AsSlice(), true)) require.NoError(t, b.Start()) require.NoError(t, a.Start()) @@ -3950,13 +3950,13 @@ func testDiscoveryRecovers(t *testing.T, suite *integrationTestSuite) { remote.AddUser(username, []string{username}) main.AddUser(username, []string{username}) - require.NoError(t, main.Create(t, remote.Secrets.AsSlice(), false, nil)) + require.NoError(t, main.Create(t, remote.Secrets.AsSlice(), false)) mainSecrets := main.Secrets // switch listen address of the main cluster to load balancer mainProxyAddr := *utils.MustParseAddr(mainSecrets.TunnelAddr) lb.AddBackend(mainProxyAddr) mainSecrets.TunnelAddr = lb.Addr().String() - require.NoError(t, remote.Create(t, mainSecrets.AsSlice(), true, nil)) + require.NoError(t, remote.Create(t, mainSecrets.AsSlice(), true)) require.NoError(t, main.Start()) require.NoError(t, remote.Start()) @@ -4085,13 +4085,13 @@ func testDiscovery(t *testing.T, suite *integrationTestSuite) { remote.AddUser(username, []string{username}) main.AddUser(username, []string{username}) - require.NoError(t, main.Create(t, remote.Secrets.AsSlice(), false, nil)) + require.NoError(t, main.Create(t, remote.Secrets.AsSlice(), false)) mainSecrets := main.Secrets // switch listen address of the main cluster to load balancer mainProxyAddr := *utils.MustParseAddr(mainSecrets.TunnelAddr) lb.AddBackend(mainProxyAddr) mainSecrets.TunnelAddr = lb.Addr().String() - require.NoError(t, remote.Create(t, mainSecrets.AsSlice(), true, nil)) + require.NoError(t, remote.Create(t, mainSecrets.AsSlice(), true)) require.NoError(t, main.Start()) require.NoError(t, remote.Start()) @@ -7223,7 +7223,6 @@ func WithListeners(setupFn helpers.InstanceListenerSetupFunc) InstanceConfigOpti func (s *integrationTestSuite) defaultServiceConfig() *servicecfg.Config { cfg := servicecfg.MakeDefaultConfig() - cfg.Console = nil cfg.Logger = s.Log cfg.CircuitBreakerConfig = breaker.NoopBreakerConfig() cfg.InstanceMetadataClient = imds.NewDisabledIMDSClient() @@ -8572,7 +8571,6 @@ func TestConnectivityWithoutAuth(t *testing.T) { // Create auth config. authCfg := servicecfg.MakeDefaultConfig() - authCfg.Console = nil authCfg.Logger = utils.NewSlogLoggerForTests() authCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig() authCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient() @@ -8635,7 +8633,6 @@ func TestConnectivityWithoutAuth(t *testing.T) { nodeCfg.SetToken("token") nodeCfg.CachePolicy.Enabled = true nodeCfg.DataDir = t.TempDir() - nodeCfg.Console = nil nodeCfg.Logger = utils.NewSlogLoggerForTests() nodeCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig() nodeCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient() @@ -8716,7 +8713,6 @@ func TestConnectivityDuringAuthRestart(t *testing.T) { // Create auth config. authCfg := servicecfg.MakeDefaultConfig() - authCfg.Console = nil authCfg.Logger = utils.NewSlogLoggerForTests() authCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig() authCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient() @@ -8776,7 +8772,6 @@ func TestConnectivityDuringAuthRestart(t *testing.T) { nodeCfg.SetToken("token") nodeCfg.CachePolicy.Enabled = true nodeCfg.DataDir = t.TempDir() - nodeCfg.Console = nil nodeCfg.Logger = utils.NewSlogLoggerForTests() nodeCfg.CircuitBreakerConfig = breaker.NoopBreakerConfig() nodeCfg.InstanceMetadataClient = imds.NewDisabledIMDSClient() diff --git a/integration/kube_integration_test.go b/integration/kube_integration_test.go index 264bbfdf50706..51568d0e6bc7e 100644 --- a/integration/kube_integration_test.go +++ b/integration/kube_integration_test.go @@ -1833,7 +1833,6 @@ type sessionMetadataResponse struct { // teleKubeConfig sets up teleport with kubernetes turned on func (s *KubeSuite) teleKubeConfig(hostname string) *servicecfg.Config { tconf := servicecfg.MakeDefaultConfig() - tconf.Console = nil tconf.Logger = s.log tconf.SSH.Enabled = true tconf.Proxy.DisableWebInterface = true @@ -1854,7 +1853,6 @@ func (s *KubeSuite) teleKubeConfig(hostname string) *servicecfg.Config { // teleKubeConfig sets up teleport with kubernetes turned on func (s *KubeSuite) teleAuthConfig(hostname string) *servicecfg.Config { tconf := servicecfg.MakeDefaultConfig() - tconf.Console = nil tconf.Logger = s.log tconf.PollingPeriod = 500 * time.Millisecond tconf.Testing.ClientTimeout = time.Second diff --git a/integration/port_forwarding_test.go b/integration/port_forwarding_test.go index 88af150695872..cdef9e9b6f35a 100644 --- a/integration/port_forwarding_test.go +++ b/integration/port_forwarding_test.go @@ -205,7 +205,6 @@ func testPortForwarding(t *testing.T, suite *integrationTestSuite) { nodeCfg.SetToken("token") nodeCfg.CachePolicy.Enabled = true nodeCfg.DataDir = t.TempDir() - nodeCfg.Console = nil nodeCfg.Auth.Enabled = false nodeCfg.Proxy.Enabled = false nodeCfg.SSH.Enabled = true diff --git a/integration/proxy/proxy_helpers.go b/integration/proxy/proxy_helpers.go index 789ab0f4f577f..8617fa10a38ef 100644 --- a/integration/proxy/proxy_helpers.go +++ b/integration/proxy/proxy_helpers.go @@ -195,7 +195,6 @@ func newSuite(t *testing.T, opts ...proxySuiteOptionsFunc) *Suite { func (p *Suite) addNodeToLeafCluster(t *testing.T, tunnelNodeHostname string) { nodeConfig := func() *servicecfg.Config { tconf := servicecfg.MakeDefaultConfig() - tconf.Console = nil tconf.Logger = utils.NewSlogLoggerForTests() tconf.Hostname = tunnelNodeHostname tconf.SetToken("token") diff --git a/lib/client/api_login_test.go b/lib/client/api_login_test.go index e06e73c6ce648..15d09fc03b671 100644 --- a/lib/client/api_login_test.go +++ b/lib/client/api_login_test.go @@ -516,8 +516,6 @@ type standaloneBundle struct { func newStandaloneTeleport(t *testing.T, clock clockwork.Clock) *standaloneBundle { randomAddr := utils.NetAddr{AddrNetwork: "tcp", Addr: "127.0.0.1:0"} - console := io.Discard - staticToken := uuid.New().String() // Prepare role and user. @@ -549,7 +547,6 @@ func newStandaloneTeleport(t *testing.T, clock clockwork.Clock) *standaloneBundl cfg.DataDir = makeDataDir() cfg.Hostname = "localhost" cfg.Clock = clock - cfg.Console = console cfg.Logger = utils.NewSlogLoggerForTests() cfg.SetAuthServerAddress(randomAddr) // must be present cfg.Auth.Preference, err = types.NewAuthPreferenceFromConfigFile(types.AuthPreferenceSpecV2{ @@ -633,7 +630,6 @@ func newStandaloneTeleport(t *testing.T, clock clockwork.Clock) *standaloneBundl cfg.Hostname = "localhost" cfg.SetToken(staticToken) cfg.Clock = clock - cfg.Console = console cfg.Logger = utils.NewSlogLoggerForTests() cfg.SetAuthServerAddress(*authAddr) cfg.Auth.Enabled = false diff --git a/lib/config/configuration.go b/lib/config/configuration.go index dda2ac6859cf4..45d3544012cfe 100644 --- a/lib/config/configuration.go +++ b/lib/config/configuration.go @@ -781,11 +781,6 @@ func applyAuthOrProxyAddress(fc *FileConfig, cfg *servicecfg.Config) error { } func applyLogConfig(loggerConfig Log, cfg *servicecfg.Config) error { - switch loggerConfig.Output { - case "stderr", "error", "2", "stdout", "out", "1": - cfg.Console = io.Discard // disable console printing - } - logger, level, err := logutils.Initialize(logutils.Config{ Output: loggerConfig.Output, Severity: loggerConfig.Severity, @@ -2514,7 +2509,6 @@ func Configure(clf *CommandLineFlags, cfg *servicecfg.Config, legacyAppFlags boo // apply --debug flag to config: if clf.Debug { - cfg.Console = io.Discard cfg.Debug = clf.Debug } diff --git a/lib/service/servicecfg/config.go b/lib/service/servicecfg/config.go index a89e79a8f6302..c8db0c845b418 100644 --- a/lib/service/servicecfg/config.go +++ b/lib/service/servicecfg/config.go @@ -21,7 +21,6 @@ package servicecfg import ( "context" - "io" "log/slog" "net" "net/http" @@ -132,9 +131,6 @@ type Config struct { // a teleport cluster). It's automatically generated on 1st start HostUUID string - // Console writer to speak to a user - Console io.Writer - // ReverseTunnels is a list of reverse tunnels to create on the // first cluster start ReverseTunnels []types.ReverseTunnel @@ -540,7 +536,6 @@ func ApplyDefaults(cfg *Config) { // Global defaults. cfg.Hostname = hostname cfg.DataDir = defaults.DataDir - cfg.Console = os.Stdout cfg.CipherSuites = utils.DefaultCipherSuites() cfg.Ciphers = sc.Ciphers cfg.KEXAlgorithms = kex @@ -684,10 +679,6 @@ func applyDefaults(cfg *Config) { cfg.Version = defaults.TeleportConfigVersionV1 } - if cfg.Console == nil { - cfg.Console = io.Discard - } - if cfg.Logger == nil { cfg.Logger = slog.Default() } diff --git a/tool/teleport/common/teleport_test.go b/tool/teleport/common/teleport_test.go index 7b1292f1e625c..fbf449fe37bc1 100644 --- a/tool/teleport/common/teleport_test.go +++ b/tool/teleport/common/teleport_test.go @@ -84,7 +84,6 @@ func TestTeleportMain(t *testing.T) { require.True(t, conf.Auth.Enabled) require.True(t, conf.SSH.Enabled) require.True(t, conf.Proxy.Enabled) - require.Equal(t, os.Stdout, conf.Console) require.True(t, slog.Default().Handler().Enabled(context.Background(), slog.LevelError)) })