Skip to content

Commit 4b0b9b0

Browse files
authored
feat: add interfaces report to support bundle (#13563)
1 parent 88eb6ce commit 4b0b9b0

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

cli/support.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ func writeBundle(src *support.Bundle, dest *zip.Writer) error {
254254
"deployment/health.json": src.Deployment.HealthReport,
255255
"network/connection_info.json": src.Network.ConnectionInfo,
256256
"network/netcheck.json": src.Network.Netcheck,
257+
"network/interfaces.json": src.Network.Interfaces,
257258
"workspace/template.json": src.Workspace.Template,
258259
"workspace/template_version.json": src.Workspace.TemplateVersion,
259260
"workspace/parameters.json": src.Workspace.Parameters,

cli/support_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ func assertBundleContents(t *testing.T, path string, wantWorkspace bool, wantAge
197197
var v derphealth.Report
198198
decodeJSONFromZip(t, f, &v)
199199
require.NotEmpty(t, v, "netcheck should not be empty")
200+
case "network/interfaces.json":
201+
var v healthsdk.InterfacesReport
202+
decodeJSONFromZip(t, f, &v)
203+
require.NotEmpty(t, v, "interfaces should not be empty")
200204
case "workspace/workspace.json":
201205
var v codersdk.Workspace
202206
decodeJSONFromZip(t, f, &v)

codersdk/healthsdk/interfaces.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ import (
88
"github.com/coder/coder/v2/coderd/healthcheck/health"
99
)
1010

11+
// gVisor is nominally permitted to send packets up to 1280.
12+
// Wireguard adds 30 bytes (1310)
13+
// UDP adds 8 bytes (1318)
14+
// IP adds 20-60 bytes (1338-1378)
15+
// So, it really needs to be 1378 to be totally safe
16+
const safeMTU = 1378
17+
1118
// @typescript-ignore InterfacesReport
1219
type InterfacesReport struct {
1320
BaseReport
@@ -61,11 +68,11 @@ func generateInterfacesReport(st *interfaces.State) (report InterfacesReport) {
6168
continue
6269
}
6370
report.Interfaces = append(report.Interfaces, healthIface)
64-
if iface.MTU < 1378 {
71+
if iface.MTU < safeMTU {
6572
report.Severity = health.SeverityWarning
6673
report.Warnings = append(report.Warnings,
6774
health.Messagef(health.CodeInterfaceSmallMTU,
68-
"network interface %s has MTU %d (less than 1378), which may cause problems with direct connections", iface.Name, iface.MTU),
75+
"network interface %s has MTU %d (less than %d), which may cause problems with direct connections", iface.Name, iface.MTU, safeMTU),
6976
)
7077
}
7178
}

support/support.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ type Deployment struct {
4747

4848
type Network struct {
4949
ConnectionInfo workspacesdk.AgentConnectionInfo
50-
CoordinatorDebug string `json:"coordinator_debug"`
51-
Netcheck *derphealth.Report `json:"netcheck"`
52-
TailnetDebug string `json:"tailnet_debug"`
50+
CoordinatorDebug string `json:"coordinator_debug"`
51+
Netcheck *derphealth.Report `json:"netcheck"`
52+
TailnetDebug string `json:"tailnet_debug"`
53+
Interfaces healthsdk.InterfacesReport `json:"interfaces"`
5354
}
5455

5556
type Netcheck struct {
@@ -194,6 +195,15 @@ func NetworkInfo(ctx context.Context, client *codersdk.Client, log slog.Logger)
194195
return nil
195196
})
196197

198+
eg.Go(func() error {
199+
rpt, err := healthsdk.RunInterfacesReport()
200+
if err != nil {
201+
return xerrors.Errorf("run interfaces report: %w", err)
202+
}
203+
n.Interfaces = rpt
204+
return nil
205+
})
206+
197207
if err := eg.Wait(); err != nil {
198208
log.Error(ctx, "fetch network information", slog.Error(err))
199209
}

support/support_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func TestRun(t *testing.T) {
6666
assertNotNilNotEmpty(t, bun.Network.CoordinatorDebug, "network coordinator debug should be present")
6767
assertNotNilNotEmpty(t, bun.Network.Netcheck, "network netcheck should be present")
6868
assertNotNilNotEmpty(t, bun.Network.TailnetDebug, "network tailnet debug should be present")
69+
assertNotNilNotEmpty(t, bun.Network.Interfaces, "network interfaces health should be present")
6970
assertNotNilNotEmpty(t, bun.Workspace.Workspace, "workspace should be present")
7071
assertSanitizedWorkspace(t, bun.Workspace.Workspace)
7172
assertNotNilNotEmpty(t, bun.Workspace.BuildLogs, "workspace build logs should be present")
@@ -114,6 +115,7 @@ func TestRun(t *testing.T) {
114115
assertNotNilNotEmpty(t, bun.Network.CoordinatorDebug, "network coordinator debug should be present")
115116
assertNotNilNotEmpty(t, bun.Network.Netcheck, "network netcheck should be present")
116117
assertNotNilNotEmpty(t, bun.Network.TailnetDebug, "network tailnet debug should be present")
118+
assertNotNilNotEmpty(t, bun.Network.Interfaces, "network interfaces health should be present")
117119
assert.Empty(t, bun.Workspace.Workspace, "did not expect workspace to be present")
118120
assert.Empty(t, bun.Agent, "did not expect agent to be present")
119121
assertNotNilNotEmpty(t, bun.Logs, "bundle logs should be present")

0 commit comments

Comments
 (0)