libstore: remove Store::registerDrvOutput

it's only used by the RegisterDrvOutput daemon wire operation now, and
that one we can safely stub out to throw an error when called instead.

Change-Id: If29716976392c9c7a2a05b151dfe80b2c8d9c07d
This commit is contained in:
eldritch horrors
2025-05-20 17:43:46 +00:00
parent f25dc923ca
commit 1cbb6ba21c
8 changed files with 1 additions and 140 deletions
-11
View File
@@ -520,17 +520,6 @@ try {
co_return result::current_exception();
}
kj::Promise<Result<void>> BinaryCacheStore::registerDrvOutput(const Realisation& info)
try {
if (diskCache)
diskCache->upsertRealisation(getUri(), info);
auto filePath = realisationsPrefix + "/" + info.id.to_string() + ".doi";
upsertFile(filePath, info.toJSON().dump(), "application/json");
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
ref<FSAccessor> BinaryCacheStore::getFSAccessor()
{
return make_ref<RemoteFSAccessor>(ref<Store>(*this), config().localNarCache);
-2
View File
@@ -146,8 +146,6 @@ public:
const StorePathSet & references,
RepairFlag repair) override;
kj::Promise<Result<void>> registerDrvOutput(const Realisation & info) override;
kj::Promise<Result<std::shared_ptr<const Realisation>>>
queryRealisationUncached(const DrvOutput &) override;
+1 -12
View File
@@ -947,18 +947,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
}
case WorkerProto::Op::RegisterDrvOutput: {
logger->startWork();
if (GET_PROTOCOL_MINOR(clientVersion) < 31) {
auto outputId = DrvOutput::parse(readString(from));
auto outputPath = StorePath(readString(from));
aio.blockOn(store->registerDrvOutput(Realisation{
.id = outputId, .outPath = outputPath}));
} else {
auto realisation = WorkerProto::Serialise<Realisation>::read(*store, rconn);
aio.blockOn(store->registerDrvOutput(realisation));
}
logger->stopWork();
break;
throw UnimplementedError("ca derivations are not supported");
}
case WorkerProto::Op::QueryRealisation: {
-76
View File
@@ -766,82 +766,6 @@ void canonicalisePathMetaData(const Path & path,
}
kj::Promise<Result<void>>
LocalStore::registerDrvOutput(const Realisation & info, CheckSigsFlag checkSigs)
try {
experimentalFeatureSettings.require(Xp::CaDerivations);
if (checkSigs == NoCheckSigs || !realisationIsUntrusted(info))
TRY_AWAIT(registerDrvOutput(info));
else
throw Error("cannot register realisation '%s' because it lacks a signature by a trusted key", info.outPath.to_string());
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
kj::Promise<Result<void>> LocalStore::registerDrvOutput(const Realisation & info)
try {
experimentalFeatureSettings.require(Xp::CaDerivations);
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
TRY_AWAIT(retrySQLite([&]() -> kj::Promise<Result<void>> {
try {
auto state = co_await _dbState.lock();
if (auto oldR = queryRealisation_(*state, info.id)) {
if (info.isCompatibleWith(*oldR)) {
auto combinedSignatures = oldR->signatures;
combinedSignatures.insert(info.signatures.begin(),
info.signatures.end());
state->stmts->UpdateRealisedOutput.use()
(concatStringsSep(" ", combinedSignatures))
(info.id.strHash())
(info.id.outputName)
.exec();
} else {
throw Error("Trying to register a realisation of '%s', but we already "
"have another one locally.\n"
"Local: %s\n"
"Remote: %s",
info.id.to_string(),
printStorePath(oldR->outPath),
printStorePath(info.outPath)
);
}
} else {
state->stmts->RegisterRealisedOutput.use()
(info.id.strHash())
(info.id.outputName)
(printStorePath(info.outPath))
(concatStringsSep(" ", info.signatures))
.exec();
}
for (auto & [outputId, depPath] : info.dependentRealisations) {
auto localRealisation = queryRealisationCore_(*state, outputId);
if (!localRealisation)
throw Error("unable to register the derivation '%s' as it "
"depends on the non existent '%s'",
info.id.to_string(), outputId.to_string());
if (localRealisation->second.outPath != depPath)
throw Error("unable to register the derivation '%s' as it "
"depends on a realisation of '%s' that doesnt"
"match what we have locally",
info.id.to_string(), outputId.to_string());
state->stmts->AddRealisationReference.use()
(info.id.strHash())
(info.id.outputName)
(outputId.strHash())
(outputId.outputName)
.exec();
}
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
}));
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
void LocalStore::cacheDrvOutputMapping(
DBState & state,
const uint64_t deriver,
-3
View File
@@ -319,9 +319,6 @@ public:
* Register the store path 'output' as the output named 'outputName' of
* derivation 'deriver'.
*/
kj::Promise<Result<void>> registerDrvOutput(const Realisation & info) override;
kj::Promise<Result<void>>
registerDrvOutput(const Realisation & info, CheckSigsFlag checkSigs) override;
void cacheDrvOutputMapping(
DBState & state,
const uint64_t deriver,
-17
View File
@@ -603,23 +603,6 @@ try {
co_return result::current_exception();
}
kj::Promise<Result<void>> RemoteStore::registerDrvOutput(const Realisation & info)
try {
auto conn(TRY_AWAIT(getConnection()));
conn->to << WorkerProto::Op::RegisterDrvOutput;
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) {
REMOVE_AFTER_DROPPING_PROTO_MINOR(30);
conn->to << info.id.to_string();
conn->to << std::string(info.outPath.to_string());
} else {
conn->to << WorkerProto::write(*this, *conn, info);
}
conn.processStderr();
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
kj::Promise<Result<std::shared_ptr<const Realisation>>>
RemoteStore::queryRealisationUncached(const DrvOutput & id)
try {
-2
View File
@@ -117,8 +117,6 @@ public:
const StorePathSet & references,
RepairFlag repair) override;
kj::Promise<Result<void>> registerDrvOutput(const Realisation & info) override;
kj::Promise<Result<std::shared_ptr<const Realisation>>>
queryRealisationUncached(const DrvOutput &) override;
-17
View File
@@ -592,23 +592,6 @@ public:
const StorePathSet & references,
RepairFlag repair = NoRepair) = 0;
/**
* Add a mapping indicating that `deriver!outputName` maps to the output path
* `output`.
*
* This is redundant for known-input-addressed and fixed-output derivations
* as this information is already present in the drv file, but necessary for
* floating-ca derivations and their dependencies as there's no way to
* retrieve this information otherwise.
*/
virtual kj::Promise<Result<void>> registerDrvOutput(const Realisation & output)
try { unsupported("registerDrvOutput"); } catch (...) { return {result::current_exception()}; }
virtual kj::Promise<Result<void>>
registerDrvOutput(const Realisation & output, CheckSigsFlag checkSigs)
{
return registerDrvOutput(output);
}
/**
* Generate a NAR dump of a store path.
*/