Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2e08d19

Browse files
committed
fix test
1 parent55cda77 commit2e08d19

File tree

5 files changed

+14
-24
lines changed

5 files changed

+14
-24
lines changed

‎cli/cliui/agent.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import (
77
"strconv"
88
"strings"
99
"time"
10-
"unicode"
1110

1211
"github.com/google/uuid"
1312
"golang.org/x/xerrors"
1413
"tailscale.com/tailcfg"
1514

16-
"github.com/coder/coder/v2/coderd/healthcheck/health"
1715
"github.com/coder/coder/v2/codersdk"
1816
"github.com/coder/coder/v2/codersdk/healthsdk"
1917
"github.com/coder/coder/v2/codersdk/workspacesdk"
@@ -394,13 +392,13 @@ func (d ConnDiags) splitDiagnostics() (general, client, agent []string) {
394392

395393
ifd.AgentNetcheck!=nil {
396394
for_,msg:=ranged.AgentNetcheck.Interfaces.Warnings {
397-
agent=append(agent,formatHealthMessage(msg))
395+
agent=append(agent,msg.Message)
398396
}
399397
}
400398

401399
ifd.LocalInterfaces!=nil {
402400
for_,msg:=ranged.LocalInterfaces.Warnings {
403-
client=append(client,formatHealthMessage(msg))
401+
client=append(client,msg.Message)
404402
}
405403
}
406404

@@ -441,21 +439,12 @@ func (d ConnDiags) splitDiagnostics() (general, client, agent []string) {
441439
}
442440
}
443441

444-
iftrue {
442+
ifd.ClientIPIsAWS {
445443
client=append(client,"Client IP address is within an AWS range (AWS uses hard NAT)")
446444
}
447445

448-
iftrue {
446+
ifd.AgentIPIsAWS {
449447
agent=append(agent,"Agent IP address is within an AWS range (AWS uses hard NAT)")
450448
}
451449
returngeneral,client,agent
452450
}
453-
454-
funcformatHealthMessage(msg health.Message)string {
455-
ifmsg.Code!=health.CodeInterfaceSmallMTU {
456-
returnmsg.Message
457-
}
458-
r:= []rune(strings.Replace(msg.Message,", which may cause problems with direct connections","",-1))
459-
out:=string(append([]rune{unicode.ToUpper(r[0])},r[1:]...))
460-
returnfmt.Sprintf("%s, which may degrade the quality of direct connections",out)
461-
}

‎cli/cliui/agent_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ func TestConnDiagnostics(t *testing.T) {
817817
Interfaces: healthsdk.InterfacesReport{
818818
BaseReport: healthsdk.BaseReport{
819819
Warnings: []health.Message{
820-
health.Messagef(health.CodeInterfaceSmallMTU,"network interface eth0 has MTU 1280, (less than 1378), which maycause problems with direct connections"),
820+
health.Messagef(health.CodeInterfaceSmallMTU,"Network interface eth0 has MTU 1280, (less than 1378), which maydegrade the quality of direct connections"),
821821
},
822822
},
823823
},
@@ -838,7 +838,7 @@ func TestConnDiagnostics(t *testing.T) {
838838
LocalInterfaces:&healthsdk.InterfacesReport{
839839
BaseReport: healthsdk.BaseReport{
840840
Warnings: []health.Message{
841-
health.Messagef(health.CodeInterfaceSmallMTU,"network interface eth1 has MTU 1310, (less than 1378), which maycause problems with direct connections"),
841+
health.Messagef(health.CodeInterfaceSmallMTU,"Network interface eth1 has MTU 1310, (less than 1378), which maydegrade the quality of direct connections"),
842842
},
843843
},
844844
},

‎cli/ping.go

Lines changed: 6 additions & 6 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-
defercancel()
151+
diagCtx,diagCancel:=context.WithTimeout(inv.Context(),30*time.Second)
152+
deferdiagCancel()
153153
diags:=conn.GetPeerDiagnostics()
154154
cliui.PeerDiagnostics(inv.Stdout,diags)
155155

@@ -161,16 +161,16 @@ 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
iferr!=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
iferr!=nil||connInfo.DERPMap==nil {
173-
returnxerrors.Errorf("Failed to retrieve connection info from server: %v\n",err)
173+
returnxerrors.Errorf("Failed to retrieve connection info from server: %w\n",err)
174174
}
175175
connDiags.ConnInfo=connInfo
176176
ifReport,err:=healthsdk.RunInterfacesReport()
@@ -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
iferr==nil {
185185
connDiags.AgentNetcheck=&agentNetcheck
186186
connDiags.AgentIPIsAWS=isAWSIP(awsRanges,agentNetcheck.NetInfo)

‎cli/ping_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func TestPing(t *testing.T) {
6767

6868
pty.ExpectMatch("pong from "+workspace.Name)
6969
pty.ExpectMatch("✔ received remote agent data from Coder networking coordinator")
70+
pty.ExpectMatch("✔ You are connected directly (p2p)")
7071
cancel()
7172
<-cmdDone
7273
})

‎codersdk/healthsdk/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func generateInterfacesReport(st *interfaces.State) (report InterfacesReport) {
7272
report.Severity=health.SeverityWarning
7373
report.Warnings=append(report.Warnings,
7474
health.Messagef(health.CodeInterfaceSmallMTU,
75-
"network interface %s has MTU %d (less than %d), which maycause problems with direct connections",iface.Name,iface.MTU,safeMTU),
75+
"Network interface %s has MTU %d (less than %d), which maydegrade the quality of direct connections",iface.Name,iface.MTU,safeMTU),
7676
)
7777
}
7878
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp