Skip to content

Commit

Permalink
Fixes for discovery with JS
Browse files Browse the repository at this point in the history
- Patch prost-reflect
- Ensure discovery only goes over http2
- Add ca certs to the dockerfile, as the rustls library panics if it doesn't find them :(
- Add a console feature to enable tokio-console to be used
  • Loading branch information
jackkleeman committed Mar 22, 2023
1 parent f7ad6a9 commit 9280055
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 9 deletions.
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
rustflags = [
"-C", "force-unwind-tables", # Include full unwind tables when aborting on panic
"--cfg", "uuid_unstable", # Enable unstable Uuid
"--cfg", "tokio_unstable", # Enable unstable tokio
]
89 changes: 87 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ paste = "1.0"
pin-project = "1.0"
prost = "0.11"
prost-types = "0.11"
prost-reflect = "0.10.2"
prost-reflect = "0.10.3"
prost-build = "0.11"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
Expand Down
7 changes: 5 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ RUN apt -y install \
protobuf-compiler \
libprotoc-dev \
clang \
llvm
llvm \
ca-certificates
RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
COPY rust-toolchain.toml .
# Install toolchain based on rust-toolchain.toml. See for more details: https://github.com/paketo-community/rustup/issues/56
Expand All @@ -34,6 +35,8 @@ RUN just arch=$TARGETARCH build --release && \
FROM debian:bullseye-slim AS runtime
COPY --from=builder /restate/target/release/restate /usr/local/bin
COPY --from=builder /restate/NOTICE /NOTICE
# copy OS roots
COPY --from=builder /etc/ssl /etc/ssl
ENV RUST_LOG="warn,runtime=info"
WORKDIR /
ENTRYPOINT ["/usr/local/bin/restate"]
ENTRYPOINT ["/usr/local/bin/restate"]
9 changes: 8 additions & 1 deletion src/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ where
loop {
tokio::select! {
proposal = proposal_rx.recv() => {
debug!(?proposal, "Received proposal");
let fmt = format!("{proposal:?}");
debug!(proposal = fmt, "Received proposal");

let (target_peer_id, proposal) = proposal.expect("Consensus owns the proposal sender, that's why the receiver should never be closed");

Expand All @@ -112,15 +113,21 @@ where
if let Some(sender) = cmd_log.append_cmd(Command::Apply(proposal)) {
waiting_for_send_capacity.push(sender.reserve_owned())
}

debug!(proposal = fmt, "Processed proposal")
},
raft_msg = raft_rx.recv() => {
if let Some((target_peer_id, raft_msg)) = raft_msg {
let fmt = format!("{raft_msg:?}");
debug!(raft_msg = fmt, "Received raft message");

let cmd_log = cmd_logs.get_mut(&target_peer_id).expect("Peer id '{target}' is not known. This is a bug.");

if let Some(sender) = cmd_log.append_cmd(Command::Apply(raft_msg)) {
waiting_for_send_capacity.push(sender.reserve_owned())
}

debug!(raft_msg = fmt, "Processed raft message");
} else {
debug!("Shutting consensus down.");
break;
Expand Down
3 changes: 3 additions & 0 deletions src/restate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ tokio = { workspace = true }
tracing = { workspace = true }
tracing_instrumentation = { workspace = true }
worker = { workspace = true }

[features]
console = ["tokio/full", "tokio/tracing", "tracing_instrumentation/console-subscriber"]
3 changes: 1 addition & 2 deletions src/service_protocol/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,10 @@ impl ServiceDiscovery {
uri: &Uri,
additional_headers: &HashMap<HeaderName, HeaderValue>,
) -> Result<DiscoveredMetadata, ServiceDiscoveryError> {
let client = Client::builder().build::<_, Body>(
let client = Client::builder().http2_only(true).build::<_, Body>(
HttpsConnectorBuilder::new()
.with_native_roots()
.https_or_http()
.enable_http1()
.enable_http2()
.build(),
);
Expand Down
3 changes: 2 additions & 1 deletion src/tracing_instrumentation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ publish = false

[dependencies]
clap = { workspace = true }
console-subscriber = { version = "0.1.8", optional = true }
opentelemetry = { workspace = true, features = ["rt-tokio-current-thread", "rt-tokio"] }
opentelemetry-jaeger = { version = "0.17", features = ["rt-tokio-current-thread", "rt-tokio"] }
opentelemetry-semantic-conventions = "0.10"
Expand All @@ -20,4 +21,4 @@ tracing-subscriber = { workspace = true }
tracing-opentelemetry = { workspace = true }

[dev-dependencies]
tokio = { workspace = true }
tokio = { workspace = true }
2 changes: 2 additions & 0 deletions src/tracing_instrumentation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ impl Options {
)
.with_ansi(!self.disable_ansi_log),
);
#[cfg(feature = "console-subscriber")]
let layers = layers.with(console_subscriber::spawn());

if let Some(jaeger_endpoint) = &self.jaeger_endpoint {
layers
Expand Down

0 comments on commit 9280055

Please sign in to comment.