Skip to content

Commit dfcd93b

Browse files
authored
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
1 parent 95347b2 commit dfcd93b

File tree

3 files changed

+5
-40
lines changed

3 files changed

+5
-40
lines changed

agent/agent.go

-8
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ type Options struct {
9191
Execer agentexec.Execer
9292
ContainerLister agentcontainers.Lister
9393

94-
ExperimentalConnectionReports bool
9594
ExperimentalDevcontainersEnabled bool
9695
}
9796

@@ -196,7 +195,6 @@ func New(options Options) Agent {
196195
lister: options.ContainerLister,
197196

198197
experimentalDevcontainersEnabled: options.ExperimentalDevcontainersEnabled,
199-
experimentalConnectionReports: options.ExperimentalConnectionReports,
200198
}
201199
// Initially, we have a closed channel, reflecting the fact that we are not initially connected.
202200
// Each time we connect we replace the channel (while holding the closeMutex) with a new one
@@ -273,7 +271,6 @@ type agent struct {
273271
lister agentcontainers.Lister
274272

275273
experimentalDevcontainersEnabled bool
276-
experimentalConnectionReports bool
277274
}
278275

279276
func (a *agent) TailnetConn() *tailnet.Conn {
@@ -797,11 +794,6 @@ const (
797794
)
798795

799796
func (a *agent) reportConnection(id uuid.UUID, connectionType proto.Connection_Type, ip string) (disconnected func(code int, reason string)) {
800-
// If the experiment hasn't been enabled, we don't report connections.
801-
if !a.experimentalConnectionReports {
802-
return func(int, string) {} // Noop.
803-
}
804-
805797
// Remove the port from the IP because ports are not supported in coderd.
806798
if host, _, err := net.SplitHostPort(ip); err != nil {
807799
a.logger.Error(a.hardCtx, "split host and port for connection report failed", slog.F("ip", ip), slog.Error(err))

agent/agent_test.go

+5-18
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
173173
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
174174
defer cancel()
175175
//nolint:dogsled
176-
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
177-
o.ExperimentalConnectionReports = true
178-
})
176+
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
179177
sshClient, err := conn.SSHClient(ctx)
180178
require.NoError(t, err)
181179
defer sshClient.Close()
@@ -243,9 +241,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
243241
remotePort := sc.Text()
244242

245243
//nolint:dogsled
246-
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
247-
o.ExperimentalConnectionReports = true
248-
})
244+
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
249245
sshClient, err := conn.SSHClient(ctx)
250246
require.NoError(t, err)
251247

@@ -960,9 +956,7 @@ func TestAgent_SFTP(t *testing.T) {
960956
home = "/" + strings.ReplaceAll(home, "\\", "/")
961957
}
962958
//nolint:dogsled
963-
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
964-
o.ExperimentalConnectionReports = true
965-
})
959+
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
966960
sshClient, err := conn.SSHClient(ctx)
967961
require.NoError(t, err)
968962
defer sshClient.Close()
@@ -998,9 +992,7 @@ func TestAgent_SCP(t *testing.T) {
998992
defer cancel()
999993

1000994
//nolint:dogsled
1001-
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
1002-
o.ExperimentalConnectionReports = true
1003-
})
995+
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
1004996
sshClient, err := conn.SSHClient(ctx)
1005997
require.NoError(t, err)
1006998
defer sshClient.Close()
@@ -1043,7 +1035,6 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
10431035
//nolint:dogsled
10441036
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
10451037
o.BlockFileTransfer = true
1046-
o.ExperimentalConnectionReports = true
10471038
})
10481039
sshClient, err := conn.SSHClient(ctx)
10491040
require.NoError(t, err)
@@ -1064,7 +1055,6 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
10641055
//nolint:dogsled
10651056
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
10661057
o.BlockFileTransfer = true
1067-
o.ExperimentalConnectionReports = true
10681058
})
10691059
sshClient, err := conn.SSHClient(ctx)
10701060
require.NoError(t, err)
@@ -1093,7 +1083,6 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
10931083
//nolint:dogsled
10941084
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
10951085
o.BlockFileTransfer = true
1096-
o.ExperimentalConnectionReports = true
10971086
})
10981087
sshClient, err := conn.SSHClient(ctx)
10991088
require.NoError(t, err)
@@ -1724,9 +1713,7 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
17241713
defer cancel()
17251714

17261715
//nolint:dogsled
1727-
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
1728-
o.ExperimentalConnectionReports = true
1729-
})
1716+
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
17301717
id := uuid.New()
17311718

17321719
// Test that the connection is reported. This must be tested in the

cli/agent.go

-14
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
5454
agentHeaderCommand string
5555
agentHeader []string
5656

57-
experimentalConnectionReports bool
5857
experimentalDevcontainersEnabled bool
5958
)
6059
cmd := &serpent.Command{
@@ -327,10 +326,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
327326
containerLister = agentcontainers.NewDocker(execer)
328327
}
329328

330-
if experimentalConnectionReports {
331-
logger.Info(ctx, "experimental connection reports enabled")
332-
}
333-
334329
agnt := agent.New(agent.Options{
335330
Client: client,
336331
Logger: logger,
@@ -359,7 +354,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
359354
ContainerLister: containerLister,
360355

361356
ExperimentalDevcontainersEnabled: experimentalDevcontainersEnabled,
362-
ExperimentalConnectionReports: experimentalConnectionReports,
363357
})
364358

365359
promHandler := agent.PrometheusMetricsHandler(prometheusRegistry, logger)
@@ -489,14 +483,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
489483
Description: "Allow the agent to automatically detect running devcontainers.",
490484
Value: serpent.BoolOf(&experimentalDevcontainersEnabled),
491485
},
492-
{
493-
Flag: "experimental-connection-reports-enable",
494-
Hidden: true,
495-
Default: "false",
496-
Env: "CODER_AGENT_EXPERIMENTAL_CONNECTION_REPORTS_ENABLE",
497-
Description: "Enable experimental connection reports.",
498-
Value: serpent.BoolOf(&experimentalConnectionReports),
499-
},
500486
}
501487

502488
return cmd

0 commit comments

Comments
 (0)