Skip to content

various: fix closure narinfo cache#129

Open
pieter0101 wants to merge 5 commits into
mainfrom
fix/closure-narinfo-cache
Open

various: fix closure narinfo cache#129
pieter0101 wants to merge 5 commits into
mainfrom
fix/closure-narinfo-cache

Conversation

@pieter0101

Copy link
Copy Markdown
Contributor

Publish signed narinfos for successful build output closures so Circus can serve every recorded dependency from its cache.

Comment thread crates/queue-runner/src/worker.rs Outdated
Some(format!("nar/{nar_hash}.nar?hash={output_hash}"))
}

async fn sign_narinfo_fingerprint(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems to duplicate sign_fingerprint. Both implement identical Ed25519 signing (fingerprint 1;path;narhash;size;refs) and any potential format changes would have to be applied in two places. Please move shared logic into circus_common or circus_nix.

project_id: Option<Uuid>,
) {
let key_file = match &signing_config.key_file {
Some(kf) if signing_config.enabled && kf.exists() => kf,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This reads the signing key from disk once per closure path. Read once at the top of persist_closure_narinfos_with_nix and pass the parsed key down.

Comment thread crates/queue-runner/src/runner_loop.rs Outdated
Comment on lines +287 to +291
publish_succeeded_output_closure(
&pool,
&worker_pool,
build.id,
output_path,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We seem to be passing existing.build_output_path (singular) to publish_succeeded_output_closure. For derivations with multiple outputs, only the first output gets its closure cached.

Comment thread crates/server/src/routes/cache.rs Outdated
Comment on lines +326 to +329
if has_signed_persisted_narinfo(pool, &store_path, scope.project_id()).await?
{
return Ok(true);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If a .drv path ended up in narinfo_cache with a signature, it would bypass the explicit drv check and the CA branch. You can move the check after the drv gate.

@NotAShelf NotAShelf changed the title Fix/closure narinfo cache varioıs: fix closure narinfo cache Jun 27, 2026
.filter(|hash| !hash.is_empty())
}

fn canonical_nix_sha256_hash(text: &str) -> Option<String> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

canonical_nix_sha256_hash returns None silently for unrecognized formats, which means entries are silently dropped from the closure. This is not breaking but for the sake of being explicit we should log with tracing::warn! here.

}

#[tokio::test]
async fn test_persist_closure_narinfos_records_dependency_closure() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Leaves jobset/evaluation/build rows in the test database...

output_path: &str,
) {
let project_id = match repo::builds::get(pool, build_id).await {
Ok(build) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should log when get_project_for_build returns None instead of only logging the Err branch.

@NotAShelf NotAShelf changed the title varioıs: fix closure narinfo cache various: fix closure narinfo cache Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants