Skip to content

Commit 6d91cde

Browse files
MasterPtatoNathanFlurry
authored andcommitted
fix: figure out actor log shipping
1 parent 1b91198 commit 6d91cde

File tree

12 files changed

+99
-25
lines changed

12 files changed

+99
-25
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Large diffs are not rendered by default.

packages/common/util/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ macros = []
1313
async-trait = "0.1"
1414
bcrypt = "0.13.0"
1515
chrono = "0.4"
16-
fdb-util.workspace = true
1716
formatted-error = { workspace = true, optional = true }
1817
futures-util = "0.3"
1918
global-error.workspace = true
@@ -25,6 +24,7 @@ regex = "1.4"
2524
reqwest = { version = "0.12", default-features = false }
2625
rivet-config.workspace = true
2726
rivet-metrics.workspace = true
27+
rivet-util-id = { workspace = true }
2828
rivet-util-macros.workspace = true
2929
serde = { version = "1.0", features = ["derive"] }
3030
serde_json = { version = "1.0" }

packages/common/util/core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
pub use id::Id;
21
use rand::Rng;
32
pub use rivet_util_macros as macros;
3+
pub use rivet_util_id as id;
4+
pub use id::Id;
45
use tokio::time::{Duration, Instant};
56

67
pub mod billing;
@@ -13,7 +14,6 @@ pub mod format;
1314
pub mod future;
1415
pub mod geo;
1516
pub mod glob;
16-
pub mod id;
1717
pub mod math;
1818
pub mod req;
1919
pub mod route;

packages/common/util/id/Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "rivet-util-id"
3+
version.workspace = true
4+
authors.workspace = true
5+
license.workspace = true
6+
edition.workspace = true
7+
8+
[dependencies]
9+
fdb-util.workspace = true
10+
serde = { version = "1.0", features = ["derive"] }
11+
thiserror = "1.0"
12+
uuid = { version = "1", features = ["v4", "serde"] }
13+
14+
[dependencies.sqlx]
15+
workspace = true
16+
features = [
17+
"runtime-tokio",
18+
"postgres",
19+
"uuid",
20+
"json",
21+
"ipnetwork"
22+
]
File renamed without changes.

packages/edge/infra/client/container-runner/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ path = "src/main.rs"
1313
anyhow.workspace = true
1414
nix.workspace = true
1515
rivet-logs.workspace = true
16+
rivet-util.workspace = true
1617
serde = { version = "1.0.195", features = ["derive"] }
1718
serde_json = "1.0.111"
1819
signal-hook = "0.3.17"

packages/edge/infra/client/container-runner/Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
FROM clux/muslrust:1.81.0-stable AS rust
1+
# IMPORTANT: This version is required for GLIBC 2.31 (used by edge servers on Linode)
2+
FROM rust:1.82.0-bullseye AS rust
23

34
WORKDIR /app
45
COPY . .
56

7+
# Installs shared libs
8+
#
9+
# The FDB version should match `cluster::workflows::server::install::install_scripts::components::fdb::FDB_VERSION`
10+
RUN \
11+
apt-get update -y && \
12+
apt-get install -y \
13+
libclang-dev protobuf-compiler && \
14+
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.1.60/libfdb_c.x86_64.so"
15+
616
RUN \
717
--mount=type=cache,target=/root/.cargo/git \
818
--mount=type=cache,target=/root/.cargo/registry \
919
--mount=type=cache,target=/app/target \
10-
RUSTFLAGS="--cfg tokio_unstable" cargo build --bin rivet-container-runner --release && \
20+
# TODO: release is too slow
21+
RUSTFLAGS="--cfg tokio_unstable" cargo build --target x86_64-unknown-linux-gnu --bin rivet-container-runner && \
1122
mkdir -p /app/dist && \
12-
mv /app/target/x86_64-unknown-linux-musl/release/rivet-container-runner /app/dist/rivet-container-runner
23+
mv /app/target/x86_64-unknown-linux-gnu/debug/rivet-container-runner /app/dist/rivet-container-runner
1324

