Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2e78668

Browse files
committed
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 (cherry picked from commit dfcd93b)
1 parent 97481a3 commit 2e78668

File tree

3 files changed

+5
-45
lines changed

3 files changed

+5
-45
lines changed

agent/agent.go

-11
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ type Options struct {
9090
BlockFileTransfer bool
9191
Execer agentexec.Execer
9292
ContainerLister agentcontainers.Lister
93-
94-
ExperimentalConnectionReports bool
9593
}
9694

9795
type Client interface {
@@ -193,8 +191,6 @@ func New(options Options) Agent {
193191
metrics: newAgentMetrics(prometheusRegistry),
194192
execer: options.Execer,
195193
lister: options.ContainerLister,
196-
197-
experimentalConnectionReports: options.ExperimentalConnectionReports,
198194
}
199195
// Initially, we have a closed channel, reflecting the fact that we are not initially connected.
200196
// Each time we connect we replace the channel (while holding the closeMutex) with a new one
@@ -269,8 +265,6 @@ type agent struct {
269265
metrics *agentMetrics
270266
execer agentexec.Execer
271267
lister agentcontainers.Lister
272-
273-
experimentalConnectionReports bool
274268
}
275269

276270
func (a *agent) TailnetConn() *tailnet.Conn {
@@ -789,11 +783,6 @@ const (
789783
)
790784

791785
func (a *agent) reportConnection(id uuid.UUID, connectionType proto.Connection_Type, ip string) (disconnected func(code int, reason string)) {
792-
// If the experiment hasn't been enabled, we don't report connections.
793-
if !a.experimentalConnectionReports {
794-
return func(int, string) {} // Noop.
795-
}
796-
797786
// Remove the port from the IP because ports are not supported in coderd.
798787
if host, _, err := net.SplitHostPort(ip); err != nil {
799788
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
@@ -169,9 +169,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
169169
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
170170
defer cancel()
171171
//nolint:dogsled
172-
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
173-
o.ExperimentalConnectionReports = true
174-
})
172+
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
175173
sshClient, err := conn.SSHClient(ctx)
176174
require.NoError(t, err)
177175
defer sshClient.Close()
@@ -239,9 +237,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
239237
remotePort := sc.Text()
240238

241239
//nolint:dogsled
242-
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
243-
o.ExperimentalConnectionReports = true
244-
})
240+
conn, agentClient, stats, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
245241
sshClient, err := conn.SSHClient(ctx)
246242
require.NoError(t, err)
247243

@@ -956,9 +952,7 @@ func TestAgent_SFTP(t *testing.T) {
956952
home = "/" + strings.ReplaceAll(home, "\\", "/")
957953
}
958954
//nolint:dogsled
959-
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
960-
o.ExperimentalConnectionReports = true
961-
})
955+
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
962956
sshClient, err := conn.SSHClient(ctx)
963957
require.NoError(t, err)
964958
defer sshClient.Close()
@@ -994,9 +988,7 @@ func TestAgent_SCP(t *testing.T) {
994988
defer cancel()
995989

996990
//nolint:dogsled
997-
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
998-
o.ExperimentalConnectionReports = true
999-
})
991+
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
1000992
sshClient, err := conn.SSHClient(ctx)
1001993
require.NoError(t, err)
1002994
defer sshClient.Close()
@@ -1039,7 +1031,6 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
10391031
//nolint:dogsled
10401032
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
10411033
o.BlockFileTransfer = true
1042-
o.ExperimentalConnectionReports = true
10431034
})
10441035
sshClient, err := conn.SSHClient(ctx)
10451036
require.NoError(t, err)
@@ -1060,7 +1051,6 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
10601051
//nolint:dogsled
10611052
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
10621053
o.BlockFileTransfer = true
1063-
o.ExperimentalConnectionReports = true
10641054
})
10651055
sshClient, err := conn.SSHClient(ctx)
10661056
require.NoError(t, err)
@@ -1089,7 +1079,6 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
10891079
//nolint:dogsled
10901080
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
10911081
o.BlockFileTransfer = true
1092-
o.ExperimentalConnectionReports = true
10931082
})
10941083
sshClient, err := conn.SSHClient(ctx)
10951084
require.NoError(t, err)
@@ -1720,9 +1709,7 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
17201709
defer cancel()
17211710

17221711
//nolint:dogsled
1723-
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
1724-
o.ExperimentalConnectionReports = true
1725-
})
1712+
conn, agentClient, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0)
17261713
id := uuid.New()
17271714

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

cli/agent.go

-16
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
5454
agentHeaderCommand string
5555
agentHeader []string
5656
devcontainersEnabled bool
57-
58-
experimentalConnectionReports bool
5957
)
6058
cmd := &serpent.Command{
6159
Use: "agent",
@@ -327,10 +325,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
327325
containerLister = agentcontainers.NewDocker(execer)
328326
}
329327

330-
if experimentalConnectionReports {
331-
logger.Info(ctx, "experimental connection reports enabled")
332-
}
333-
334328
agnt := agent.New(agent.Options{
335329
Client: client,
336330
Logger: logger,
@@ -357,8 +351,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
357351
BlockFileTransfer: blockFileTransfer,
358352
Execer: execer,
359353
ContainerLister: containerLister,
360-
361-
ExperimentalConnectionReports: experimentalConnectionReports,
362354
})
363355

364356
promHandler := agent.PrometheusMetricsHandler(prometheusRegistry, logger)
@@ -488,14 +480,6 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
488480
Description: "Allow the agent to automatically detect running devcontainers.",
489481
Value: serpent.BoolOf(&devcontainersEnabled),
490482
},
491-
{
492-
Flag: "experimental-connection-reports-enable",
493-
Hidden: true,
494-
Default: "false",
495-
Env: "CODER_AGENT_EXPERIMENTAL_CONNECTION_REPORTS_ENABLE",
496-
Description: "Enable experimental connection reports.",
497-
Value: serpent.BoolOf(&experimentalConnectionReports),
498-
},
499483
}
500484

501485
return cmd

0 commit comments

Comments
 (0)