Skip to content

Commit b959de1

Browse files
committed
fix firecracker compile + run-dir flow; use reachable default image ref
1 parent 2bdcc43 commit b959de1

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

cleanroom.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 1
22
sandbox:
33
image:
4-
ref: ghcr.io/buildkite/cleanroom-base/alpine@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
4+
ref: docker.io/library/alpine@sha256:25109184c71bdad752c8312a8623239686a9a2071e8825f20acb8f2198c3f659
55
network:
66
default: deny
77
allow:

internal/backend/firecracker/backend.go

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"runtime"
1616
"strconv"
1717
"strings"
18+
"sync"
1819
"time"
1920

2021
"github.com/buildkite/cleanroom/internal/backend"
@@ -238,38 +239,17 @@ func (a *Adapter) run(ctx context.Context, req backend.RunRequest, stream backen
238239
return nil, err
239240
}
240241

241-
if !req.HostPassthrough {
242-
observation.PlanPath = planPath
243-
observation.RunDir = runDir
244-
return &backend.RunResult{
245-
RunID: req.RunID,
246-
ExitCode: 0,
247-
LaunchedVM: false,
248-
PlanPath: planPath,
249-
RunDir: runDir,
250-
ImageRef: req.Policy.ImageRef,
251-
ImageDigest: req.Policy.ImageDigest,
252-
Message: "firecracker execution plan generated; command not executed (set --dry-run or --host-passthrough for non-launch modes)",
253-
}, nil
254-
}
255-
256-
exitCode, stdout, stderr, err := runHostPassthrough(ctx, req.CWD, req.Command, req.TTY, stream)
257-
if err != nil {
258-
return nil, err
259-
}
260242
observation.PlanPath = planPath
261243
observation.RunDir = runDir
262244
return &backend.RunResult{
263245
RunID: req.RunID,
264-
ExitCode: exitCode,
246+
ExitCode: 0,
265247
LaunchedVM: false,
266248
PlanPath: planPath,
267249
RunDir: runDir,
268250
ImageRef: req.Policy.ImageRef,
269251
ImageDigest: req.Policy.ImageDigest,
270-
Message: "host passthrough execution complete (not sandboxed)",
271-
Stdout: stdout,
272-
Stderr: stderr,
252+
Message: "firecracker execution plan generated; command not executed",
273253
}, nil
274254
}
275255

@@ -283,7 +263,7 @@ func (a *Adapter) run(ctx context.Context, req backend.RunRequest, stream backen
283263
}
284264

285265
if req.KernelImagePath == "" {
286-
return nil, errors.New("kernel_image must be configured for launched execution; use --dry-run or --host-passthrough for non-launch modes")
266+
return nil, errors.New("kernel_image must be configured for launched execution")
287267
}
288268
observation.Phase = "launch"
289269

internal/controlservice/service.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"path/filepath"
78
"sort"
89
"strings"
910
"sync"
@@ -12,6 +13,7 @@ import (
1213
"github.com/buildkite/cleanroom/internal/backend"
1314
"github.com/buildkite/cleanroom/internal/controlapi"
1415
cleanroomv1 "github.com/buildkite/cleanroom/internal/gen/cleanroom/v1"
16+
"github.com/buildkite/cleanroom/internal/paths"
1517
"github.com/buildkite/cleanroom/internal/policy"
1618
"github.com/buildkite/cleanroom/internal/runtimeconfig"
1719
"github.com/charmbracelet/log"
@@ -853,6 +855,14 @@ func (s *Service) runExecution(sandboxID, executionID string) {
853855
})
854856

855857
firecrackerCfg := sb.Firecracker
858+
if strings.TrimSpace(firecrackerCfg.RunDir) == "" {
859+
if runBaseDir, err := paths.RunBaseDir(); err == nil {
860+
firecrackerCfg.RunDir = filepath.Join(runBaseDir, ex.RunID)
861+
}
862+
}
863+
if ex.Options.ReadOnlyWorkspace {
864+
firecrackerCfg.WorkspaceAccess = "ro"
865+
}
856866
if ex.Options.LaunchSeconds != 0 {
857867
firecrackerCfg.LaunchSeconds = ex.Options.LaunchSeconds
858868
}

internal/controlservice/service_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package controlservice
33
import (
44
"context"
55
"errors"
6+
"path/filepath"
67
"strings"
78
"testing"
89
"time"
910

1011
"github.com/buildkite/cleanroom/internal/backend"
1112
"github.com/buildkite/cleanroom/internal/controlapi"
1213
cleanroomv1 "github.com/buildkite/cleanroom/internal/gen/cleanroom/v1"
14+
"github.com/buildkite/cleanroom/internal/paths"
1315
"github.com/buildkite/cleanroom/internal/policy"
1416
)
1517

@@ -185,8 +187,12 @@ func TestLaunchRunTerminateLifecycle(t *testing.T) {
185187
if runResp.ImageDigest == "" {
186188
t.Fatal("expected run response to include image digest")
187189
}
188-
if !strings.HasPrefix(adapter.req.RunDir, "/tmp/cleanrooms/") {
189-
t.Fatalf("expected run dir under run root, got %q", adapter.req.RunDir)
190+
runBaseDir, err := paths.RunBaseDir()
191+
if err != nil {
192+
t.Fatalf("resolve run base dir: %v", err)
193+
}
194+
if got, want := filepath.Dir(adapter.req.RunDir), filepath.Clean(runBaseDir); got != want {
195+
t.Fatalf("expected run dir under %q, got %q", want, adapter.req.RunDir)
190196
}
191197
if adapter.runCalls != 1 {
192198
t.Fatalf("expected exactly one run call, got %d", adapter.runCalls)

0 commit comments

Comments
 (0)