Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ ztm_agent_db*
# buck2 out
buck-out

# local docker build cache (huge, never needed in image)
.buildx-cache
.buildx-cache/**

# Dockderfile
docker

Expand Down
28 changes: 17 additions & 11 deletions ceres/src/pack/import_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,29 @@ impl ImportRepo {
let mono_api_service: MonoApiService = self.into();
let storage = self.storage.mono_storage();

// Import tip commit + message do not depend on monorepo root; load once so retries
// under the root lock do not repeat git_db reads.
let latest_commit: Commit = Commit::from_git_model(
self.storage
.git_db_storage()
.get_commit_by_hash(self.repo.repo_id, &commit_id)
.await?
.ok_or_else(|| MegaError::Other(format!("commit {commit_id} not found")))?,
);
let commit_msg = latest_commit.format_message();

// Concurrent attaches need CAS on root mega_refs; retry when head moved.
// Redis lock reduces retry storms; DB still enforces correctness via StaleMonorepoRootRef.
//
// `search_and_create_tree` walks the live root tree via the API (`get_root_tree`); it must
// run against the same root snapshot as `get_main_ref` for this attempt, so it stays
// inside the locked section. Further reduction would require threading an explicit root
// tree/commit into `tree_ops` so tree building can run without holding the global lock.
const MAX_ATTACH_ATTEMPTS: u32 = 64;
let mut root_lock_wait_max_ms: u128 = 0;
let mut root_lock_wait_sum_ms: u128 = 0;

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

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

let latest_commit: Commit = Commit::from_git_model(
self.storage
.git_db_storage()
.get_commit_by_hash(self.repo.repo_id, &commit_id)
.await?
.ok_or_else(|| MegaError::Other(format!("commit {} not found", commit_id)))?,
);

let commit_msg = latest_commit.format_message();
let new_commit = Commit::from_tree_id(
save_trees
.back()
Expand Down
5 changes: 4 additions & 1 deletion orion-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ COPY . .

# -- Step 2: build binary into normal target directory
ENV CARGO_TARGET_DIR=/app/target
RUN cargo build -p orion-server --release
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/app/target \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Persist build artifact outside cache mount

The cargo build step writes /app/target into a BuildKit type=cache mount, which is not part of the committed image filesystem after the RUN completes. That means the later COPY --from=builder /app/target/release/orion-server ... can fail on clean builders because the binary is not present in the stage snapshot. Keep dependency caches mounted, but write/copy the final binary to a non-mounted path before the step ends.

Useful? React with 👍 / 👎.

cargo build -p orion-server --release

# ────── Stage 3: Runtime ──────
FROM debian:bookworm-slim
Expand Down
19 changes: 13 additions & 6 deletions orion-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::io::IsTerminal;
/// Orion Build Server
/// A distributed build system that manages build tasks and worker nodes
use std::path::PathBuf;
Expand All @@ -23,27 +24,33 @@ fn init_tracing_from_config() {
cli_path: None,
env_path: std::env::var_os("MEGA_CONFIG").map(PathBuf::from),
};
let level = match ConfigLoader::new(input).load() {
let (level, with_ansi) = match ConfigLoader::new(input).load() {
Ok(loaded) => match loaded.path.to_str() {
Some(p) => match Config::new(p) {
Ok(cfg) => tracing_level_from_config(&cfg.log.level),
Ok(cfg) => (
tracing_level_from_config(&cfg.log.level),
cfg.log.with_ansi && std::io::stdout().is_terminal(),
),
Err(e) => {
eprintln!("Failed to parse config for log level: {e}; using info");
tracing::Level::INFO
(tracing::Level::INFO, std::io::stdout().is_terminal())
}
},
None => {
eprintln!("Config path is not valid UTF-8; using info");
tracing::Level::INFO
(tracing::Level::INFO, std::io::stdout().is_terminal())
}
},
Err(e) => {
eprintln!("Failed to locate config for log level: {e}; using info");
tracing::Level::INFO
(tracing::Level::INFO, std::io::stdout().is_terminal())
}
};

tracing_subscriber::fmt().with_max_level(level).init();
tracing_subscriber::fmt()
.with_max_level(level)
.with_ansi(with_ansi)
.init();
}

#[tokio::main]
Expand Down
9 changes: 9 additions & 0 deletions orion-server/src/service/ws_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ async fn process_message(
}
}
}
WSMessage::TaskAck {
build_id,
success,
message,
} => {
tracing::info!(
"TaskAck from worker {current_worker_id}: build_id={build_id} success={success} message={message}"
);
}
WSMessage::TaskBuildOutput { build_id, output } => {
if let Some(build_info) = state.scheduler.active_builds.get(&build_id) {
let log_event = LogEvent {
Expand Down
4 changes: 3 additions & 1 deletion orion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ td_util_buck = { path = "./buck" }
thiserror = { workspace = true }
utoipa.workspace = true
common = { path = "../common" }
scorpiofs = "0.2.1"
tokio-util = { workspace = true }

[dev-dependencies]
serial_test = { workspace = true }
tempfile = { workspace = true }

[target.'cfg(target_os = "linux")'.dependencies]
scorpiofs = "0.2.1"
Loading
Loading