1425
# Create an empty image and copy binaries into it to minimize the size of the image
1526
FROM scratch

packages/edge/infra/client/container-runner/src/log_shipper.rs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,39 @@ impl LogShipper {
9090
println!("Log shipper connected");
9191

9292
while let Result::Ok(message) = self.msg_rx.recv() {
93+
// // If actor id is not provided, extract from logs
94+
// let actor_id = if self.actor_id.is_some() {
95+
// self.actor_id.as_deref()
96+
// } else {
97+
// if let Some(start_idx) = message.message.find("actor_") {
98+
// let start_idx = start_idx + 6;
99+
100+
// // Look for next non alphanum (end of actor id)
101+
// let end_idx = if let Some(end_idx) =
102+
// message.message[start_idx..].find(|c: char| !c.is_ascii_alphanumeric())
103+
// {
104+
// start_idx + end_idx
105+
// } else {
106+
// message.message.len()
107+
// };
108+
109+
// let actor_id = &message.message[start_idx..end_idx];
110+
111+
// // Check if valid id
112+
// rivet_util::Id::parse(actor_id).is_ok().then_some(actor_id)
113+
// } else {
114+
// None
115+
// }
116+
// };
117+
118+
// // Cannot determine actor id, ignore log
119+
// let Some(actor_id) = actor_id else {
120+
// continue;
121+
// };
122+
93123
let vector_message = VectorMessage::Actors {
94-
// runner_id: self.runner_id.as_str(),
95-
actor_id: self.actor_id.as_ref().map(|x| x.as_str()),
124+
runner_id: self.runner_id.as_str(),
125+
actor_id: self.actor_id.as_deref(),
96126
stream_type: message.stream_type as u8,
97127
ts: message.ts,
98128
message: message.message.as_str(),
@@ -114,7 +144,7 @@ impl LogShipper {
114144
enum VectorMessage<'a> {
115145
#[serde(rename = "actors")]
116146
Actors {
117-
// runner_id: &'a str,
147+
runner_id: &'a str,
118148
actor_id: Option<&'a str>,
119149
stream_type: u8,
120150
ts: u64,

packages/edge/infra/client/echo/Dockerfile

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,16 @@ RUN useradd -m -d /home/nonroot -s /bin/sh nonroot
1717
RUN grep nonroot /etc/passwd > /passwd && \
1818
grep nonroot /etc/group > /group
1919

20-
USER nonroot
21-
22-
CMD ["/app/dist/pegboard-echo-server"]
20+
# Create an empty image and copy binaries into it to minimize the size of the image
21+
FROM scratch
2322

24-
# # Create an empty image and copy binaries into it to minimize the size of the image
25-
# FROM scratch
23+
# Copy passwd and group files
24+
COPY --from=rust /passwd /etc/passwd
25+
COPY --from=rust /group /etc/group
2626

27-
# # Copy passwd and group files
28-
# COPY --from=rust /passwd /etc/passwd
29-
# COPY --from=rust /group /etc/group
27+
COPY --from=rust /app/dist/ /
3028

31-
# COPY --from=rust /app/dist/ /
32-
33-
# # Switch to the non-root user
34-
# USER nonroot
29+
# Switch to the non-root user
30+
USER nonroot
3531

36-
# CMD ["/pegboard-echo-server"]
32+
CMD ["/pegboard-echo-server"]

packages/edge/infra/client/echo/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn encode_frame<T: Serialize>(payload: &T) -> Result<Bytes> {
143143
let mut buf = Vec::with_capacity(4);
144144
let mut cursor = Cursor::new(&mut buf);
145145

146-
cursor.write(&[0u8; 4]); // header (currently unused)
146+
cursor.write(&[0u8; 4])?; // header (currently unused)
147147

148148
serde_json::to_writer(&mut cursor, payload)?;
149149

0 commit comments

Comments
 (0)