Skip to content

Commit e162ec9

Browse files
committed
fix test
1 parent 55cda77 commit e162ec9

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

cli/cliui/agent.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,11 @@ func (d ConnDiags) splitDiagnostics() (general, client, agent []string) {
441441
}
442442
}
443443

444-
if true {
444+
if d.ClientIPIsAWS {
445445
client = append(client, "Client IP address is within an AWS range (AWS uses hard NAT)")
446446
}
447447

448-
if true {
448+
if d.AgentIPIsAWS {
449449
agent = append(agent, "Agent IP address is within an AWS range (AWS uses hard NAT)")
450450
}
451451
return general, client, agent

cli/ping.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ func (r *RootCmd) ping() *serpent.Command {
148148
break
149149
}
150150
}
151-
ctx, cancel = context.WithTimeout(inv.Context(), 30*time.Second)
152-
defer cancel()
151+
diagCtx, diagCancel := context.WithTimeout(inv.Context(), 30*time.Second)
152+
defer diagCancel()
153153
diags := conn.GetPeerDiagnostics()
154154
cliui.PeerDiagnostics(inv.Stdout, diags)
155155

@@ -161,14 +161,14 @@ func (r *RootCmd) ping() *serpent.Command {
161161
Verbose: r.verbose,
162162
}
163163

164-
awsRanges, err := cliutil.FetchAWSIPRanges(ctx, cliutil.AWSIPRangesURL)
164+
awsRanges, err := cliutil.FetchAWSIPRanges(diagCtx, cliutil.AWSIPRangesURL)
165165
if err != nil {
166166
opts.Logger.Debug(inv.Context(), "failed to retrieve AWS IP ranges", slog.Error(err))
167167
}
168168

169169
connDiags.ClientIPIsAWS = isAWSIP(awsRanges, ni)
170170

171-
connInfo, err := client.AgentConnectionInfoGeneric(ctx)
171+
connInfo, err := client.AgentConnectionInfoGeneric(diagCtx)
172172
if err != nil || connInfo.DERPMap == nil {
173173
return xerrors.Errorf("Failed to retrieve connection info from server: %v\n", err)
174174
}
@@ -180,7 +180,7 @@ func (r *RootCmd) ping() *serpent.Command {
180180
_, _ = fmt.Fprintf(inv.Stdout, "Failed to retrieve local interfaces report: %v\n", err)
181181
}
182182

183-
agentNetcheck, err := conn.Netcheck(ctx)
183+
agentNetcheck, err := conn.Netcheck(diagCtx)
184184
if err == nil {
185185
connDiags.AgentNetcheck = &agentNetcheck
186186
connDiags.AgentIPIsAWS = isAWSIP(awsRanges, agentNetcheck.NetInfo)

cli/ping_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func TestPing(t *testing.T) {
3939
})
4040

4141
pty.ExpectMatch("pong from " + workspace.Name)
42-
cancel()
4342
<-cmdDone
4443
})
4544

@@ -67,7 +66,6 @@ func TestPing(t *testing.T) {
6766

6867
pty.ExpectMatch("pong from " + workspace.Name)
6968
pty.ExpectMatch("✔ received remote agent data from Coder networking coordinator")
70-
cancel()
7169
<-cmdDone
7270
})
7371
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy