-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfirecracker_validate.go
More file actions
57 lines (45 loc) · 1.69 KB
/
Copy pathfirecracker_validate.go
File metadata and controls
57 lines (45 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package runtime
import (
"fmt"
"path/filepath"
"github.com/TechnologyTailors/Schedune/schedune-control-plane/pkg/schema/launch"
)
// FirecrackerExecutor validates and dry-runs Firecracker execution
type FirecrackerExecutor struct{}
func (k *FirecrackerExecutor) Prepare(spec launch.LaunchSpec) (launch.PreparedLaunch, error) {
binPath := "firecracker"
kernel, rootfs := resolveFirecrackerDisks(spec)
if kernel == "" || rootfs == "" {
return launch.PreparedLaunch{}, fmt.Errorf("missing kernel or rootfs path for firecracker artifact model")
}
controlSocket, err := GetControlSocketPath(spec.WorkloadID, "firecracker")
if err != nil {
return launch.PreparedLaunch{}, fmt.Errorf("failed to resolve control socket: %w", err)
}
runtimeDir := filepath.Dir(controlSocket)
args := []string{
"--api-sock", controlSocket,
// In a real execution, we'd write a config JSON and pass it, or call the API.
// For V0 dry-run, we just mock the arguments.
"--config-file", filepath.Join(runtimeDir, "fc-config.json"),
}
return launch.PreparedLaunch{
RuntimeBackend: "firecracker",
MemoryMB: spec.MemoryMB,
Vcpu: spec.Vcpu,
StartupGraceSec: 2,
Firecracker: &launch.PreparedFirecrackerLaunch{
BinaryPath: binPath,
KernelImagePath: kernel,
RootfsPath: rootfs,
CommandArgs: args,
ControlSocketPath: controlSocket,
},
}, nil
}
func (k *FirecrackerExecutor) Execute(prepared launch.PreparedLaunch) (int, error) {
return 0, fmt.Errorf("firecracker actual execution not implemented in Data Plane V0 - validate/dry-run only")
}
func (k *FirecrackerExecutor) Terminate(pid int) error {
return fmt.Errorf("firecracker termination not implemented")
}