kubernetes-sigs / blixt

Layer 4 Kubernetes load-balancer
Apache License 2.0
355 stars 51 forks source link

Unable to build dataplane due to new version of Aya #291

Closed k-jingyang closed 1 month ago

k-jingyang commented 1 month ago

Hello, I was trying to build the project and encountered the error below. Upon investigation, it's because we didn't copy Cargo.lock in Containerfile.dataplane. Hence, we pulled a newer version of aya where Bpf structs/modules were renamed to Epbf

❯ make build.image.dataplane TAG=latest
DOCKER_BUILDKIT=1 docker buildx build --platform linux/amd64 --load --file=build/Containerfile.dataplane -t ghcr.io/kubernetes-sigs/blixt-dataplane:latest ./
[+] Building 66.1s (23/28)                                                                                                                                                                                                                                                docker:default
 => [internal] load build definition from Containerfile.dataplane                                                                                                                                                                                                                   0.0s
 => => transferring dockerfile: 2.17kB                                                                                                                                                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                                                                                                                                    0.9s
 => [internal] load metadata for docker.io/library/rust:1.75-slim-bookworm                                                                                                                                                                                                          0.9s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                   0.0s
 => => transferring context: 189B                                                                                                                                                                                                                                                   0.0s
 => [internal] load build context                                                                                                                                                                                                                                                   0.6s
 => => transferring context: 345.58MB                                                                                                                                                                                                                                               0.6s
 => [builder  1/18] FROM docker.io/library/rust:1.75-slim-bookworm@sha256:70c2a016184099262fd7cee46f3d35fec3568c45c62f87e37f7f665f766b1f74                                                                                                                                          0.0s
 => [stage-1 1/5] FROM docker.io/library/alpine:latest@sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d                                                                                                                                                      0.0s
 => CACHED [builder  2/18] RUN apt-get update                                                                                                                                                                                                                                       0.0s
 => CACHED [builder  3/18] RUN apt-get install --yes     build-essential     protobuf-compiler     pkg-config     llvm-16     musl-tools                                                                                                                                            0.0s
 => CACHED [builder  4/18] RUN rustup default stable                                                                                                                                                                                                                                0.0s
 => CACHED [builder  5/18] RUN rustup install nightly                                                                                                                                                                                                                               0.0s
 => CACHED [builder  6/18] RUN rustup component add rust-src --toolchain nightly                                                                                                                                                                                                    0.0s
 => CACHED [builder  7/18] RUN --mount=type=cache,target=/root/.cargo/registry     cargo install bpf-linker                                                                                                                                                                         0.0s
 => CACHED [builder  8/18] WORKDIR /workspace                                                                                                                                                                                                                                       0.0s
 => CACHED [builder  9/18] RUN if [ "amd64" = "amd64" ];     then echo "x86_64" >> arch;     else echo "aarch64" >> arch;     fi                                                                                                                                                    0.0s
 => CACHED [builder 10/18] RUN rustup target add $(eval cat arch)-unknown-linux-musl                                                                                                                                                                                                0.0s
 => [builder 11/18] COPY dataplane dataplane                                                                                                                                                                                                                                        0.4s
 => [builder 12/18] COPY tools/udp-test-server tools/udp-test-server                                                                                                                                                                                                                0.0s
 => [builder 13/18] COPY xtask xtask                                                                                                                                                                                                                                                0.0s
 => [builder 14/18] COPY Cargo.toml Cargo.toml                                                                                                                                                                                                                                      0.0s
 => [builder 15/18] COPY .cargo .cargo                                                                                                                                                                                                                                              0.0s
 => [builder 16/18] RUN --mount=type=cache,target=/workspace/target/     --mount=type=cache,target=/root/.cargo/registry     cargo xtask build-ebpf --release                                                                                                                      36.1s
 => ERROR [builder 17/18] RUN --mount=type=cache,target=/workspace/target/     --mount=type=cache,target=/root/.cargo/registry     RUSTFLAGS=-Ctarget-feature=+crt-static cargo build     --workspace     --exclude ebpf     --release     --target=$(eval cat arch)-unknown-linu  27.9s
------
 > [builder 17/18] RUN --mount=type=cache,target=/workspace/target/     --mount=type=cache,target=/root/.cargo/registry     RUSTFLAGS=-Ctarget-feature=+crt-static cargo build     --workspace     --exclude ebpf     --release     --target=$(eval cat arch)-unknown-linux-musl:
0.197 warning: excluded package(s) `ebpf` not found in workspace `/workspace`
0.227  Downloading crates ...
0.291   Downloaded crc32fast v1.4.2
0.298   Downloaded env_filter v0.1.2
0.303   Downloaded foldhash v0.1.3
0.304   Downloaded aya-log-common v0.1.15
0.305   Downloaded env_logger v0.11.5
0.307   Downloaded lock_api v0.4.12
0.325   Downloaded parking_lot_core v0.9.10
0.326   Downloaded scopeguard v1.2.0
0.327   Downloaded parking_lot v0.12.3
0.329   Downloaded object v0.36.5
0.337   Downloaded num_enum_derive v0.7.3
0.338   Downloaded num_enum v0.7.3
1.044   Downloaded aya-log v0.2.1
1.359   Downloaded aya-obj v0.2.0
1.565   Downloaded aya v0.13.0
1.597    Compiling libc v0.2.159
1.600    Compiling syn v2.0.79
1.600    Compiling object v0.36.5
1.969    Compiling parking_lot_core v0.9.10
1.969    Compiling socket2 v0.5.7
1.969    Compiling signal-hook-registry v1.4.2
1.969    Compiling mio v1.0.2
1.969    Compiling getrandom v0.2.15
1.971    Compiling netlink-packet-route v0.20.1
1.972    Compiling netlink-sys v0.8.6
2.040    Compiling rand_core v0.6.4
2.040    Compiling ring v0.17.8
2.120    Compiling parking_lot v0.12.3
2.175    Compiling rand_chacha v0.3.1
2.296    Compiling tokio v1.40.0
2.371    Compiling rand v0.8.5
3.020    Compiling rustls-webpki v0.102.8
3.499    Compiling rustls v0.22.4
3.890    Compiling prettyplease v0.2.22
4.602    Compiling prost-build v0.12.6
5.195    Compiling tonic-build v0.11.0
5.859    Compiling aya-obj v0.2.0
8.293    Compiling tokio-util v0.7.12
9.168    Compiling h2 v0.3.26
9.592    Compiling tower v0.4.13
10.03    Compiling tokio-io-timeout v1.2.0
10.14    Compiling tokio-stream v0.1.16
10.79    Compiling tokio-rustls v0.25.0
10.96    Compiling aya v0.12.0
11.05    Compiling aya v0.13.0
12.90    Compiling hyper v0.14.30
14.75    Compiling common v0.3.0 (/workspace/dataplane/common)
14.83    Compiling aya-log v0.2.1
15.80    Compiling udp-test-server v0.3.0 (/workspace/tools/udp-test-server)
17.11    Compiling hyper-timeout v0.4.1
17.25    Compiling axum v0.6.20
21.07    Compiling tonic v0.11.0
21.92    Compiling tonic-health v0.11.0
22.06    Compiling api-server v0.3.0 (/workspace/dataplane/api-server)
24.38    Compiling xtask v0.3.0 (/workspace/xtask)
24.38    Compiling loader v0.3.0 (/workspace/dataplane/loader)
24.42 warning: use of deprecated type alias `aya_log::BpfLogger`: Use `aya_log::EbpfLogger` instead
24.42   --> dataplane/loader/src/main.rs:14:14
24.42    |
24.42 14 | use aya_log::BpfLogger;
24.42    |              ^^^^^^^^^
24.42    |
24.42    = note: `#[warn(deprecated)]` on by default
24.42 
24.42 warning: use of deprecated type alias `aya_log::BpfLogger`: Use `aya_log::EbpfLogger` instead
24.42   --> dataplane/loader/src/main.rs:41:25
24.42    |
24.42 41 |         if let Err(e) = BpfLogger::init(&mut bpf) {
24.42    |                         ^^^^^^^^^
24.42 
24.45 error[E0308]: mismatched types
24.45    --> dataplane/loader/src/main.rs:41:41
24.45     |
24.45 41  |         if let Err(e) = BpfLogger::init(&mut bpf) {
24.45     |                         --------------- ^^^^^^^^ expected `&mut Ebpf`, found `&mut Bpf`
24.45     |                         |
24.45     |                         arguments to this function are incorrect
24.45     |
24.45     = note: expected mutable reference `&mut aya::bpf::Ebpf`
24.45                found mutable reference `&mut Bpf`
24.45 note: associated function defined here
24.45    --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/aya-log-0.2.1/src/lib.rs:106:12
24.45     |
24.45 106 |     pub fn init(bpf: &mut Ebpf) -> Result<EbpfLogger, Error> {
24.45     |            ^^^^
24.45 
24.47 For more information about this error, try `rustc --explain E0308`.
24.47 warning: `loader` (bin "loader") generated 2 warnings
24.47 error: could not compile `loader` (bin "loader") due to 1 previous error; 2 warnings emitted
24.47 warning: build failed, waiting for other jobs to finish...
------
Containerfile.dataplane:42
--------------------
  41 |         cargo xtask build-ebpf --release
  42 | >>> RUN --mount=type=cache,target=/workspace/target/ \
  43 | >>>     --mount=type=cache,target=/root/.cargo/registry \
  44 | >>>     RUSTFLAGS=-Ctarget-feature=+crt-static cargo build \
  45 | >>>     --workspace \
  46 | >>>     --exclude ebpf \ 
  47 | >>>     --release \
  48 | >>>     --target=$(eval cat arch)-unknown-linux-musl
  49 |     RUN --mount=type=cache,target=/workspace/target/ \
--------------------
ERROR: failed to solve: process "/bin/sh -c RUSTFLAGS=-Ctarget-feature=+crt-static cargo build     --workspace     --exclude ebpf     --release     --target=$(eval cat arch)-unknown-linux-musl" did not complete successfully: exit code: 101
make: *** [Makefile:187: build.image.dataplane] Error 1
k-jingyang commented 1 month ago

This error seems to also exist in archive/golang-control-plane