Files
visor/runsc/container/BUILD
T
zeekayandHanzo Dev 3da05638df State the ZAP wire of every urpc payload
urpc encodes with encoding/json, which walks the payload on every call: a
realistic control.ExecArgs costs 7084ns and 10 allocations to cross. ZAP
reads a field at a constant offset out of the buffer that arrived, so the
same payload is 740ns and one allocation -- but only if the offsets are
stated, and a stated offset that is wrong is silent corruption rather than
a compile error. So state them from the types themselves.

//tools/zap reflects over the payloads at build time and writes the wire
as Go source with the offsets as constants. It lives inside Bazel because
pkg/sentry/control cannot be imported from outside it: the *_go_proto
packages it depends on have no source in the tree.

Six payloads had no layout to state. A map, an interface and a type from
another module have no offsets, so each is answered in the type:

  SaveOpts.Metadata and StartContainerArgs.InitialCgroups/Limits cross as
  lists of pairs; boot.Route.Destination restates net.IPNet as Subnet;
  OpenMountArgs restates the OCI mount fields the call actually uses;
  StartArgs.Spec and SinkConfig.Config carry their documents as the bytes
  they arrived as; MetricsRegistrationResponse carries the protocol
  buffer the same way; and seccheck's session options become a type
  instead of a map of any.

ExecArgs and MetricsExportData still have none: ExecArgs holds live
kernel objects behind an interface, and MetricsExportData reaches a
prometheus snapshot whose labels are a map.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-22 23:10:33 -07:00

130 lines
3.8 KiB
Python

load("//tools:defs.bzl", "default_platform", "go_library", "go_test", "most_shards", "platforms")
package(
default_applicable_licenses = ["//:license"],
licenses = ["notice"],
)
go_library(
name = "container",
srcs = [
"container.go",
"gofer_to_host_rpc.go",
"null_netns.go",
"state_file.go",
"status.go",
"zap.go",
],
visibility = [
"//runsc:__subpackages__",
"//test:__subpackages__",
"//tools/zap:__pkg__",
],
deps = [
"//pkg/abi/linux",
"//pkg/cleanup",
"//pkg/log",
"//pkg/pinring",
"//pkg/sentry/control",
"//pkg/sentry/fsimpl/erofs",
"//pkg/sentry/fsimpl/tmpfs",
"//pkg/sentry/pgalloc",
"//pkg/sighandling",
"//pkg/sync",
"//pkg/unet",
"//pkg/urpc",
"//runsc/boot",
"//runsc/cgroup",
"//runsc/config",
"//runsc/console",
"//runsc/donation",
"//runsc/profile",
"//runsc/sandbox",
"//runsc/specutils",
"//runsc/starttime",
"@com_github_gofrs_flock//:go_default_library",
"@com_github_opencontainers_runtime_spec//specs-go:go_default_library",
"@com_github_zap_proto_go//:go",
"@org_golang_x_sys//unix:go_default_library",
],
)
go_test(
name = "container_test",
size = "large",
srcs = [
"console_test.go",
"container_test.go",
"metric_server_test.go",
"multi_container_test.go",
"shared_volume_test.go",
"trace_test.go",
],
# Only run the default platform for the tsan test, which should
# be compatible. For non-tsan builds, run all platforms.
args = select({
"//conditions:default": [
"--test_platforms=%s" % ",".join([p for (p, tags) in platforms.items() if "manual" not in tags]) or default_platform,
],
"//tools:gotsan": [
"--test_platforms=%s" % default_platform,
],
}),
data = [
"//:release",
"//test/cmd/test_app",
],
library = ":container",
shard_count = most_shards,
tags = ["requires-kvm"],
deps = [
"//pkg/abi/linux",
"//pkg/cleanup",
"//pkg/hostos",
"//pkg/log",
"//pkg/seccheck/scsdk",
"//pkg/sentry/checkpoint",
"//pkg/sentry/control",
"//pkg/sentry/fscheckpoint",
"//pkg/sentry/fscheckpoint:fscheckpoint_proto_go_proto",
"//pkg/sentry/fsimpl/erofs",
"//pkg/sentry/kernel",
"//pkg/sentry/kernel/auth",
"//pkg/sentry/limits",
"//pkg/sentry/platform",
"//pkg/sentry/seccheck",
"//pkg/sentry/seccheck/points:points_go_proto",
"//pkg/sentry/seccheck/sinks/remote/test",
"//pkg/sentry/state/checkpointfiles",
"//pkg/state/statefile",
"//pkg/sync",
"//pkg/test/testutil",
"//pkg/unet",
"//runsc/boot",
"//runsc/cgroup",
"//runsc/config",
"//runsc/flag",
"//runsc/sandbox",
"//runsc/specutils",
"//test/metricclient",
"@com_github_cenkalti_backoff//:go_default_library",
"@com_github_creack_pty//:go_default_library",
"@com_github_google_go_cmp//cmp:go_default_library",
"@com_github_opencontainers_runtime_spec//specs-go:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
"@org_golang_x_sys//unix:go_default_library",
],
)
go_test(
name = "serialization_test",
srcs = ["serialization_test.go"],
deps = [
":container",
"//runsc/sandbox",
"@org_golang_google_protobuf//proto:go_default_library",
],
)