third_party/linux: build using unhermetic rule
This replaces ad-hoc genrules (for the node Linux image and the ktest
image) with a real Bazel rule with an attached transition which ensures
we end up with the same-ish configurations for all builds of an image.
This reduces rebuilds of the ktest Linux kernel, from three down to one.
Before: https://drive.google.com/file/d/1c6VmY2bqx9Pgs61TOUfgMi8Sn0WQeobu/view
After: https://drive.google.com/file/d/13eO1rLhoBCMMRUKrmJz8QnhdAR3ctIGb/view
We also drive-by fix the Kubernetes CTS test suite to run on a single-node
Cluster (instead of failing early due to that being currently reworked).
Test Plan: Build system refactor, following existing test.
X-Origin-Diff: phab/D761
GitOrigin-RevId: b5545ac5fd402fbf0340d941a90b9ea6ea0b6d43
diff --git a/metropolis/node/BUILD.bazel b/metropolis/node/BUILD.bazel
index b5ed532..ee86523 100644
--- a/metropolis/node/BUILD.bazel
+++ b/metropolis/node/BUILD.bazel
@@ -88,7 +88,7 @@
genrule(
name = "image",
srcs = [
- "//third_party/linux:bzImage",
+ "//third_party/linux",
":rootfs",
],
outs = [
@@ -96,7 +96,7 @@
],
cmd = """
$(location //metropolis/node/build/mkimage) \
- -efi $(location //third_party/linux:bzImage) \
+ -efi $(location //third_party/linux) \
-system $(location :rootfs) \
-out $@
""",
diff --git a/metropolis/test/e2e/k8s_cts/main.go b/metropolis/test/e2e/k8s_cts/main.go
index e676a05..e419b2f 100644
--- a/metropolis/test/e2e/k8s_cts/main.go
+++ b/metropolis/test/e2e/k8s_cts/main.go
@@ -93,7 +93,8 @@
cancel()
}()
- debugClient, portMap, err := launch.LaunchCluster(ctx, launch.ClusterOptions{NumNodes: 2})
+ // TODO(q3k): bump up number of nodes after multi-node workflow gets reimplemented.
+ debugClient, portMap, err := launch.LaunchCluster(ctx, launch.ClusterOptions{NumNodes: 1})
if err != nil {
log.Fatalf("Failed to launch cluster: %v", err)
}
diff --git a/metropolis/test/ktest/BUILD b/metropolis/test/ktest/BUILD
index cfbce55..e994c48 100644
--- a/metropolis/test/ktest/BUILD
+++ b/metropolis/test/ktest/BUILD
@@ -1,5 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("//metropolis/node/build/kconfig-patcher:kconfig-patcher.bzl", "kconfig_patch")
+load("//third_party/linux:def.bzl", "linux_image")
go_library(
name = "go_default_library",
@@ -18,7 +19,7 @@
kconfig_patch(
name = "testing-config",
- src = "//third_party/linux:kernel-config",
+ src = "//third_party/linux:linux-metropolis.config",
out = "testing.config",
override_configs = {
# Unlock command line
@@ -33,27 +34,15 @@
},
)
-genrule(
+linux_image(
name = "linux-testing",
- srcs = [
- "@linux//:all",
- ":testing-config",
+ image_format = "vmlinux",
+ kernel_config = ":testing-config",
+ # This image is directly used by the ktest macro, thus it needs a pretty
+ # wide visibility.
+ visibility = [
+ "//metropolis:__subpackages__",
],
- outs = [
- "linux-testing.elf",
- ],
- cmd = """
- DIR=external/linux
-
- mkdir $$DIR/.bin
-
- cp $(location :testing-config) $$DIR/.config
-
- (cd $$DIR && make -j $$(nproc) vmlinux >/dev/null)
-
- cp $$DIR/vmlinux $@
- """,
- visibility = ["//metropolis:__subpackages__"],
)
filegroup(
diff --git a/metropolis/test/launch/launch.go b/metropolis/test/launch/launch.go
index 3a444ef..85e0a21 100644
--- a/metropolis/test/launch/launch.go
+++ b/metropolis/test/launch/launch.go
@@ -521,7 +521,7 @@
go func() {
if err := RunMicroVM(ctx, &MicroVMOptions{
- KernelPath: "metropolis/test/ktest/linux-testing.elf",
+ KernelPath: "metropolis/test/ktest/vmlinux",
InitramfsPath: "metropolis/test/nanoswitch/initramfs.lz4",
ExtraNetworkInterfaces: switchPorts,
PortMap: portMap,