Commit 2ac31cb
committed
fix(orchestrator): make
This change makes the orchestrator package buildable and testable on
darwin (Apple Silicon and Intel) so contributors can iterate locally
without a Linux VM. It does NOT change any runtime behaviour on linux —
the production target.
Background
----------
`go test -v ./...` inside packages/orchestrator failed on darwin because
~50 packages transitively import linux-only code:
- `github.com/ngrok/firewall_toolkit/pkg/expressions` (nftables
expression helpers; the package itself has linux build tags
upstream).
- `github.com/Merovius/nbd/nbdnl` (NBD netlink ioctls).
- `github.com/containernetworking/plugins/pkg/ns` (netns).
- linux-only symbols on `golang.org/x/sys/unix` and
`syscall.SysProcAttr` (`SyncFileRange`, `CopyFileRange`,
`ProcessVMReadv`, `RemoteIovec`, `Fsopen`, `FsconfigSetString`,
`Fsmount`, `MoveMount`, `MAP_HUGETLB`, `syscall.MAP_ANONYMOUS`,
`UseCgroupFD`, `CgroupFD`, …).
- cgo-based `userfaultfd` wrappers around `<linux/userfaultfd.h>`.
None of these can ever compile on darwin and there is no portable
substitute (the orchestrator is a linux-only runtime: firecracker
VMs, nftables, NBD, userfaultfd, cgroupv2 are all linux kernel
features).
Changes
-------
Added `//go:build linux` to every `.go` file in the packages whose
compile-time dependencies are linux-only. On darwin those packages
now report `[no test files]` (or are simply skipped); on linux they
build exactly as before because the constraint matches.
Tagged packages (267 files):
orchestrator (root), benchmarks,
cmd/{create-build,mount-build-rootfs,resume-build,smoketest},
pkg/cfg, pkg/chrooted, pkg/factories, pkg/healthcheck,
pkg/hyperloopserver{,/handlers}, pkg/metrics,
pkg/nfsproxy{,/chroot}, pkg/proxy,
pkg/sandbox{,/block,/build,/build/mocks,/fc,/nbd,/nbd/testutils,
/network,/rootfs,/template,/template/mocks,
/template/peerserver,/template/peerserver/mocks,
/uffd,/uffd/memory,/uffd/prefetch,/uffd/testutils,
/uffd/userfaultfd},
pkg/server, pkg/service, pkg/tcpfirewall,
pkg/template/build{,/buildcontext,/builderrors,/commands,
/core/filesystem,/core/oci,/core/rootfs,/layer,/phases,
/phases/{base,finalize,optimize,steps,user},
/sandboxtools,/storage/cache},
pkg/template/{metadata,server},
pkg/volumes.
Whole-package tagging (rather than per-leaf-file tagging plus darwin
stubs) was chosen because the linux-only API surface of these
packages is woven through them — `Firewall`, `Cache`,
`DirectPathMount`, `Userfaultfd`, namespaced slot setup, etc. are
used by sibling files within the same package. Stubbing every
exported symbol on darwin would have produced significantly more
churn for code that fundamentally cannot run on darwin anyway, and
would have given a false impression that those packages could ever
be exercised off-linux.
Files that already carried a build tag (`stat_linux.go`,
`stat_osx.go` in cmd/clean-nfs-cache/cleaner, the cgo
`userfaultfd/fd.go`, etc.) were left untouched.
Verification
------------
On darwin/arm64:
$ go test ./...
ok cmd/clean-nfs-cache/cleaner
ok cmd/simulate-gcs-traffic
ok cmd/simulate-nfs-traffic
ok pkg/localupload
ok pkg/nfsproxy/recovery
ok pkg/nfsproxy/tracing
ok pkg/portmap
ok pkg/sandbox/template/peerclient
ok pkg/template/build/writer
(linux-only packages report `[no test files]`)
exit 0
`go build ./...` also succeeds on darwin. All linux build tags resolve
correctly and the linux build is unchanged because we only added
constraints; no source was deleted or moved.go test ./... build and pass on macOS1 parent 3bf682b commit 2ac31cb
265 files changed
Lines changed: 530 additions & 0 deletions
File tree
- packages/orchestrator
- benchmarks
- cmd
- create-build
- mount-build-rootfs
- resume-build
- smoketest
- pkg
- cfg
- chrooted
- factories
- healthcheck
- hyperloopserver
- handlers
- metrics
- nfsproxy
- chroot
- proxy
- sandbox
- block
- build
- mocks
- cgroup
- fc
- nbd
- testutils
- network
- rootfs
- template
- mocks
- peerserver
- mocks
- uffd
- memory
- prefetch
- testutils
- userfaultfd
- server
- service
- tcpfirewall
- template
- build
- buildcontext
- builderrors
- commands
- core
- filesystem
- oci
- rootfs
- layer
- phases
- base
- finalize
- optimize
- steps
- user
- sandboxtools
- storage/cache
- metadata
- server
- volumes
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
0 commit comments