Skip to content

Commit c0c0af5

Browse files
committed
Revert "fix test"
This reverts commit 218f4b0.
1 parent d451924 commit c0c0af5

File tree

4 files changed

+5
-46
lines changed

4 files changed

+5
-46
lines changed

agent/agent.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,12 +1503,6 @@ func (a *agent) Collect(ctx context.Context, networkStats map[netlogtype.Connect
15031503

15041504
stats.SessionCountReconnectingPty = a.connCountReconnectingPTY.Load()
15051505

1506-
// if we've seen sessions but currently have no connections we
1507-
// just count the sum of the sessions as connections
1508-
if stats.ConnectionCount == 0 {
1509-
stats.ConnectionCount = stats.SessionCountSsh + stats.SessionCountVscode + stats.SessionCountJetbrains + stats.SessionCountReconnectingPty
1510-
}
1511-
15121506
// Compute the median connection latency!
15131507
a.logger.Debug(ctx, "starting peer latency measurement for stats")
15141508
var wg sync.WaitGroup

agent/agentssh/agentssh.go

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ type Server struct {
105105
connCountVSCode atomic.Int64
106106
connCountJetBrains atomic.Int64
107107
connCountSSHSession atomic.Int64
108-
seenVSCode atomic.Bool
109-
seenJetBrains atomic.Bool
110-
seenSSHSession atomic.Bool
111108

112109
metrics *sshServerMetrics
113110
}
@@ -170,7 +167,7 @@ func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prom
170167
ChannelHandlers: map[string]ssh.ChannelHandler{
171168
"direct-tcpip": func(srv *ssh.Server, conn *gossh.ServerConn, newChan gossh.NewChannel, ctx ssh.Context) {
172169
// Wrapper is designed to find and track JetBrains Gateway connections.
173-
wrapped := NewJetbrainsChannelWatcher(ctx, s.logger, newChan, &s.connCountJetBrains, &s.seenJetBrains)
170+
wrapped := NewJetbrainsChannelWatcher(ctx, s.logger, newChan, &s.connCountJetBrains)
174171
ssh.DirectTCPIPHandler(srv, conn, wrapped, ctx)
175172
},
176173
"direct-streamlocal@openssh.com": directStreamLocalHandler,
@@ -248,31 +245,10 @@ type ConnStats struct {
248245
}
249246

250247
func (s *Server) ConnStats() ConnStats {
251-
// if we have 0 active connections, but we have seen a connection
252-
// since the last time we collected, count it as 1 so that workspace
253-
// activity is properly counted.
254-
sshCount := s.connCountSSHSession.Load()
255-
if sshCount == 0 && s.seenSSHSession.Load() {
256-
sshCount = 1
257-
}
258-
vscode := s.connCountVSCode.Load()
259-
if vscode == 0 && s.seenVSCode.Load() {
260-
vscode = 1
261-
}
262-
jetbrains := s.connCountJetBrains.Load()
263-
if jetbrains == 0 && s.seenJetBrains.Load() {
264-
jetbrains = 1
265-
}
266-
267-
// Reset the seen trackers for the next collection.
268-
s.seenSSHSession.Store(false)
269-
s.seenVSCode.Store(false)
270-
s.seenJetBrains.Store(false)
271-
272248
return ConnStats{
273-
Sessions: sshCount,
274-
VSCode: vscode,
275-
JetBrains: jetbrains,
249+
Sessions: s.connCountSSHSession.Load(),
250+
VSCode: s.connCountVSCode.Load(),
251+
JetBrains: s.connCountJetBrains.Load(),
276252
}
277253
}
278254

@@ -416,14 +392,12 @@ func (s *Server) sessionStart(logger slog.Logger, session ssh.Session, extraEnv
416392
switch magicType {
417393
case MagicSessionTypeVSCode:
418394
s.connCountVSCode.Add(1)
419-
s.seenVSCode.Store(true)
420395
defer s.connCountVSCode.Add(-1)
421396
case MagicSessionTypeJetBrains:
422397
// Do nothing here because JetBrains launches hundreds of ssh sessions.
423398
// We instead track JetBrains in the single persistent tcp forwarding channel.
424399
case "":
425400
s.connCountSSHSession.Add(1)
426-
s.seenSSHSession.Store(true)
427401
defer s.connCountSSHSession.Add(-1)
428402
default:
429403
logger.Warn(ctx, "invalid magic ssh session type specified", slog.F("type", magicType))

agent/agentssh/jetbrainstrack.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ type localForwardChannelData struct {
2727
type JetbrainsChannelWatcher struct {
2828
gossh.NewChannel
2929
jetbrainsCounter *atomic.Int64
30-
jetbrainsSeen *atomic.Bool
3130
logger slog.Logger
3231
}
3332

34-
func NewJetbrainsChannelWatcher(ctx ssh.Context, logger slog.Logger, newChannel gossh.NewChannel, counter *atomic.Int64, seen *atomic.Bool) gossh.NewChannel {
33+
func NewJetbrainsChannelWatcher(ctx ssh.Context, logger slog.Logger, newChannel gossh.NewChannel, counter *atomic.Int64) gossh.NewChannel {
3534
d := localForwardChannelData{}
3635
if err := gossh.Unmarshal(newChannel.ExtraData(), &d); err != nil {
3736
// If the data fails to unmarshal, do nothing.
@@ -61,7 +60,6 @@ func NewJetbrainsChannelWatcher(ctx ssh.Context, logger slog.Logger, newChannel
6160
return &JetbrainsChannelWatcher{
6261
NewChannel: newChannel,
6362
jetbrainsCounter: counter,
64-
jetbrainsSeen: seen,
6563
logger: logger.With(slog.F("destination_port", d.DestPort)),
6664
}
6765
}
@@ -72,7 +70,6 @@ func (w *JetbrainsChannelWatcher) Accept() (gossh.Channel, <-chan *gossh.Request
7270
return c, r, err
7371
}
7472
w.jetbrainsCounter.Add(1)
75-
w.jetbrainsSeen.Store(true)
7673
// nolint: gocritic // JetBrains is a proper noun and should be capitalized
7774
w.logger.Debug(context.Background(), "JetBrains watcher accepted channel")
7875

coderd/activitybump_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,6 @@ func TestWorkspaceActivityBump(t *testing.T) {
212212
time.Sleep(time.Second * 3)
213213
sshConn, err := conn.SSHClient(ctx)
214214
require.NoError(t, err)
215-
sess, err := sshConn.NewSession()
216-
require.NoError(t, err)
217-
err = sess.Shell()
218-
require.NoError(t, err)
219-
err = sess.Close()
220-
require.NoError(t, err)
221215
_ = sshConn.Close()
222216

223217
assertBumped(true)

0 commit comments

Comments
 (0)