Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EBPF] Allow --compile-only and cross-compile in kmt.build #27111

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions tasks/kmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@ def build(
arch: str | None = None,
component: Component = "system-probe",
layout: str = "tasks/kernel_matrix_testing/build-layout.json",
compile_only=False,
):
stack = check_and_get_stack(stack)
assert stacks.stack_exists(
Expand All @@ -1113,35 +1114,39 @@ def build(
if arch is None:
arch = "local"

arch_obj = Arch.from_str(arch)
paths = KMTPaths(stack, arch_obj)
paths.arch_dir.mkdir(parents=True, exist_ok=True)

cc = get_compiler(ctx)

cc.exec(f"cd {CONTAINER_AGENT_PATH} && inv -e system-probe.object-files")

build_task = "build-sysprobe-binary" if component == "system-probe" else "build"
cc.exec(
f"cd {CONTAINER_AGENT_PATH} && git config --global --add safe.directory {CONTAINER_AGENT_PATH} && inv -e {component}.{build_task} --no-bundle --arch={arch_obj.name}",
)

cc.exec(f"tar cf {CONTAINER_AGENT_PATH}/kmt-deps/{stack}/build-embedded-dir.tar {EMBEDDED_SHARE_DIR}")

if compile_only:
return
Comment on lines +1132 to +1133
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider (if not too much work) extracting the remaining of this function to another function and call it only if compile_only == False


if vms is None:
vms = ",".join(stacks.get_all_vms_in_stack(stack))

assert os.path.exists(layout), f"File {layout} does not exist"

arch_obj = Arch.from_str(arch)
paths = KMTPaths(stack, arch_obj)
paths.arch_dir.mkdir(parents=True, exist_ok=True)

ssh_key_obj = try_get_ssh_key(ctx, ssh_key)
infra = build_infrastructure(stack, ssh_key_obj)
domains = filter_target_domains(vms, infra, arch_obj)
cc = get_compiler(ctx)

if not images_matching_ci(ctx, domains):
if ask("Some VMs do not match version in CI. Continue anyway [y/N]") != "y":
return

assert len(domains) > 0, f"no vms found from list {vms}. Run `inv -e kmt.status` to see all VMs in current stack"

cc.exec(f"cd {CONTAINER_AGENT_PATH} && inv -e system-probe.object-files")

build_task = "build-sysprobe-binary" if component == "system-probe" else "build"
cc.exec(
f"cd {CONTAINER_AGENT_PATH} && git config --global --add safe.directory {CONTAINER_AGENT_PATH} && inv -e {component}.{build_task} --no-bundle",
)

cc.exec(f"tar cf {CONTAINER_AGENT_PATH}/kmt-deps/{stack}/build-embedded-dir.tar {EMBEDDED_SHARE_DIR}")

build_layout(ctx, domains, layout, verbose)
for d in domains:
d.copy(ctx, f"./bin/{component}", "/root/")
Expand Down
Loading