Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

Commit 1e3dec7

Browse files
authored
fix: improve orion/orion-server dev builds (#2047)
- Make orion compile on macOS by gating scorpiofs/Linux-only Antares code
1 parent 5da8a68 commit 1e3dec7

10 files changed

Lines changed: 526 additions & 379 deletions

File tree

‎.dockerignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ ztm_agent_db*
3737
# buck2 out
3838
buck-out
3939

40+
# local docker build cache (huge, never needed in image)
41+
.buildx-cache
42+
.buildx-cache/**
43+
4044
# Dockderfile
4145
docker
4246

‎ceres/src/pack/import_repo.rs‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,29 @@ impl ImportRepo {
459459
let mono_api_service: MonoApiService = self.into();
460460
let storage = self.storage.mono_storage();
461461

462+
// Import tip commit + message do not depend on monorepo root; load once so retries
463+
// under the root lock do not repeat git_db reads.
464+
let latest_commit: Commit = Commit::from_git_model(
465+
self.storage
466+
.git_db_storage()
467+
.get_commit_by_hash(self.repo.repo_id, &commit_id)
468+
.await?
469+
.ok_or_else(|| MegaError::Other(format!("commit {commit_id} not found")))?,
470+
);
471+
let commit_msg = latest_commit.format_message();
472+
462473
// Concurrent attaches need CAS on root mega_refs; retry when head moved.
474+
// Redis lock reduces retry storms; DB still enforces correctness via StaleMonorepoRootRef.
475+
//
476+
// `search_and_create_tree` walks the live root tree via the API (`get_root_tree`); it must
477+
// run against the same root snapshot as `get_main_ref` for this attempt, so it stays
478+
// inside the locked section. Further reduction would require threading an explicit root
479+
// tree/commit into `tree_ops` so tree building can run without holding the global lock.
463480
const MAX_ATTACH_ATTEMPTS: u32 = 64;
464481
let mut root_lock_wait_max_ms: u128 = 0;
465482
let mut root_lock_wait_sum_ms: u128 = 0;
466483

467484
for attempt in 0..MAX_ATTACH_ATTEMPTS {
468-
// Only the root mega_refs update needs cross-repo serialization.
469-
// Keep the lock scope as small as possible: just the root ref read + attach transaction.
470485
let t_lock = Instant::now();
471486
let guard = self.unpack_redlock.clone().lock().await?;
472487
let lock_wait_ms = t_lock.elapsed().as_millis();
@@ -483,15 +498,6 @@ impl ImportRepo {
483498

484499
let save_trees = tree_ops::search_and_create_tree(&mono_api_service, &path).await?;
485500

486-
let latest_commit: Commit = Commit::from_git_model(
487-
self.storage
488-
.git_db_storage()
489-
.get_commit_by_hash(self.repo.repo_id, &commit_id)
490-
.await?
491-
.ok_or_else(|| MegaError::Other(format!("commit {} not found", commit_id)))?,
492-
);
493-
494-
let commit_msg = latest_commit.format_message();
495501
let new_commit = Commit::from_tree_id(
496502
save_trees
497503
.back()

‎orion-server/Dockerfile‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ COPY . .
4545

4646
# -- Step 2: build binary into normal target directory
4747
ENV CARGO_TARGET_DIR=/app/target
48-
RUN cargo build -p orion-server --release
48+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
49+
--mount=type=cache,target=/usr/local/cargo/git \
50+
--mount=type=cache,target=/app/target \
51+
cargo build -p orion-server --release
4952

5053
# ────── Stage 3: Runtime ──────
5154
FROM debian:bookworm-slim

‎orion-server/src/main.rs‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::io::IsTerminal;
12
/// Orion Build Server
23
/// A distributed build system that manages build tasks and worker nodes
34
use std::path::PathBuf;
@@ -23,27 +24,33 @@ fn init_tracing_from_config() {
2324
cli_path: None,
2425
env_path: std::env::var_os("MEGA_CONFIG").map(PathBuf::from),
2526
};
26-
let level = match ConfigLoader::new(input).load() {
27+
let (level, with_ansi) = match ConfigLoader::new(input).load() {
2728
Ok(loaded) => match loaded.path.to_str() {
2829
Some(p) => match Config::new(p) {
29-
Ok(cfg) => tracing_level_from_config(&cfg.log.level),
30+
Ok(cfg) => (
31+
tracing_level_from_config(&cfg.log.level),
32+
cfg.log.with_ansi && std::io::stdout().is_terminal(),
33+
),
3034
Err(e) => {
3135
eprintln!("Failed to parse config for log level: {e}; using info");
32-
tracing::Level::INFO
36+
(tracing::Level::INFO, std::io::stdout().is_terminal())
3337
}
3438
},
3539
None => {
3640
eprintln!("Config path is not valid UTF-8; using info");
37-
tracing::Level::INFO
41+
(tracing::Level::INFO, std::io::stdout().is_terminal())
3842
}
3943
},
4044
Err(e) => {
4145
eprintln!("Failed to locate config for log level: {e}; using info");
42-
tracing::Level::INFO
46+
(tracing::Level::INFO, std::io::stdout().is_terminal())
4347
}
4448
};
4549

46-
tracing_subscriber::fmt().with_max_level(level).init();
50+
tracing_subscriber::fmt()
51+
.with_max_level(level)
52+
.with_ansi(with_ansi)
53+
.init();
4754
}
4855

4956
#[tokio::main]

‎orion-server/src/service/ws_service.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ async fn process_message(
148148
}
149149
}
150150
}
151+
WSMessage::TaskAck {
152+
build_id,
153+
success,
154+
message,
155+
} => {
156+
tracing::info!(
157+
"TaskAck from worker {current_worker_id}: build_id={build_id} success={success} message={message}"
158+
);
159+
}
151160
WSMessage::TaskBuildOutput { build_id, output } => {
152161
if let Some(build_info) = state.scheduler.active_builds.get(&build_id) {
153162
let log_event = LogEvent {

‎orion/Cargo.toml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ td_util_buck = { path = "./buck" }
3030
thiserror = { workspace = true }
3131
utoipa.workspace = true
3232
common = { path = "../common" }
33-
scorpiofs = "0.2.1"
3433
tokio-util = { workspace = true }
3534

3635
[dev-dependencies]
3736
serial_test = { workspace = true }
3837
tempfile = { workspace = true }
38+
39+
[target.'cfg(target_os = "linux")'.dependencies]
40+
scorpiofs = "0.2.1"

0 commit comments

Comments
 (0)