Skip to content

feat!: add summary to coder ping #14762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions cli/cliui/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ func (d ConnDiags) Write(w io.Writer) {
for _, msg := range general {
_, _ = fmt.Fprintln(w, msg)
}
if len(general) > 0 {
_, _ = fmt.Fprintln(w, "")
}
if len(client) > 0 {
_, _ = fmt.Fprint(w, "Possible client-side issues with direct connection:\n\n")
for _, msg := range client {
Expand All @@ -385,12 +388,6 @@ func (d ConnDiags) Write(w io.Writer) {
}

func (d ConnDiags) splitDiagnostics() (general, client, agent []string) {
if d.PingP2P {
general = append(general, "✔ You are connected directly (p2p)")
} else {
general = append(general, "❗ You are connected via a DERP relay, not directly (p2p)")
}

if d.AgentNetcheck != nil {
for _, msg := range d.AgentNetcheck.Interfaces.Warnings {
agent = append(agent, msg.Message)
Expand Down Expand Up @@ -461,5 +458,6 @@ func (d ConnDiags) splitDiagnostics() (general, client, agent []string) {
agent = append(agent,
fmt.Sprintf("Agent IP address is within an AWS range (AWS uses hard NAT)\n %s#endpoint-dependent-nat-hard-nat", d.TroubleshootingURL))
}

return general, client, agent
}
26 changes: 0 additions & 26 deletions cli/cliui/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,19 +683,6 @@ func TestConnDiagnostics(t *testing.T) {
diags cliui.ConnDiags
want []string
}{
{
name: "Direct",
diags: cliui.ConnDiags{
ConnInfo: workspacesdk.AgentConnectionInfo{
DERPMap: &tailcfg.DERPMap{},
},
PingP2P: true,
LocalNetInfo: &tailcfg.NetInfo{},
},
want: []string{
`✔ You are connected directly (p2p)`,
},
},
{
name: "DirectBlocked",
diags: cliui.ConnDiags{
Expand All @@ -705,7 +692,6 @@ func TestConnDiagnostics(t *testing.T) {
},
},
want: []string{
`❗ You are connected via a DERP relay, not directly (p2p)`,
`❗ Your Coder administrator has blocked direct connections`,
},
},
Expand All @@ -718,7 +704,6 @@ func TestConnDiagnostics(t *testing.T) {
LocalNetInfo: &tailcfg.NetInfo{},
},
want: []string{
`❗ You are connected via a DERP relay, not directly (p2p)`,
`The DERP map is not configured to use STUN`,
},
},
Expand All @@ -743,7 +728,6 @@ func TestConnDiagnostics(t *testing.T) {
},
},
want: []string{
`❗ You are connected via a DERP relay, not directly (p2p)`,
`Client could not connect to STUN over UDP`,
},
},
Expand All @@ -770,7 +754,6 @@ func TestConnDiagnostics(t *testing.T) {
},
},
want: []string{
`❗ You are connected via a DERP relay, not directly (p2p)`,
`Agent could not connect to STUN over UDP`,
},
},
Expand All @@ -785,7 +768,6 @@ func TestConnDiagnostics(t *testing.T) {
},
},
want: []string{
`❗ You are connected via a DERP relay, not directly (p2p)`,
`Client is potentially behind a hard NAT, as multiple endpoints were retrieved from different STUN servers`,
},
},
Expand All @@ -795,14 +777,12 @@ func TestConnDiagnostics(t *testing.T) {
ConnInfo: workspacesdk.AgentConnectionInfo{
DERPMap: &tailcfg.DERPMap{},
},
PingP2P: false,
LocalNetInfo: &tailcfg.NetInfo{},
AgentNetcheck: &healthsdk.AgentNetcheckReport{
NetInfo: &tailcfg.NetInfo{MappingVariesByDestIP: "true"},
},
},
want: []string{
`❗ You are connected via a DERP relay, not directly (p2p)`,
`Agent is potentially behind a hard NAT, as multiple endpoints were retrieved from different STUN servers`,
},
},
Expand All @@ -812,7 +792,6 @@ func TestConnDiagnostics(t *testing.T) {
ConnInfo: workspacesdk.AgentConnectionInfo{
DERPMap: &tailcfg.DERPMap{},
},
PingP2P: true,
AgentNetcheck: &healthsdk.AgentNetcheckReport{
Interfaces: healthsdk.InterfacesReport{
BaseReport: healthsdk.BaseReport{
Expand All @@ -824,7 +803,6 @@ func TestConnDiagnostics(t *testing.T) {
},
},
want: []string{
`✔ You are connected directly (p2p)`,
`Network interface eth0 has MTU 1280, (less than 1378), which may degrade the quality of direct connections`,
},
},
Expand All @@ -834,7 +812,6 @@ func TestConnDiagnostics(t *testing.T) {
ConnInfo: workspacesdk.AgentConnectionInfo{
DERPMap: &tailcfg.DERPMap{},
},
PingP2P: true,
LocalInterfaces: &healthsdk.InterfacesReport{
BaseReport: healthsdk.BaseReport{
Warnings: []health.Message{
Expand All @@ -844,7 +821,6 @@ func TestConnDiagnostics(t *testing.T) {
},
},
want: []string{
`✔ You are connected directly (p2p)`,
`Network interface eth1 has MTU 1310, (less than 1378), which may degrade the quality of direct connections`,
},
},
Expand All @@ -858,7 +834,6 @@ func TestConnDiagnostics(t *testing.T) {
AgentIPIsAWS: false,
},
want: []string{
`❗ You are connected via a DERP relay, not directly (p2p)`,
`Client IP address is within an AWS range (AWS uses hard NAT)`,
},
},
Expand All @@ -872,7 +847,6 @@ func TestConnDiagnostics(t *testing.T) {
AgentIPIsAWS: true,
},
want: []string{
`❗ You are connected via a DERP relay, not directly (p2p)`,
`Agent IP address is within an AWS range (AWS uses hard NAT)`,
},
},
Expand Down
4 changes: 4 additions & 0 deletions cli/cliui/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ func renderTable(out any, sort string, headers table.Row, filterColumns []string
if val != nil {
v = *val
}
case *time.Duration:
if val != nil {
v = val.String()
}
case fmt.Stringer:
if val != nil {
v = val.String()
Expand Down
Loading
Loading