From aa3d6f708d50a310f60bca8f3e0ee310e4dce61c Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 14 Jan 2026 16:30:39 +0100 Subject: [PATCH] Use workspace FUSE for reading and writing files on serverless --- bundle/config/mutator/configure_wsfs.go | 5 +++++ bundle/config/mutator/configure_wsfs_test.go | 11 +++++++++++ libs/dbr/context.go | 11 ++++++++++- libs/dbr/context_test.go | 7 +++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/bundle/config/mutator/configure_wsfs.go b/bundle/config/mutator/configure_wsfs.go index 110e1a3819..4ef7d553c5 100644 --- a/bundle/config/mutator/configure_wsfs.go +++ b/bundle/config/mutator/configure_wsfs.go @@ -34,6 +34,11 @@ func (m *configureWSFS) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagno return nil } + // If running on serverless, use OS file functions directly. + if dbr.RunsOnServerless(ctx) { + return nil + } + // If so, swap out vfs.Path instance of the sync root with one that // makes all Workspace File System interactions extension aware. p, err := vfs.NewFilerPath(ctx, root, func(path string) (filer.Filer, error) { diff --git a/bundle/config/mutator/configure_wsfs_test.go b/bundle/config/mutator/configure_wsfs_test.go index 6762a446b4..ea1bf8cbce 100644 --- a/bundle/config/mutator/configure_wsfs_test.go +++ b/bundle/config/mutator/configure_wsfs_test.go @@ -63,3 +63,14 @@ func TestConfigureWSFS_SwapSyncRoot(t *testing.T) { assert.Empty(t, diags) assert.NotEqual(t, originalSyncRoot, b.SyncRoot) } + +func TestConfigureWSFS_SkipsIfRunningOnServerless(t *testing.T) { + b := mockBundleForConfigureWSFS(t, "/Workspace/foo") + originalSyncRoot := b.SyncRoot + + ctx := context.Background() + ctx = dbr.MockRuntime(ctx, dbr.Environment{IsDbr: true, Version: "client.1.13"}) + diags := bundle.Apply(ctx, b, mutator.ConfigureWSFS()) + assert.Empty(t, diags) + assert.Equal(t, originalSyncRoot, b.SyncRoot) +} diff --git a/libs/dbr/context.go b/libs/dbr/context.go index 303e911fba..06d5f00c62 100644 --- a/libs/dbr/context.go +++ b/libs/dbr/context.go @@ -1,6 +1,9 @@ package dbr -import "context" +import ( + "context" + "strings" +) // key is a package-local type to use for context keys. // @@ -61,3 +64,9 @@ func RuntimeVersion(ctx context.Context) string { return v.(Environment).Version } + +// RunsOnServerless returns true if running on serverless compute. +// Serverless runtime versions are prefixed with "client.". +func RunsOnServerless(ctx context.Context) bool { + return strings.HasPrefix(RuntimeVersion(ctx), "client.") +} diff --git a/libs/dbr/context_test.go b/libs/dbr/context_test.go index 94e155ab59..f73c204e62 100644 --- a/libs/dbr/context_test.go +++ b/libs/dbr/context_test.go @@ -84,3 +84,10 @@ func TestContext_RuntimeVersionWithMock(t *testing.T) { assert.Equal(t, "15.4", RuntimeVersion(MockRuntime(ctx, Environment{IsDbr: true, Version: "15.4"}))) assert.Empty(t, RuntimeVersion(MockRuntime(ctx, Environment{}))) } + +func TestContext_RunsOnServerless(t *testing.T) { + ctx := context.Background() + assert.True(t, RunsOnServerless(MockRuntime(ctx, Environment{IsDbr: true, Version: "client.1.13"}))) + assert.False(t, RunsOnServerless(MockRuntime(ctx, Environment{IsDbr: true, Version: "15.4"}))) + assert.False(t, RunsOnServerless(MockRuntime(ctx, Environment{}))) +}