Skip to content

Commit 99113cf

Browse files
authored
Add more options to df_engine docker build, slim down features for some packages (open-telemetry#1540)
This PR addresses a few problems that I ran into getting `df_engine` running in my kubernetes environment. The end result of all this is that you can now run a docker build like this: ` docker build --build-arg FEATURES="azure" --build-arg RUSTFLAGS="-C target-feature=-gfni" --build-arg DEBUG=1 --build-context otel-arrow=../../ -f Dockerfile -t df_engine .` # TLS Some of the Azure SDK crates + reqwest have a lot of default features enabled that we are not using and which rely on linking with openssl for TLS. This was giving me trouble with our musl build. I've disabled default features for these packages at the workspace level and opted for using `rustls-tls` with reqwest in the `otap` crate. # Configuring the docker build - Added the `FEATURES` build arg to the dockerfile and the cross platform build script so that you can turn on features like `azure` when building - Added the ability to specify `RUSTFLAGS` for the docker build so that we can turn some features on or off when compiling which brings me to my next item... # Adding some optional debug utils to the image When running on k8s I was getting very mysterious crashes after a couple of seconds with 0 logs to stdout. Remoting into the container and running the binary gave me the "Illegal instruction (core dumped)" message, which was a start. After checking the obvious vector extensions like SSE/AVX/AVX512, I was stumped. So, I added gdb to the container and found the exact instruction which is the longest mnemonic I have ever seen (comes from arrow's buffer crate): ``` (gdb) x/i $pc => 0x7ffff745fb4f <new+463>: vgf2p8affineqb $0x0,%ymm3,%ymm5,%ymm5 ``` Turns out my laptop has support for a specific feature called `gfni`, which the nodes with Intel Xeon processors that I was running did not. I think this will not be the last time someone needs to debug a native code/cross-compilation problem, so I added an option to the build called `DEBUG` that will include `gdb` (and maybe other debug utilities in the future) in the image.
1 parent 4889f00 commit 99113cf

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

rust/otap-dataflow/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ miette = { version="7.6.0", features = ["fancy"] }
8585
mimalloc-rust = "0.2.1"
8686
nix = { version = "0.30.1", features = ["process", "signal"] }
8787
num_enum = "0.7"
88-
object_store = "0.12.3"
88+
object_store = {version = "0.12.3", default-features = false}
8989
once_cell = "1.20.2"
9090
opentelemetry = "0.31.0"
9191
opentelemetry-proto = { version = "0.31", default-features = false, features = ["gen-tonic-messages", "logs"]} #TODO - use it from submodule instead of crate(?)
@@ -150,10 +150,10 @@ zip = "=4.2.0"
150150
byte-unit = "5.2.0"
151151

152152
# Azure Monnitor Exporter
153-
azure_identity = "0.30.0"
153+
azure_core = {version = "0.30.1", default-features = false }
154+
azure_identity = {version = "0.30.0", default-features = false }
154155
flate2 = "1.1.5"
155-
reqwest = "0.12.24"
156-
azure_core = "0.30.1"
156+
reqwest = { version = "0.12.24", default-features = false }
157157
time = "0.3.44"
158158
wiremock = "0.6.5"
159159

rust/otap-dataflow/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,27 @@ COPY --from=otel-arrow /proto/opentelemetry-proto /build/proto/opentelemetry-pro
2222

2323
COPY . /build/rust/dataflow/.
2424

25+
# RUSTFLAGS can be used to pass argument to rustc e.g.
26+
# --build-arg RUSTFLAGS="-C target-feature=-gfni"
27+
ARG RUSTFLAGS="-C target-cpu=native"
28+
ENV RUSTFLAGS=${RUSTFLAGS}
29+
30+
# These are used to enable features and are passed to carg's --features argument
31+
# e.g. --build-arg FEATURES="azure,quiver-persistence"
32+
ARG FEATURES
33+
ENV FEATURES=${FEATURES}
34+
2535
# Build dataflow engine
2636
RUN ./cross-arch-build.sh
2737

2838
# The runtime image
2939
FROM docker.io/alpine:3.23@sha256:51183f2cfa6320055da30872f211093f9ff1d3cf06f39a0bdb212314c5dc7375
3040
LABEL maintainer="The OpenTelemetry Authors"
41+
42+
# Passing --build-arg BUILD=1 adds additional debugging features to the image.
43+
ARG DEBUG="0"
44+
RUN if [ "$DEBUG" = "1" ]; then apk add --no-cache gdb; fi
45+
3146
RUN addgroup dataflow \
3247
&& adduser \
3348
--ingroup dataflow \

rust/otap-dataflow/crates/otap/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ futures-timer.workspace = true
2222
http.workspace = true
2323
humantime-serde.workspace = true
2424
log.workspace = true
25-
object_store.workspace = true
25+
object_store = {workspace = true, features = ["fs"]}
2626
parquet.workspace = true
2727
thiserror = { workspace = true }
2828
serde_with = { workspace = true }
@@ -70,8 +70,8 @@ geneva-uploader = { version = "0.3.0", optional = true }
7070
# Azure Monitor Exporter dependencies
7171
azure_identity = { workspace = true, optional = true }
7272
flate2 = { workspace = true, optional = true }
73-
reqwest = { workspace = true, optional = true }
74-
azure_core = { workspace = true, optional = true }
73+
reqwest = { workspace = true, optional = true, features = ["rustls-tls"] }
74+
azure_core = { workspace = true, optional = true, features = ["reqwest"] }
7575

7676
# OpenTelemetry proto with tonic feature enabled
7777
opentelemetry-proto = { workspace = true, optional = true }

rust/otap-dataflow/cross-arch-build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ else
1616
fi
1717

1818
rustup target add "${RUST_TARGET}"
19-
cargo build --release --target="${RUST_TARGET}"
20-
cp "target/${RUST_TARGET}/release/df_engine" .
19+
cargo build --release --features "$FEATURES" --target="${RUST_TARGET}"
20+
cp "target/${RUST_TARGET}/release/df_engine" .

0 commit comments

Comments
 (0)