Skip to content
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: 8 additions & 2 deletions internal/remote/firecrest/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ func (c *FirecrestRemoteSessionController) Start(ctx context.Context) error {
return err
}
env["WSTUNNEL_SERVICE_ADDRESS"] = renkuBaseURL.Hostname()
env["WSTUNNEL_SERVICE_PORT"] = fmt.Sprintf("%d", 443) // wss port (same as https)
env["WSTUNNEL_PATH_PREFIX"] = renkuBaseURLPath + "/" + v1alpha1.TunnelIngressPathSuffix // session path with tunnel
env["WSTUNNEL_SERVICE_PORT"] = fmt.Sprintf("%d", 443) // wss port (same as https)
env["WSTUNNEL_PATH_PREFIX"] = wstunnelPathPrefix(renkuBaseURLPath) // session path with tunnel
}
// Setup environment variables for git repositories
repos := []string{}
Expand Down Expand Up @@ -1055,3 +1055,9 @@ func getPreferredScratch(fileSystems *[]FileSystem) *FileSystem {
}
return scratch
}

// wstunnelPathPrefix returns the -P value for the remote wstunnel client. wstunnel prepends a "/" to
// it when building the upgrade request, so the prefix must not carry one itself.
func wstunnelPathPrefix(renkuBaseURLPath string) string {
return strings.TrimPrefix(path.Join(renkuBaseURLPath, v1alpha1.TunnelIngressPathSuffix), "/")
}
20 changes: 20 additions & 0 deletions internal/remote/firecrest/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,23 @@ func TestStreamsToFetch(t *testing.T) {
})
}
}

func TestWstunnelPathPrefix(t *testing.T) {
tests := []struct {
name string
renkuBaseURLPath string
want string
}{
{"leading slash", "/sessions/my-session", "sessions/my-session/__amalthea__/tunnel"},
{"no leading slash", "sessions/my-session", "sessions/my-session/__amalthea__/tunnel"},
{"trailing slash", "/sessions/my-session/", "sessions/my-session/__amalthea__/tunnel"},
{"doubled leading slash", "//sessions/my-session", "sessions/my-session/__amalthea__/tunnel"},
}
// wstunnel's client prepends a "/" when it builds the upgrade request, so a prefix with a leading
// slash produces a "//sessions/..." request path that strict path-matching proxies do not route.
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.want, wstunnelPathPrefix(tt.renkuBaseURLPath))
})
}
}
Loading