mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
feat: enable agent connection reports by default, remove flag (#16778)
This change enables agent connection reports by default and removes the experimental flag for enabling them. Updates #15139
This commit is contained in:
committed by
GitHub
parent
95347b2b93
commit
dfcd93b26e
@ -91,7 +91,6 @@ type Options struct {
|
|||||||
Execer agentexec.Execer
|
Execer agentexec.Execer
|
||||||
ContainerLister agentcontainers.Lister
|
ContainerLister agentcontainers.Lister
|
||||||
|
|
||||||
ExperimentalConnectionReports bool
|
|
||||||
ExperimentalDevcontainersEnabled bool
|
ExperimentalDevcontainersEnabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +195,6 @@ func New(options Options) Agent {
|
|||||||
lister: options.ContainerLister,
|
lister: options.ContainerLister,
|
||||||
|
|
||||||
experimentalDevcontainersEnabled: options.ExperimentalDevcontainersEnabled,
|
experimentalDevcontainersEnabled: options.ExperimentalDevcontainersEnabled,
|
||||||
experimentalConnectionReports: options.ExperimentalConnectionReports,
|
|
||||||
}
|
}
|
||||||
// Initially, we have a closed channel, reflecting the fact that we are not initially connected.
|
// Initially, we have a closed channel, reflecting the fact that we are not initially connected.
|
||||||
// Each time we connect we replace the channel (while holding the closeMutex) with a new one
|
// Each time we connect we replace the channel (while holding the closeMutex) with a new one
|
||||||
@ -273,7 +271,6 @@ type agent struct {
|
|||||||
lister agentcontainers.Lister
|
lister agentcontainers.Lister
|
||||||
|
|
||||||
experimentalDevcontainersEnabled bool
|
experimentalDevcontainersEnabled bool
|
||||||
experimentalConnectionReports bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *agent) TailnetConn() *tailnet.Conn {
|
func (a *agent) TailnetConn() *tailnet.Conn {
|
||||||
@ -797,11 +794,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (a *agent) reportConnection(id uuid.UUID, connectionType proto.Connection_Type, ip string) (disconnected func(code int, reason string)) {
|
func (a *agent) reportConnection(id uuid.UUID, connectionType proto.Connection_Type, ip string) (disconnected func(code int, reason string)) {
|
||||||
// If the experiment hasn't been enabled, we don't report connections.
|
|
||||||
if !a.experimentalConnectionReports {
|
|
||||||
return func(int, string) {} // Noop.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the port from the IP because ports are not supported in coderd.
|
// Remove the port from the IP because ports are not supported in coderd.
|
||||||
if host, _, err := net.SplitHostPort(ip); err != nil {
|
if host, _, err := net.SplitHostPort(ip); err != nil {
|
||||||
a.logger.Error(a.hardCtx, "split host and port for connection report failed", slog.F("ip", ip), slog.Error(err))
|
a.logger.Error(a.hardCtx, "split host and port for connection report failed", slog.F("ip", ip), slog.Error(err))
|
||||||
|
@ -173,9 +173,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
//nolint:dogsled
|
//nolint:dogsled
|
||||||
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
|
||||||
o.ExperimentalConnectionReports = true
|
|
||||||
})
|
|
||||||
sshClient, err := conn.SSHClient(ctx)
|
sshClient, err := conn.SSHClient(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer sshClient.Close()
|
defer sshClient.Close()
|
||||||
@ -243,9 +241,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
|
|||||||
remotePort := sc.Text()
|
remotePort := sc.Text()
|
||||||
|
|
||||||
//nolint:dogsled
|
//nolint:dogsled
|
||||||
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
|
||||||
o.ExperimentalConnectionReports = true
|
|
||||||
})
|
|
||||||
sshClient, err := conn.SSHClient(ctx)
|
sshClient, err := conn.SSHClient(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -960,9 +956,7 @@ func TestAgent_SFTP(t *testing.T) {
|
|||||||
home = "/" + strings.ReplaceAll(home, "\\", "/")
|
home = "/" + strings.ReplaceAll(home, "\\", "/")
|
||||||
}
|
}
|
||||||
//nolint:dogsled
|
//nolint:dogsled
|
||||||
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
|
||||||
o.ExperimentalConnectionReports = true
|
|
||||||
})
|
|
||||||
sshClient, err := conn.SSHClient(ctx)
|
sshClient, err := conn.SSHClient(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer sshClient.Close()
|
defer sshClient.Close()
|
||||||
@ -998,9 +992,7 @@ func TestAgent_SCP(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
//nolint:dogsled
|
//nolint:dogsled
|
||||||
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
|
||||||
o.ExperimentalConnectionReports = true
|
|
||||||
})
|
|
||||||
sshClient, err := conn.SSHClient(ctx)
|
sshClient, err := conn.SSHClient(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer sshClient.Close()
|
defer sshClient.Close()
|
||||||
@ -1043,7 +1035,6 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
|
|||||||
//nolint:dogsled
|
//nolint:dogsled
|
||||||
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
||||||
o.BlockFileTransfer = true
|
o.BlockFileTransfer = true
|
||||||
o.ExperimentalConnectionReports = true
|
|
||||||
})
|
})
|
||||||
sshClient, err := conn.SSHClient(ctx)
|
sshClient, err := conn.SSHClient(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -1064,7 +1055,6 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
|
|||||||
//nolint:dogsled
|
//nolint:dogsled
|
||||||
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
||||||
o.BlockFileTransfer = true
|
o.BlockFileTransfer = true
|
||||||
o.ExperimentalConnectionReports = true
|
|
||||||
})
|
})
|
||||||
sshClient, err := conn.SSHClient(ctx)
|
sshClient, err := conn.SSHClient(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -1093,7 +1083,6 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
|
|||||||
//nolint:dogsled
|
//nolint:dogsled
|
||||||
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
||||||
o.BlockFileTransfer = true
|
o.BlockFileTransfer = true
|
||||||
o.ExperimentalConnectionReports = true
|
|
||||||
})
|
})
|
||||||
sshClient, err := conn.SSHClient(ctx)
|
sshClient, err := conn.SSHClient(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -1724,9 +1713,7 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
//nolint:dogsled
|
//nolint:dogsled
|
||||||
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
|
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
|
||||||
o.ExperimentalConnectionReports = true
|
|
||||||
})
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|
||||||
// Test that the connection is reported. This must be tested in the
|
// Test that the connection is reported. This must be tested in the
|
||||||
|
14
cli/agent.go
14
cli/agent.go
@ -54,7 +54,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
|
|||||||
agentHeaderCommand string
|
agentHeaderCommand string
|
||||||
agentHeader []string
|
agentHeader []string
|
||||||
|
|
||||||
experimentalConnectionReports bool
|
|
||||||
experimentalDevcontainersEnabled bool
|
experimentalDevcontainersEnabled bool
|
||||||
)
|
)
|
||||||
cmd := &serpent.Command{
|
cmd := &serpent.Command{
|
||||||
@ -327,10 +326,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
|
|||||||
containerLister = agentcontainers.NewDocker(execer)
|
containerLister = agentcontainers.NewDocker(execer)
|
||||||
}
|
}
|
||||||
|
|
||||||
if experimentalConnectionReports {
|
|
||||||
logger.Info(ctx, "experimental connection reports enabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
agnt := agent.New(agent.Options{
|
agnt := agent.New(agent.Options{
|
||||||
Client: client,
|
Client: client,
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
@ -359,7 +354,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
|
|||||||
ContainerLister: containerLister,
|
ContainerLister: containerLister,
|
||||||
|
|
||||||
ExperimentalDevcontainersEnabled: experimentalDevcontainersEnabled,
|
ExperimentalDevcontainersEnabled: experimentalDevcontainersEnabled,
|
||||||
ExperimentalConnectionReports: experimentalConnectionReports,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
promHandler := agent.PrometheusMetricsHandler(prometheusRegistry, logger)
|
promHandler := agent.PrometheusMetricsHandler(prometheusRegistry, logger)
|
||||||
@ -489,14 +483,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
|
|||||||
Description: "Allow the agent to automatically detect running devcontainers.",
|
Description: "Allow the agent to automatically detect running devcontainers.",
|
||||||
Value: serpent.BoolOf(&experimentalDevcontainersEnabled),
|
Value: serpent.BoolOf(&experimentalDevcontainersEnabled),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Flag: "experimental-connection-reports-enable",
|
|
||||||
Hidden: true,
|
|
||||||
Default: "false",
|
|
||||||
Env: "CODER_AGENT_EXPERIMENTAL_CONNECTION_REPORTS_ENABLE",
|
|
||||||
Description: "Enable experimental connection reports.",
|
|
||||||
Value: serpent.BoolOf(&experimentalConnectionReports),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
Reference in New Issue
Block a user