Skip to content

Commit 65c275e

Browse files
committed
Introduce kafka-oidc feature and enable it by default for restate-server builds
To use the Kafka ingress with OIDC authentication, we need to enable the gssapi-vendored and curl-static features on our rdkafka dependency. To make things properly work with cross compilation, we need to patch rust-sasl and rdkafka and bump librdkafka to v2.12.1. The latter allows us to compile with curl-static which saves us the hassle to dynamically link against libraries from a different target architecture. Update transitive dependencies to work with cross compilation Bump rdkafka to use librdkafka 2.12.1
1 parent 740fe8b commit 65c275e

File tree

12 files changed

+135
-15
lines changed

12 files changed

+135
-15
lines changed

.github/workflows/docker.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ on:
6666
required: false
6767
default: false
6868
type: boolean
69+
features:
70+
description: "features to enable in the build"
71+
required: false
72+
default: ""
73+
type: string
6974
pushToDockerHub:
7075
description: "push image to DockerHub"
7176
required: false

Cargo.lock

Lines changed: 81 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ zstd = { version = "0.13" }
260260
[patch.crates-io.restate-workspace-hack]
261261
path = "workspace-hack"
262262

263+
[patch.crates-io]
264+
# Cross compilation fixes: Use autotools to detect cross compilation tool chain and disable tests when cross compiling.
265+
# The fixes are based on rust-sasl v0.1.22.
266+
# Todo: Upstream changes and get rid of patch
267+
sasl2-sys = { git = "https://github.com/restatedev/rust-sasl", rev = "6298ec4e1da8cd808be9956a8e32f42a7f10b245" }
268+
263269
[profile.release]
264270
opt-level = 3
265271
lto = "thin"

crates/ingress-kafka/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ publish = false
1010
[features]
1111
default = []
1212
options_schema = ["dep:schemars"]
13+
# support for OIDC based authentication via the Kafka consumer, building with rdkafka/curl-static does not work as it
14+
# fails with "SSL certificate OpenSSL verify result: unable to get local issuer certificate (20) (-1)" when trying to
15+
# obtain the OIDC token.
16+
oidc = ["rdkafka/curl-static", "rdkafka/gssapi-vendored"]
1317

1418
[dependencies]
1519
restate-workspace-hack = { workspace = true }
@@ -32,7 +36,10 @@ opentelemetry = { workspace = true }
3236
opentelemetry_sdk = { workspace = true }
3337
parking_lot = { workspace = true }
3438
# 0.38 was not released yet at the time of writing, so when this happens, remove the pin.
35-
rdkafka = { version = "0.38", git = "https://github.com/fede1024/rust-rdkafka.git", rev = "47d86d71e340896491b65521594bbf081186201e", features = ["libz-static", "cmake-build", "ssl-vendored"] }
39+
# The current revision is based on 47d86d71e340896491b65521594bbf081186201e, which was the previously pinned revision.
40+
# What was added on top of it, was enabling the curl feature of librdkafka if the feature curl-static is enabled and
41+
# upgrading librdkafka to v2.12.1 which allow us to configure the ca certificate of the statically linked curl library.
42+
rdkafka = { version = "0.38", git = "https://github.com/restatedev/rust-rdkafka.git", rev = "26064222228405f04963d8c38a6e771a80d23d2a", features = ["libz-static", "cmake-build", "ssl-vendored"] }
3643
schemars = { workspace = true, optional = true }
3744
thiserror = { workspace = true }
3845
tokio = { workspace = true, features = ["sync", "rt"] }

