Skip to content

Commit c506823

Browse files
authored
add nowsh reason to help debug failure (#2755)
1 parent 26e6dde commit c506823

File tree

2 files changed

+40
-14
lines changed

2 files changed

+40
-14
lines changed

pkg/remote/conncontroller/conncontroller.go

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ const (
4747
Status_Error = "error"
4848
)
4949

50+
const (
51+
NoWshCode_Disabled = "disabled"
52+
NoWshCode_PermissionError = "permission-error"
53+
NoWshCode_UserDeclined = "user-declined"
54+
NoWshCode_DomainSocketError = "domainsocket-error"
55+
NoWshCode_ConnServerStartError = "connserver-start-error"
56+
NoWshCode_InstallError = "install-error"
57+
NoWshCode_PostInstallStartError = "postinstall-start-error"
58+
NoWshCode_InstallVerifyError = "install-verify-error"
59+
)
60+
5061
const DefaultConnectionTimeout = 60 * time.Second
5162

5263
var globalLock = &sync.Mutex{}
@@ -663,6 +674,7 @@ type WshCheckResult struct {
663674
WshEnabled bool
664675
ClientVersion string
665676
NoWshReason string
677+
NoWshCode string
666678
WshError error
667679
}
668680

@@ -672,48 +684,48 @@ func (conn *SSHConn) tryEnableWsh(ctx context.Context, clientDisplayName string)
672684
enableWsh, askBeforeInstall := conn.getConnWshSettings()
673685
conn.Infof(ctx, "wsh settings enable:%v ask:%v\n", enableWsh, askBeforeInstall)
674686
if !enableWsh {
675-
return WshCheckResult{NoWshReason: "conn:wshenabled set to false"}
687+
return WshCheckResult{NoWshReason: "conn:wshenabled set to false", NoWshCode: NoWshCode_Disabled}
676688
}
677689
if askBeforeInstall {
678690
allowInstall, err := conn.getPermissionToInstallWsh(ctx, clientDisplayName)
679691
if err != nil {
680692
log.Printf("error getting permission to install wsh: %v\n", err)
681-
return WshCheckResult{NoWshReason: "error getting user permission to install", WshError: err}
693+
return WshCheckResult{NoWshReason: "error getting user permission to install", NoWshCode: NoWshCode_PermissionError, WshError: err}
682694
}
683695
if !allowInstall {
684-
return WshCheckResult{NoWshReason: "user selected not to install wsh extensions"}
696+
return WshCheckResult{NoWshReason: "user selected not to install wsh extensions", NoWshCode: NoWshCode_UserDeclined}
685697
}
686698
}
687699
err := conn.OpenDomainSocketListener(ctx)
688700
if err != nil {
689701
conn.Infof(ctx, "ERROR opening domain socket listener: %v\n", err)
690702
err = fmt.Errorf("error opening domain socket listener: %w", err)
691-
return WshCheckResult{NoWshReason: "error opening domain socket", WshError: err}
703+
return WshCheckResult{NoWshReason: "error opening domain socket", NoWshCode: NoWshCode_DomainSocketError, WshError: err}
692704
}
693705
needsInstall, clientVersion, osArchStr, err := conn.StartConnServer(ctx, false)
694706
if err != nil {
695707
conn.Infof(ctx, "ERROR starting conn server: %v\n", err)
696708
err = fmt.Errorf("error starting conn server: %w", err)
697-
return WshCheckResult{NoWshReason: "error starting connserver", WshError: err}
709+
return WshCheckResult{NoWshReason: "error starting connserver", NoWshCode: NoWshCode_ConnServerStartError, WshError: err}
698710
}
699711
if needsInstall {
700712
conn.Infof(ctx, "connserver needs to be (re)installed\n")
701713
err = conn.InstallWsh(ctx, osArchStr)
702714
if err != nil {
703715
conn.Infof(ctx, "ERROR installing wsh: %v\n", err)
704716
err = fmt.Errorf("error installing wsh: %w", err)
705-
return WshCheckResult{NoWshReason: "error installing wsh/connserver", WshError: err}
717+
return WshCheckResult{NoWshReason: "error installing wsh/connserver", NoWshCode: NoWshCode_InstallError, WshError: err}
706718
}
707719
needsInstall, clientVersion, _, err = conn.StartConnServer(ctx, true)
708720
if err != nil {
709721
conn.Infof(ctx, "ERROR starting conn server (after install): %v\n", err)
710722
err = fmt.Errorf("error starting conn server (after install): %w", err)
711-
return WshCheckResult{NoWshReason: "error starting connserver", WshError: err}
723+
return WshCheckResult{NoWshReason: "error starting connserver", NoWshCode: NoWshCode_PostInstallStartError, WshError: err}
712724
}
713725
if needsInstall {
714726
conn.Infof(ctx, "conn server not installed correctly (after install)\n")
715727
err = fmt.Errorf("conn server not installed correctly (after install)")
716-
return WshCheckResult{NoWshReason: "connserver not installed properly", WshError: err}
728+
return WshCheckResult{NoWshReason: "connserver not installed properly", NoWshCode: NoWshCode_InstallVerifyError, WshError: err}
717729
}
718730
return WshCheckResult{WshEnabled: true, ClientVersion: clientVersion}
719731
} else {
@@ -780,6 +792,13 @@ func (conn *SSHConn) connectInternal(ctx context.Context, connFlags *wconfig.Con
780792
} else {
781793
conn.Infof(ctx, "wsh not enabled: %s\n", wshResult.NoWshReason)
782794
}
795+
telemetry.GoRecordTEventWrap(&telemetrydata.TEvent{
796+
Event: "conn:nowsh",
797+
Props: telemetrydata.TEventProps{
798+
ConnType: "ssh",
799+
ConnWshErrorCode: wshResult.NoWshCode,
800+
},
801+
})
783802
}
784803
conn.persistWshInstalled(ctx, wshResult)
785804
return nil

pkg/telemetry/telemetrydata/telemetrydata.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var ValidEventNames = map[string]bool{
3535

3636
"conn:connect": true,
3737
"conn:connecterror": true,
38+
"conn:nowsh": true,
3839

3940
"waveai:enabletelemetry": true,
4041
"waveai:post": true,
@@ -105,14 +106,20 @@ type TEventProps struct {
105106

106107
ActionInitiator string `json:"action:initiator,omitempty" tstype:"\"keyboard\" | \"mouse\""`
107108
ActionType string `json:"action:type,omitempty"`
108-
PanicType string `json:"debug:panictype,omitempty"`
109+
110+
PanicType string `json:"debug:panictype,omitempty"`
111+
109112
BlockView string `json:"block:view,omitempty"`
110113
BlockController string `json:"block:controller,omitempty"`
111-
AiBackendType string `json:"ai:backendtype,omitempty"`
112-
AiLocal bool `json:"ai:local,omitempty"`
113-
WshCmd string `json:"wsh:cmd,omitempty"`
114-
WshHadError bool `json:"wsh:haderror,omitempty"`
115-
ConnType string `json:"conn:conntype,omitempty"`
114+
115+
AiBackendType string `json:"ai:backendtype,omitempty"`
116+
AiLocal bool `json:"ai:local,omitempty"`
117+
118+
WshCmd string `json:"wsh:cmd,omitempty"`
119+
WshHadError bool `json:"wsh:haderror,omitempty"`
120+
121+
ConnType string `json:"conn:conntype,omitempty"`
122+
ConnWshErrorCode string `json:"conn:wsherrorcode,omitempty"`
116123

117124
OnboardingFeature string `json:"onboarding:feature,omitempty" tstype:"\"waveai\" | \"magnify\" | \"wsh\""`
118125
OnboardingVersion string `json:"onboarding:version,omitempty"`

0 commit comments

Comments
 (0)