From 231263fd26fea8c21f97e060f7a2aab5eabd18f5 Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Wed, 20 Nov 2024 03:24:44 +0000 Subject: [PATCH] fix(cli): properly handle build log streaming during `coder ping` --- cli/ping.go | 12 ++++++------ codersdk/healthsdk/interfaces.go | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cli/ping.go b/cli/ping.go index cd3f6e3a8ba55..a54687cf2cc84 100644 --- a/cli/ping.go +++ b/cli/ping.go @@ -103,11 +103,6 @@ func (r *RootCmd) ping() *serpent.Command { ctx, cancel := context.WithCancel(inv.Context()) defer cancel() - spin := spinner.New(spinner.CharSets[5], 100*time.Millisecond) - spin.Writer = inv.Stderr - spin.Suffix = pretty.Sprint(cliui.DefaultStyles.Keyword, " Collecting diagnostics...") - spin.Start() - notifyCtx, notifyCancel := inv.SignalNotifyContext(ctx, StopSignals...) defer notifyCancel() @@ -118,10 +113,15 @@ func (r *RootCmd) ping() *serpent.Command { workspaceName, ) if err != nil { - spin.Stop() return err } + // Start spinner after any build logs have finished streaming + spin := spinner.New(spinner.CharSets[5], 100*time.Millisecond) + spin.Writer = inv.Stderr + spin.Suffix = pretty.Sprint(cliui.DefaultStyles.Keyword, " Collecting diagnostics...") + spin.Start() + opts := &workspacesdk.DialAgentOptions{} if r.verbose { diff --git a/codersdk/healthsdk/interfaces.go b/codersdk/healthsdk/interfaces.go index 714e1ecbdb411..fe3bc032a71ed 100644 --- a/codersdk/healthsdk/interfaces.go +++ b/codersdk/healthsdk/interfaces.go @@ -68,11 +68,14 @@ func generateInterfacesReport(st *interfaces.State) (report InterfacesReport) { continue } report.Interfaces = append(report.Interfaces, healthIface) - if iface.MTU < safeMTU { + // Some loopback interfaces on Windows have a negative MTU, which we can + // safely ignore in diagnostics. + if iface.MTU > 0 && iface.MTU < safeMTU { report.Severity = health.SeverityWarning report.Warnings = append(report.Warnings, health.Messagef(health.CodeInterfaceSmallMTU, - "Network interface %s has MTU %d (less than %d), which may degrade the quality of direct connections", iface.Name, iface.MTU, safeMTU), + "Network interface %s has MTU %d (less than %d), which may degrade the quality of direct "+ + "connections or render them unusable.", iface.Name, iface.MTU, safeMTU), ) } }