crates/ingress-kafka/src/subscription_controller.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ impl Service {
120120
task_orchestrator: &mut TaskOrchestrator,
121121
) -> anyhow::Result<()> {
122122
let mut client_config = rdkafka::ClientConfig::new();
123+
// enabling probing for the ca certificates if the user does not specify anything else
124+
client_config.set("https.ca.location", "probe");
123125

124126
let Source::Kafka { cluster, topic, .. } = subscription.source();
125127

crates/node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ options_schema = [
2222
"restate-admin/options_schema",
2323
"restate-worker/options_schema"
2424
]
25+
kafka-oidc = ["restate-worker/kafka-oidc"]
2526

2627
[dependencies]
2728
restate-workspace-hack = { workspace = true }

crates/worker/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ options_schema = [
1717
"restate-storage-query-datafusion/options_schema",
1818
"restate-timer/options_schema",
1919
]
20+
kafka-oidc = ["restate-ingress-kafka/oidc"]
2021

2122
[dependencies]
2223
restate-workspace-hack = { workspace = true }

deny.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ allow-registry = ["https://github.com/rust-lang/crates.io-index"]
174174
allow-git = [
175175
"https://github.com/apache/arrow-rs.git",
176176
"https://github.com/tikv/raft-rs.git",
177-
"https://github.com/fede1024/rust-rdkafka.git",
178177
]
179178

180179
[sources.allow-org]

docker/Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
ARG UPLOAD_DEBUGINFO=false
1212

13-
FROM --platform=$BUILDPLATFORM ghcr.io/restatedev/dev-tools:1.14.5 AS planner
13+
FROM --platform=$BUILDPLATFORM ghcr.io/restatedev/dev-tools:1.14.7 AS planner
1414
COPY . .
1515
RUN just chef-prepare
1616

17-
FROM --platform=$BUILDPLATFORM ghcr.io/restatedev/dev-tools:1.14.5 AS base
17+
FROM --platform=$BUILDPLATFORM ghcr.io/restatedev/dev-tools:1.14.7 AS base
1818
COPY --from=planner /restate/recipe.json recipe.json
1919
COPY justfile justfile
2020

@@ -32,6 +32,16 @@ ARG TARGETARCH
3232
ENV RUSTC_WRAPPER=/usr/bin/sccache
3333
ENV SCCACHE_DIR=/var/cache/sccache
3434

35+
# todo only enable those env variables when cross compiling
36+
# Set krb5 cross-compilation env variables (because we cannot run cross compiled tests)
37+
ENV krb5_cv_attr_constructor_destructor=yes
38+
ENV ac_cv_func_regcomp=yes
39+
ENV ac_cv_printf_positional=yes
40+
41+
# todo only enable this env variable when cross compiling
42+
# Set sasl2-sys cross-compilation env variables (because we cannot run cross compiled tests)
43+
ENV ac_cv_gssapi_supports_spnego=yes
44+
3545
# Overrides the behaviour of the release profile re including debug symbols, which in our repo is not to include them.
3646
# Should be set to 'false' or 'true'. See https://doc.rust-lang.org/cargo/reference/environment-variables.html
3747
ARG CARGO_PROFILE_RELEASE_DEBUG=false

docker/debug.Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
# the Business Source License, use of this software will be governed
99
# by the Apache License, Version 2.0.
1010

11-
FROM --platform=$BUILDPLATFORM ghcr.io/restatedev/dev-tools:1.14.5 AS planner
11+
FROM --platform=$BUILDPLATFORM ghcr.io/restatedev/dev-tools:1.14.7 AS planner
1212
COPY . .
1313
RUN just chef-prepare
1414

15-
FROM --platform=$BUILDPLATFORM ghcr.io/restatedev/dev-tools:1.14.5 AS base
15+
FROM --platform=$BUILDPLATFORM ghcr.io/restatedev/dev-tools:1.14.7 AS base
1616
COPY --from=planner /restate/recipe.json recipe.json
1717
COPY justfile justfile
1818

@@ -30,6 +30,16 @@ ARG TARGETARCH
3030
ENV RUSTC_WRAPPER=/usr/bin/sccache
3131
ENV SCCACHE_DIR=/var/cache/sccache
3232

33+
# todo only enable those env variables when cross compiling
34+
# Set krb5 cross-compilation env variables (because we cannot run cross compiled tests)
35+
ENV krb5_cv_attr_constructor_destructor=yes
36+
ENV ac_cv_func_regcomp=yes
37+
ENV ac_cv_printf_positional=yes
38+
39+
# todo only enable this env variable when cross compiling
40+
# Set sasl2-sys cross-compilation env variables (because we cannot run cross compiled tests)
41+
ENV ac_cv_gssapi_supports_spnego=yes
42+
3343
# Avoids feature unification by building the three binaries individually
3444
ARG BUILD_INDIVIDUALLY=false
3545
ARG RESTATE_FEATURES=''

0 commit comments

Comments
 (0)