feat(nix-daemon): Implement stubs for QueryReferrers, QueryRealizations

These are required to support certain nix's local-overlay store
operations, it's safer to return empty results for these
operations than failing with "operation not implemented" errors.

Change-Id: Ic9b69d75dd52af5a826bfb6a8b283b082a0f6bcf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12766
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
Vova Kryachko 2024-11-12 12:30:47 -05:00 committed by Vladimir Kryachko
parent fa9c067dc9
commit ccecede70b

View file

@ -5,7 +5,7 @@ use tokio::{
io::{split, AsyncReadExt, AsyncWriteExt, ReadHalf, WriteHalf},
sync::Mutex,
};
use tracing::debug;
use tracing::{debug, warn};
use super::{
types::QueryValidPaths,
@ -146,6 +146,23 @@ where
let path: StorePath<String> = self.reader.read_value().await?;
self.handle(io.query_valid_derivers(&path)).await?
}
// FUTUREWORK: These are just stubs that return an empty list.
// It's important not to return an error for the local-overlay:// store
// to work properly. While it will not see certain referrers and realizations
// it will not fail on various operations like gc and optimize store. At the
// same time, returning an empty list here shouldn't break any of local-overlay store's
// invariants.
Operation::QueryReferrers | Operation::QueryRealisation => {
let _: String = self.reader.read_value().await?;
self.handle(async move {
warn!(
?operation,
"This operation is not implemented. Returning empty result..."
);
Ok(Vec::<StorePath<String>>::new())
})
.await?
}
_ => {
return Err(std::io::Error::other(format!(
"Operation {operation:?} is not implemented"