Skip to content

Commit b7c574f

Browse files
feat!: add summary to coder ping (coder#14762)
1 parent e086d78 commit b7c574f

File tree

8 files changed

+254
-89
lines changed

8 files changed

+254
-89
lines changed

cli/cliui/agent.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ func (d ConnDiags) Write(w io.Writer) {
370370
for _, msg := range general {
371371
_, _ = fmt.Fprintln(w, msg)
372372
}
373+
if len(general) > 0 {
374+
_, _ = fmt.Fprintln(w, "")
375+
}
373376
if len(client) > 0 {
374377
_, _ = fmt.Fprint(w, "Possible client-side issues with direct connection:\n\n")
375378
for _, msg := range client {
@@ -385,12 +388,6 @@ func (d ConnDiags) Write(w io.Writer) {
385388
}
386389

387390
func (d ConnDiags) splitDiagnostics() (general, client, agent []string) {
388-
if d.PingP2P {
389-
general = append(general, "✔ You are connected directly (p2p)")
390-
} else {
391-
general = append(general, "❗ You are connected via a DERP relay, not directly (p2p)")
392-
}
393-
394391
if d.AgentNetcheck != nil {
395392
for _, msg := range d.AgentNetcheck.Interfaces.Warnings {
396393
agent = append(agent, msg.Message)
@@ -461,5 +458,6 @@ func (d ConnDiags) splitDiagnostics() (general, client, agent []string) {
461458
agent = append(agent,
462459
fmt.Sprintf("Agent IP address is within an AWS range (AWS uses hard NAT)\n %s#endpoint-dependent-nat-hard-nat", d.TroubleshootingURL))
463460
}
461+
464462
return general, client, agent
465463
}

cli/cliui/agent_test.go

-26
Original file line numberDiff line numberDiff line change
@@ -683,19 +683,6 @@ func TestConnDiagnostics(t *testing.T) {
683683
diags cliui.ConnDiags
684684
want []string
685685
}{
686-
{
687-
name: "Direct",
688-
diags: cliui.ConnDiags{
689-
ConnInfo: workspacesdk.AgentConnectionInfo{
690-
DERPMap: &tailcfg.DERPMap{},
691-
},
692-
PingP2P: true,
693-
LocalNetInfo: &tailcfg.NetInfo{},
694-
},
695-
want: []string{
696-
`✔ You are connected directly (p2p)`,
697-
},
698-
},
699686
{
700687
name: "DirectBlocked",
701688
diags: cliui.ConnDiags{
@@ -705,7 +692,6 @@ func TestConnDiagnostics(t *testing.T) {
705692
},
706693
},
707694
want: []string{
708-
`❗ You are connected via a DERP relay, not directly (p2p)`,
709695
`❗ Your Coder administrator has blocked direct connections`,
710696
},
711697
},
@@ -718,7 +704,6 @@ func TestConnDiagnostics(t *testing.T) {
718704
LocalNetInfo: &tailcfg.NetInfo{},
719705
},
720706
want: []string{
721-
`❗ You are connected via a DERP relay, not directly (p2p)`,
722707
`The DERP map is not configured to use STUN`,
723708
},
724709
},
@@ -743,7 +728,6 @@ func TestConnDiagnostics(t *testing.T) {
743728
},
744729
},
745730
want: []string{
746-
`❗ You are connected via a DERP relay, not directly (p2p)`,
747731
`Client could not connect to STUN over UDP`,
748732
},
749733
},
@@ -770,7 +754,6 @@ func TestConnDiagnostics(t *testing.T) {
770754
},
771755
},
772756
want: []string{
773-
`❗ You are connected via a DERP relay, not directly (p2p)`,
774757
`Agent could not connect to STUN over UDP`,
775758
},
776759
},
@@ -785,7 +768,6 @@ func TestConnDiagnostics(t *testing.T) {
785768
},
786769
},
787770
want: []string{
788-
`❗ You are connected via a DERP relay, not directly (p2p)`,
789771
`Client is potentially behind a hard NAT, as multiple endpoints were retrieved from different STUN servers`,
790772
},
791773
},
@@ -795,14 +777,12 @@ func TestConnDiagnostics(t *testing.T) {
795777
ConnInfo: workspacesdk.AgentConnectionInfo{
796778
DERPMap: &tailcfg.DERPMap{},
797779
},
798-
PingP2P: false,
799780
LocalNetInfo: &tailcfg.NetInfo{},
800781
AgentNetcheck: &healthsdk.AgentNetcheckReport{
801782
NetInfo: &tailcfg.NetInfo{MappingVariesByDestIP: "true"},
802783
},
803784
},
804785
want: []string{
805-
`❗ You are connected via a DERP relay, not directly (p2p)`,
806786
`Agent is potentially behind a hard NAT, as multiple endpoints were retrieved from different STUN servers`,
807787
},
808788
},
@@ -812,7 +792,6 @@ func TestConnDiagnostics(t *testing.T) {
812792
ConnInfo: workspacesdk.AgentConnectionInfo{
813793
DERPMap: &tailcfg.DERPMap{},
814794
},
815-
PingP2P: true,
816795
AgentNetcheck: &healthsdk.AgentNetcheckReport{
817796
Interfaces: healthsdk.InterfacesReport{
818797
BaseReport: healthsdk.BaseReport{
@@ -824,7 +803,6 @@ func TestConnDiagnostics(t *testing.T) {
824803
},
825804
},
826805
want: []string{
827-
`✔ You are connected directly (p2p)`,
828806
`Network interface eth0 has MTU 1280, (less than 1378), which may degrade the quality of direct connections`,
829807
},
830808
},
@@ -834,7 +812,6 @@ func TestConnDiagnostics(t *testing.T) {
834812
ConnInfo: workspacesdk.AgentConnectionInfo{
835813
DERPMap: &tailcfg.DERPMap{},
836814
},
837-
PingP2P: true,
838815
LocalInterfaces: &healthsdk.InterfacesReport{
839816
BaseReport: healthsdk.BaseReport{
840817
Warnings: []health.Message{
@@ -844,7 +821,6 @@ func TestConnDiagnostics(t *testing.T) {
844821
},
845822
},
846823
want: []string{
847-
`✔ You are connected directly (p2p)`,
848824
`Network interface eth1 has MTU 1310, (less than 1378), which may degrade the quality of direct connections`,
849825
},
850826
},
@@ -858,7 +834,6 @@ func TestConnDiagnostics(t *testing.T) {
858834
AgentIPIsAWS: false,
859835
},
860836
want: []string{
861-
`❗ You are connected via a DERP relay, not directly (p2p)`,
862837
`Client IP address is within an AWS range (AWS uses hard NAT)`,
863838
},
864839
},
@@ -872,7 +847,6 @@ func TestConnDiagnostics(t *testing.T) {
872847
AgentIPIsAWS: true,
873848
},
874849
want: []string{
875-
`❗ You are connected via a DERP relay, not directly (p2p)`,
876850
`Agent IP address is within an AWS range (AWS uses hard NAT)`,
877851
},
878852
},

cli/cliui/table.go

+4
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ func renderTable(out any, sort string, headers table.Row, filterColumns []string
199199
if val != nil {
200200
v = *val
201201
}
202+
case *time.Duration:
203+
if val != nil {
204+
v = val.String()
205+
}
202206
case fmt.Stringer:
203207
if val != nil {
204208
v = val.String()

0 commit comments

Comments
 (0)