Skip to content

Commit

Permalink
fixup: copy_file instead of filegroup
Browse files Browse the repository at this point in the history
  • Loading branch information
matzf committed Mar 18, 2024
1 parent ff2611b commit 4351a19
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 39 deletions.
6 changes: 0 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@ oci_pull(
repository = "library/debian",
)

http_archive(
name = "rules_multirun",
sha256 = "65401fca5163fda99d7f7613a389d79412ccba8749e8aeb9168b857970beb7af",
url = "https://github.com/keith/rules_multirun/releases/download/0.8.1/rules_multirun.0.8.1.tar.gz",
)

http_archive(
name = "rules_debian_packages",
sha256 = "0ae3b332f9d894e57693ce900769d2bd1b693e1f5ea1d9cdd82fa4479c93bcc8",
Expand Down
12 changes: 6 additions & 6 deletions acceptance/common/topogen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def topogen_test(
deps = [],
data = [],
homedir = "",
tester = "//docker:tester.tar"):
tester = "//docker:tester.tarball"):
"""Creates a test based on a topology file.
It creates a target specified by the 'name' argument that runs the entire
Expand Down Expand Up @@ -65,15 +65,15 @@ def topogen_test(
topo,
]
docker_images = [
"//docker:control.tar",
"//docker:daemon.tar",
"//docker:dispatcher.tar",
"//docker:router.tar",
"//docker:control.tarball",
"//docker:daemon.tarball",
"//docker:dispatcher.tarball",
"//docker:router.tarball",
]
if tester:
docker_images += [tester]
if gateway:
docker_images += ["//docker:gateway.tar"]
docker_images += ["//docker:gateway.tarball"]

for tar in docker_images:
common_data = common_data + [tar]
Expand Down
6 changes: 3 additions & 3 deletions acceptance/router_benchmark/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ exports_files([
args = [
"--executable",
"brload:$(location //acceptance/router_benchmark/brload:brload)",
"--docker=image=$(location //docker:router.tar)",
"--docker=image=$(location //docker:router.tarball)",
]

data = [
":conf",
"//docker:router.tar",
"//docker:router.tarball",
"//acceptance/router_benchmark/brload:brload",
]

Expand All @@ -22,7 +22,7 @@ raw_test(
src = "test.py",
args = args,
data = data,
homedir = "$(rootpath //docker:router.tar)",
homedir = "$(rootpath //docker:router.tarball)",
# This test uses sudo and accesses /var/run/netns.
local = True,
)
4 changes: 2 additions & 2 deletions acceptance/router_multi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ args = [
"--executable",
"braccept:$(location //tools/braccept)",
"--docker-image",
"$(location //docker:router.tar)",
"$(location //docker:router.tarball)",
"--pause_tar",
"$(location //acceptance/router_multi:pause.tar)",
]

data = [
"pause.tar",
":conf",
"//docker:router.tar",
"//docker:router.tarball",
"//tools/braccept",
]

Expand Down
6 changes: 3 additions & 3 deletions acceptance/sig_short_exp_time/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ sh_test(
srcs = ["test"],
data = [
"docker-compose.yml",
"//docker:dispatcher.tar",
"//docker:gateway.tar",
"//tools/udpproxy:udpproxy.tar",
"//docker:dispatcher.tarball",
"//docker:gateway.tarball",
"//tools/udpproxy:udpproxy.tarball",
] + glob(["testdata/**"]),
tags = [
"exclusive",
Expand Down
6 changes: 3 additions & 3 deletions acceptance/sig_short_exp_time/test
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ run_test() {(set -e
cp -RL acceptance/sig_short_exp_time/* "$tmpdir"

# Register with the docker daemon the docker images bazel created
docker image load -i tools/udpproxy/udpproxy.tar/tarball.tar
docker image load -i docker/dispatcher.load/tarball.tar
docker image load -i docker/gateway.load/tarball.tar
docker image load -i tools/udpproxy/udpproxy.tar
docker image load -i docker/dispatcher.tar
docker image load -i docker/gateway.tar

pushd $tmpdir
docker compose up -d dispatcher1 dispatcher2 sig1 sig2 patha pathb
Expand Down
23 changes: 14 additions & 9 deletions docker/scion_app.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

# Defines a common base image for all app images.
def scion_app_base():
Expand Down Expand Up @@ -41,7 +42,8 @@ def scion_app_base():
# cmd - string or list of strings of commands to execute in the image.
# caps - capabilities to set on the binary
#
# Target {name}.tar is the docker image tarball.
# Target {name}.tarball is the docker image .tar.
# Target {name}.load is the runnable target to load this image into docker.
#
# Load the image into docker with
# bazel run //path:name.load
Expand All @@ -65,17 +67,20 @@ def scion_app_image(name, src, entrypoint, appdir = "/app", workdir = "/share",
### XXX(matzf):
# This oci_tarball rule does two things: with `bazel build` it _builds_ the tarball, and with `bazel run` it _loads_ it into docker.
# Weirdly, "$(location //path/name.load)" expands to the shell script to _load_ the tarball but only the actual tarball file is symlinked into the test directories.
# I don't know if I deeply messed up, or bazel is just going of the rails here.
# As a workaround, pack the whole thing in a filegroup which only keeps the tarball. ugh
# This seems quite messed up and useless.
# One workaround is to wrap it in a filegroup; this only leaves the desired .tar file.
# The filegroups leaves the filename quite ugly though "{name}.load/tarball.tar",
# and so, instead, we copy it.
copy_file(
name = name + ".tarball",
src = name + ".load",
out = name + ".tar",
visibility = ["//visibility:public"],
)
oci_tarball(
name = name + ".load",
format = "docker",
image = name,
repo_tags = ["scion/" + name + ":latest"],
visibility = ["//visibility:public"],
)
native.filegroup(
name = name + ".tar",
srcs = [name + ".load"],
visibility = ["//visibility:public"],
)
10 changes: 6 additions & 4 deletions docker/tester.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@tester_debian10_packages//:packages.bzl", "debian_package_layer")

def scion_tester_image():
Expand Down Expand Up @@ -69,8 +70,9 @@ def scion_tester_image():
)

# see comment on scion_app.bzl
native.filegroup(
name = "tester.tar",
srcs = ["tester.load"],
copy_file(
name = "tester.tarball",
src = "tester.load",
out = "tester.tar",
visibility = ["//visibility:public"],
)
13 changes: 10 additions & 3 deletions tools/udpproxy/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
load("//tools/lint:go.bzl", "go_library")
load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

go_library(
name = "go_default_library",
Expand All @@ -20,12 +21,18 @@ go_binary(
visibility = ["//visibility:public"],
)

copy_file(
name = "udpproxy.tarball",
src = "udpproxy.load",
out = "udpproxy.tar",
visibility = ["//visibility:public"],
)

oci_tarball(
name = "udpproxy.tar",
name = "udpproxy.load",
format = "docker",
image = ":udpproxy_image",
repo_tags = ["scion/tools/udpproxy:latest"],
visibility = ["//visibility:public"],
)

oci_image(
Expand Down

0 comments on commit 4351a19

Please sign in to comment.