From 7c39586580c1eea6b1758e745f722f60fa99e9a0 Mon Sep 17 00:00:00 2001 From: Julie Yaunches Date: Wed, 12 Aug 2026 16:58:23 -0400 Subject: [PATCH] fix(refresh): preserve host SSH route Signed-off-by: Julie Yaunches --- pkg/cmd/refresh/sshaccess.go | 18 ------------------ pkg/cmd/refresh/sshaccess_test.go | 7 +++---- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/pkg/cmd/refresh/sshaccess.go b/pkg/cmd/refresh/sshaccess.go index aad5c3e9..e834dc69 100644 --- a/pkg/cmd/refresh/sshaccess.go +++ b/pkg/cmd/refresh/sshaccess.go @@ -116,12 +116,6 @@ func resolveWorkspaceSSH( workspace.SSHPort = int(port.GetPortNumber()) workspace.SSHUser = access.GetLinuxUser() workspace.SSHProxyHostname = "" - - // To support the "--host" fallback, preserve the legacy hostname information returned by the initial workspace query. - if providerHostname := providerSSHHostname(environment.GetInstance(), port.GetHostname()); providerHostname != "" { - workspace.HostSSHHostname = providerHostname - workspace.HostSSHProxyHostname = "" - } return workspace, nil } @@ -145,15 +139,3 @@ func findNetworkPort(networkInfo *devplanev1.EnvironmentNetworkInfo, portID stri } return nil } - -func providerSSHHostname(instance *devplanev1.Instance, workloadHostname string) string { - if instance == nil { - return "" - } - for _, hostname := range []string{instance.GetPublicIp(), instance.GetPublicDns(), instance.GetHostname()} { - if hostname != "" && hostname != workloadHostname { - return hostname - } - } - return "" -} diff --git a/pkg/cmd/refresh/sshaccess_test.go b/pkg/cmd/refresh/sshaccess_test.go index 0695be95..9db88862 100644 --- a/pkg/cmd/refresh/sshaccess_test.go +++ b/pkg/cmd/refresh/sshaccess_test.go @@ -41,7 +41,7 @@ func (s *stubEnvironmentSSHClient) GetNetworkInfo( }), nil } -func TestEnrichWorkspacesWithSSHAccess_UsesCurrentUsersPort(t *testing.T) { +func TestEnrichWorkspacesWithSSHAccess_UsesCurrentUsersPortWithoutChangingHostRoute(t *testing.T) { workspace := entity.Workspace{ ID: "env-1", Name: "container-env", @@ -50,7 +50,8 @@ func TestEnrichWorkspacesWithSSHAccess_UsesCurrentUsersPort(t *testing.T) { SSHUser: "ubuntu", SSHPort: 22, HostSSHUser: "ubuntu", - HostSSHPort: 22, + HostSSHPort: 41235, + HostSSHHostname: "host-gateway.example.com", SSHProxyHostname: "legacy-proxy.example.com", HostSSHProxyHostname: "legacy-host-proxy.example.com", } @@ -80,8 +81,6 @@ func TestEnrichWorkspacesWithSSHAccess_UsesCurrentUsersPort(t *testing.T) { want.SSHPort = 41234 want.SSHUser = "root" want.SSHProxyHostname = "" - want.HostSSHHostname = "203.0.113.10" - want.HostSSHProxyHostname = "" if diff := cmp.Diff([]entity.Workspace{want}, got); diff != "" { t.Fatalf("unexpected workspace (-want +got): %s", diff)