libstore: remove realisation query support

only a daemon wire operation and the perl bindings could initiate these
queries at this point. the daemon ops can throw an error instead (as if
the daemon were older) and realistically should never be queries if the
client hasn't evaluated a ca derivation on a given store, and perl code
is best off dying early. nothing known except hydra uses these bdingins
anyway, and we control our hydra so we don't need backward compat code.

Change-Id: Ia7df27aba59a4a4a692ae014f407415f3bea63f2
This commit is contained in:
eldritch horrors
2025-05-20 17:43:46 +00:00
parent aa69d39c0f
commit 976f6de81e
15 changed files with 2 additions and 257 deletions
-15
View File
@@ -505,21 +505,6 @@ try {
co_return result::current_exception();
}
kj::Promise<Result<std::shared_ptr<const Realisation>>>
BinaryCacheStore::queryRealisationUncached(const DrvOutput & id)
try {
auto outputInfoFilePath = realisationsPrefix + "/" + id.to_string() + ".doi";
auto data = getFileContents(outputInfoFilePath);
if (!data) co_return result::success(nullptr);
auto realisation = Realisation::fromJSON(
json::parse(*data), outputInfoFilePath);
co_return std::make_shared<const Realisation>(realisation);
} catch (...) {
co_return result::current_exception();
}
ref<FSAccessor> BinaryCacheStore::getFSAccessor()
{
return make_ref<RemoteFSAccessor>(ref<Store>(*this), config().localNarCache);
-3
View File
@@ -146,9 +146,6 @@ public:
const StorePathSet & references,
RepairFlag repair) override;
kj::Promise<Result<std::shared_ptr<const Realisation>>>
queryRealisationUncached(const DrvOutput &) override;
kj::Promise<Result<box_ptr<Source>>> narFromPath(const StorePath & path) override;
ref<FSAccessor> getFSAccessor() override;
+2 -18
View File
@@ -946,25 +946,9 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
break;
}
case WorkerProto::Op::RegisterDrvOutput: {
throw UnimplementedError("ca derivations are not supported");
}
case WorkerProto::Op::RegisterDrvOutput:
case WorkerProto::Op::QueryRealisation: {
logger->startWork();
auto outputId = DrvOutput::parse(readString(from));
auto info = aio.blockOn(store->queryRealisation(outputId));
logger->stopWork();
if (GET_PROTOCOL_MINOR(clientVersion) < 31) {
std::set<StorePath> outPaths;
if (info) outPaths.insert(info->outPath);
to << WorkerProto::write(*store, wconn, outPaths);
} else {
std::set<Realisation> realisations;
if (info) realisations.insert(*info);
to << WorkerProto::write(*store, wconn, realisations);
}
break;
throw UnimplementedError("ca derivations are not supported");
}
case WorkerProto::Op::AddBuildLog: {
-4
View File
@@ -74,10 +74,6 @@ struct DummyStore final : public Store
kj::Promise<Result<box_ptr<Source>>> narFromPath(const StorePath & path) override
try { unsupported("narFromPath"); } catch (...) { return {result::current_exception()}; }
kj::Promise<Result<std::shared_ptr<const Realisation>>>
queryRealisationUncached(const DrvOutput &) override
{ co_return result::success(nullptr); }
virtual ref<FSAccessor> getFSAccessor() override
{ unsupported("getFSAccessor"); }
};
-5
View File
@@ -463,11 +463,6 @@ public:
{
return {result::success(std::nullopt)};
}
kj::Promise<Result<std::shared_ptr<const Realisation>>>
queryRealisationUncached(const DrvOutput &) override
// TODO: Implement
try { unsupported("queryRealisation"); } catch (...) { co_return result::current_exception(); }
};
void registerLegacySSHStore() {
-75
View File
@@ -1841,81 +1841,6 @@ void LocalStore::signPathInfo(ValidPathInfo & info)
}
std::optional<std::pair<int64_t, Realisation>> LocalStore::queryRealisationCore_(
LocalStore::DBState & state,
const DrvOutput & id)
{
auto useQueryRealisedOutput(
state.stmts->QueryRealisedOutput.use()
(id.strHash())
(id.outputName));
if (!useQueryRealisedOutput.next())
return std::nullopt;
auto realisationDbId = useQueryRealisedOutput.getInt(0);
auto outputPath = parseStorePath(useQueryRealisedOutput.getStr(1));
auto signatures =
tokenizeString<StringSet>(useQueryRealisedOutput.getStr(2));
return {{
realisationDbId,
Realisation{
.id = id,
.outPath = outputPath,
.signatures = signatures,
}
}};
}
std::optional<const Realisation> LocalStore::queryRealisation_(
LocalStore::DBState & state,
const DrvOutput & id)
{
auto maybeCore = queryRealisationCore_(state, id);
if (!maybeCore)
return std::nullopt;
auto [realisationDbId, res] = *maybeCore;
std::map<DrvOutput, StorePath> dependentRealisations;
auto useRealisationRefs(
state.stmts->QueryRealisationReferences.use()
(realisationDbId));
while (useRealisationRefs.next()) {
auto depId = DrvOutput {
Hash::parseAnyPrefixed(useRealisationRefs.getStr(0)),
useRealisationRefs.getStr(1),
};
auto dependentRealisation = queryRealisationCore_(state, depId);
assert(dependentRealisation); // Enforced by the db schema
auto outputPath = dependentRealisation->second.outPath;
dependentRealisations.insert({depId, outputPath});
}
res.dependentRealisations = dependentRealisations;
return { res };
}
kj::Promise<Result<std::shared_ptr<const Realisation>>>
LocalStore::queryRealisationUncached(const DrvOutput & id)
try {
auto maybeRealisation =
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
TRY_AWAIT(retrySQLite([&]() -> kj::Promise<Result<std::optional<const Realisation>>> {
try {
auto state = co_await _dbState.lock();
co_return queryRealisation_(*state, id);
} catch (...) {
co_return result::current_exception();
}
}));
if (maybeRealisation)
co_return std::make_shared<const Realisation>(maybeRealisation.value());
else
co_return result::success(nullptr);
} catch (...) {
co_return result::current_exception();
}
ContentAddress LocalStore::hashCAPath(
const ContentAddressMethod & method, const HashType & hashType,
const StorePath & path)
-5
View File
@@ -325,11 +325,6 @@ public:
const std::string & outputName,
const StorePath & output);
std::optional<const Realisation> queryRealisation_(DBState & state, const DrvOutput & id);
std::optional<std::pair<int64_t, Realisation>> queryRealisationCore_(DBState & state, const DrvOutput & id);
kj::Promise<Result<std::shared_ptr<const Realisation>>>
queryRealisationUncached(const DrvOutput&) override;
kj::Promise<Result<std::optional<std::string>>> getVersion() override;
private:
-37
View File
@@ -24,43 +24,6 @@ std::string DrvOutput::to_string() const {
return strHash() + "!" + outputName;
}
kj::Promise<Result<std::set<Realisation>>>
Realisation::closure(Store & store, const std::set<Realisation> & startOutputs)
try {
std::set<Realisation> res;
TRY_AWAIT(Realisation::closure(store, startOutputs, res));
co_return res;
} catch (...) {
co_return result::current_exception();
}
kj::Promise<Result<void>> Realisation::closure(
Store & store, const std::set<Realisation> & startOutputs, std::set<Realisation> & res
)
try {
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
auto getDeps = [&](const Realisation& current) -> kj::Promise<Result<std::set<Realisation>>> {
try {
std::set<Realisation> res;
for (auto& [currentDep, _] : current.dependentRealisations) {
if (auto currentRealisation = TRY_AWAIT(store.queryRealisation(currentDep)))
res.insert(*currentRealisation);
else
throw Error(
"Unrealised derivation '%s'", currentDep.to_string());
}
co_return res;
} catch (...) {
co_return result::current_exception();
}
};
res.merge(TRY_AWAIT(computeClosureAsync<Realisation>(startOutputs, getDeps)));
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
JSON Realisation::toJSON() const {
auto jsonDependentRealisations = JSON::object();
for (auto & [depId, depOutPath] : dependentRealisations)
-5
View File
@@ -68,11 +68,6 @@ struct Realisation {
bool checkSignature(const PublicKeys & publicKeys, const std::string & sig) const;
size_t checkSignatures(const PublicKeys & publicKeys) const;
static kj::Promise<Result<std::set<Realisation>>>
closure(Store &, const std::set<Realisation> &);
static kj::Promise<Result<void>>
closure(Store &, const std::set<Realisation> &, std::set<Realisation> & res);
bool isCompatibleWith(const Realisation & other) const;
StorePath getPath() const { return outPath; }
-33
View File
@@ -603,39 +603,6 @@ try {
co_return result::current_exception();
}
kj::Promise<Result<std::shared_ptr<const Realisation>>>
RemoteStore::queryRealisationUncached(const DrvOutput & id)
try {
auto conn(TRY_AWAIT(getConnection()));
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 27) {
warn("the daemon is too old to support content-addressed derivations, please upgrade it to 2.4");
co_return result::success(nullptr);
}
conn->to << WorkerProto::Op::QueryRealisation;
conn->to << id.to_string();
conn.processStderr();
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) {
auto outPaths = WorkerProto::Serialise<std::set<StorePath>>::read(
*this, *conn);
if (outPaths.empty())
co_return result::success(nullptr);
co_return std::make_shared<const Realisation>(
Realisation{.id = id, .outPath = *outPaths.begin()}
);
} else {
auto realisations = WorkerProto::Serialise<std::set<Realisation>>::read(
*this, *conn);
if (realisations.empty())
co_return result::success(nullptr);
co_return std::make_shared<const Realisation>(*realisations.begin());
}
} catch (...) {
co_return result::current_exception();
}
kj::Promise<Result<void>> RemoteStore::copyDrvsFromEvalStore(
const std::vector<DerivedPath> & paths,
std::shared_ptr<Store> evalStore)
-3
View File
@@ -117,9 +117,6 @@ public:
const StorePathSet & references,
RepairFlag repair) override;
kj::Promise<Result<std::shared_ptr<const Realisation>>>
queryRealisationUncached(const DrvOutput &) override;
kj ::Promise<Result<void>> buildPaths(
const std::vector<DerivedPath> & paths,
BuildMode buildMode,
-34
View File
@@ -733,40 +733,6 @@ try {
co_return result::current_exception();
}
kj::Promise<Result<std::shared_ptr<const Realisation>>> Store::queryRealisation(const DrvOutput & id)
try {
if (diskCache) {
auto [cacheOutcome, maybeCachedRealisation]
= diskCache->lookupRealisation(getUri(), id);
switch (cacheOutcome) {
case NarInfoDiskCache::oValid:
debug("Returning a cached realisation for %s", id.to_string());
co_return maybeCachedRealisation;
case NarInfoDiskCache::oInvalid:
debug(
"Returning a cached missing realisation for %s",
id.to_string());
co_return result::success(nullptr);
case NarInfoDiskCache::oUnknown:
break;
}
}
auto info = TRY_AWAIT(queryRealisationUncached(id));
if (diskCache) {
if (info)
diskCache->upsertRealisation(getUri(), *info);
else
diskCache->upsertAbsentRealisation(getUri(), id);
}
co_return info;
} catch (...) {
co_return result::current_exception();
}
kj::Promise<Result<void>> Store::substitutePaths(const StorePathSet & paths)
try {
std::vector<DerivedPath> paths2;
-7
View File
@@ -392,11 +392,6 @@ public:
*/
kj::Promise<Result<ref<const ValidPathInfo>>> queryPathInfo(const StorePath & path);
/**
* Query the information about a realisation.
*/
kj::Promise<Result<std::shared_ptr<const Realisation>>> queryRealisation(const DrvOutput &);
/**
* Check whether the given valid path info is sufficiently attested, by
@@ -427,8 +422,6 @@ protected:
*/
virtual kj::Promise<Result<std::shared_ptr<const ValidPathInfo>>>
queryPathInfoUncached(const StorePath & path) = 0;
virtual kj::Promise<Result<std::shared_ptr<const Realisation>>>
queryRealisationUncached(const DrvOutput &) = 0;
public:
-1
View File
@@ -22,7 +22,6 @@ our @EXPORT = qw(
derivationFromPath
addTempRoot
getBinDir getStoreDir
queryRawRealisation
);
our $VERSION = '0.15';
-12
View File
@@ -131,18 +131,6 @@ SV * queryPathInfo(char * path, int base32)
croak("%s", e.what());
}
SV * queryRawRealisation(char * outputId)
PPCODE:
try {
auto realisation = aio().blockOn(store()->queryRealisation(DrvOutput::parse(outputId)));
if (realisation)
XPUSHs(sv_2mortal(newSVpv(realisation->toJSON().dump().c_str(), 0)));
else
XPUSHs(sv_2mortal(newSVpv("", 0)));
} catch (Error & e) {
croak("%s", e.what());
}
SV * queryPathFromHashPart(char * hashPart)
PPCODE: