mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 20:16:03 +01:00
Merge pull request #13755 from xokdvium/concise-uri-logs
treewide: Remove getUri and replace with getHumanReadableURI where appropriate
This commit is contained in:
commit
4b4895e750
20 changed files with 118 additions and 69 deletions
|
|
@ -574,14 +574,15 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||||
for (auto & sub : subs) {
|
for (auto & sub : subs) {
|
||||||
auto * logSubP = dynamic_cast<LogStore *>(&*sub);
|
auto * logSubP = dynamic_cast<LogStore *>(&*sub);
|
||||||
if (!logSubP) {
|
if (!logSubP) {
|
||||||
printInfo("Skipped '%s' which does not support retrieving build logs", sub->config.getUri());
|
printInfo(
|
||||||
|
"Skipped '%s' which does not support retrieving build logs", sub->config.getHumanReadableURI());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto & logSub = *logSubP;
|
auto & logSub = *logSubP;
|
||||||
|
|
||||||
auto log = logSub.getBuildLog(drvPath);
|
auto log = logSub.getBuildLog(drvPath);
|
||||||
if (log) {
|
if (log) {
|
||||||
printInfo("got build log for '%s' from '%s'", drvPathRaw, logSub.config.getUri());
|
printInfo("got build log for '%s' from '%s'", drvPathRaw, logSub.config.getHumanReadableURI());
|
||||||
logger->writeToStdout(*log);
|
logger->writeToStdout(*log);
|
||||||
foundLog = true;
|
foundLog = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ nix_err nix_store_get_uri(nix_c_context * context, Store * store, nix_get_string
|
||||||
if (context)
|
if (context)
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
auto res = store->ptr->config.getUri();
|
auto res = store->ptr->config.getReference().render(/*withParams=*/true);
|
||||||
return call_nix_get_string_callback(res, callback, user_data);
|
return call_nix_get_string_callback(res, callback, user_data);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,7 @@ namespace nix {
|
||||||
|
|
||||||
TEST(LegacySSHStore, constructConfig)
|
TEST(LegacySSHStore, constructConfig)
|
||||||
{
|
{
|
||||||
initLibStore(/*loadConfig=*/false);
|
LegacySSHStoreConfig config(
|
||||||
|
|
||||||
auto config = make_ref<LegacySSHStoreConfig>(
|
|
||||||
"ssh",
|
"ssh",
|
||||||
"me@localhost:2222",
|
"me@localhost:2222",
|
||||||
StoreConfig::Params{
|
StoreConfig::Params{
|
||||||
|
|
@ -20,13 +18,13 @@ TEST(LegacySSHStore, constructConfig)
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
config->remoteProgram.get(),
|
config.remoteProgram.get(),
|
||||||
(Strings{
|
(Strings{
|
||||||
"foo",
|
"foo",
|
||||||
"bar",
|
"bar",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
auto store = config->openStore();
|
EXPECT_EQ(config.getReference().render(/*withParams=*/true), "ssh://me@localhost:2222?remote-program=foo%20bar");
|
||||||
EXPECT_EQ(store->config.getUri(), "ssh://me@localhost:2222?remote-program=foo%20bar");
|
EXPECT_EQ(config.getReference().render(/*withParams=*/false), "ssh://me@localhost:2222");
|
||||||
}
|
}
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ TEST_F(nix_api_util_context, nix_store_open_dummy)
|
||||||
nix_libstore_init(ctx);
|
nix_libstore_init(ctx);
|
||||||
Store * store = nix_store_open(ctx, "dummy://", nullptr);
|
Store * store = nix_store_open(ctx, "dummy://", nullptr);
|
||||||
ASSERT_EQ(NIX_OK, ctx->last_err_code);
|
ASSERT_EQ(NIX_OK, ctx->last_err_code);
|
||||||
ASSERT_STREQ("dummy://", store->ptr->config.getUri().c_str());
|
ASSERT_STREQ("dummy://", store->ptr->config.getReference().render(/*withParams=*/true).c_str());
|
||||||
|
|
||||||
std::string str;
|
std::string str;
|
||||||
nix_store_get_version(ctx, store, OBSERVE_STRING(str));
|
nix_store_get_version(ctx, store, OBSERVE_STRING(str));
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ TEST(SSHStore, constructConfig)
|
||||||
"bar",
|
"bar",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
EXPECT_EQ(config.getUri(), "ssh-ng://me@localhost:2222?remote-program=foo%20bar");
|
EXPECT_EQ(config.getReference().render(/*withParams=*/true), "ssh-ng://me@localhost:2222?remote-program=foo%20bar");
|
||||||
config.resetOverridden();
|
config.resetOverridden();
|
||||||
EXPECT_EQ(config.getUri(), "ssh-ng://me@localhost:2222");
|
EXPECT_EQ(config.getReference().render(/*withParams=*/true), "ssh-ng://me@localhost:2222");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MountedSSHStore, constructConfig)
|
TEST(MountedSSHStore, constructConfig)
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ void BinaryCacheStore::init()
|
||||||
if (value != storeDir)
|
if (value != storeDir)
|
||||||
throw Error(
|
throw Error(
|
||||||
"binary cache '%s' is for Nix stores with prefix '%s', not '%s'",
|
"binary cache '%s' is for Nix stores with prefix '%s', not '%s'",
|
||||||
config.getUri(),
|
config.getHumanReadableURI(),
|
||||||
value,
|
value,
|
||||||
storeDir);
|
storeDir);
|
||||||
} else if (name == "WantMassQuery") {
|
} else if (name == "WantMassQuery") {
|
||||||
|
|
@ -133,7 +133,9 @@ void BinaryCacheStore::writeNarInfo(ref<NarInfo> narInfo)
|
||||||
|
|
||||||
if (diskCache)
|
if (diskCache)
|
||||||
diskCache->upsertNarInfo(
|
diskCache->upsertNarInfo(
|
||||||
config.getUri(), std::string(narInfo->path.hashPart()), std::shared_ptr<NarInfo>(narInfo));
|
config.getReference().render(/*FIXME withParams=*/false),
|
||||||
|
std::string(narInfo->path.hashPart()),
|
||||||
|
std::shared_ptr<NarInfo>(narInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
|
ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
|
||||||
|
|
@ -431,7 +433,7 @@ void BinaryCacheStore::narFromPath(const StorePath & storePath, Sink & sink)
|
||||||
void BinaryCacheStore::queryPathInfoUncached(
|
void BinaryCacheStore::queryPathInfoUncached(
|
||||||
const StorePath & storePath, Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
|
const StorePath & storePath, Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
|
||||||
{
|
{
|
||||||
auto uri = config.getUri();
|
auto uri = config.getReference().render(/*FIXME withParams=*/false);
|
||||||
auto storePathS = printStorePath(storePath);
|
auto storePathS = printStorePath(storePath);
|
||||||
auto act = std::make_shared<Activity>(
|
auto act = std::make_shared<Activity>(
|
||||||
*logger,
|
*logger,
|
||||||
|
|
@ -531,7 +533,7 @@ void BinaryCacheStore::queryRealisationUncached(
|
||||||
void BinaryCacheStore::registerDrvOutput(const Realisation & info)
|
void BinaryCacheStore::registerDrvOutput(const Realisation & info)
|
||||||
{
|
{
|
||||||
if (diskCache)
|
if (diskCache)
|
||||||
diskCache->upsertRealisation(config.getUri(), info);
|
diskCache->upsertRealisation(config.getReference().render(/*FIXME withParams=*/false), info);
|
||||||
auto filePath = realisationsPrefix + "/" + info.id.to_string() + ".doi";
|
auto filePath = realisationsPrefix + "/" + info.id.to_string() + ".doi";
|
||||||
upsertFile(filePath, info.toJSON().dump(), "application/json");
|
upsertFile(filePath, info.toJSON().dump(), "application/json");
|
||||||
}
|
}
|
||||||
|
|
@ -559,7 +561,7 @@ std::optional<std::string> BinaryCacheStore::getBuildLogExact(const StorePath &
|
||||||
{
|
{
|
||||||
auto logPath = "log/" + std::string(baseNameOf(printStorePath(path)));
|
auto logPath = "log/" + std::string(baseNameOf(printStorePath(path)));
|
||||||
|
|
||||||
debug("fetching build log from binary cache '%s/%s'", config.getUri(), logPath);
|
debug("fetching build log from binary cache '%s/%s'", config.getHumanReadableURI(), logPath);
|
||||||
|
|
||||||
return getFile(logPath);
|
return getFile(logPath);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ Goal::Co DrvOutputSubstitutionGoal::init()
|
||||||
"substituter '%s' has an incompatible realisation for '%s', ignoring.\n"
|
"substituter '%s' has an incompatible realisation for '%s', ignoring.\n"
|
||||||
"Local: %s\n"
|
"Local: %s\n"
|
||||||
"Remote: %s",
|
"Remote: %s",
|
||||||
sub->config.getUri(),
|
sub->config.getHumanReadableURI(),
|
||||||
depId.to_string(),
|
depId.to_string(),
|
||||||
worker.store.printStorePath(localOutputInfo->outPath),
|
worker.store.printStorePath(localOutputInfo->outPath),
|
||||||
worker.store.printStorePath(depPath));
|
worker.store.printStorePath(depPath));
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ Goal::Co PathSubstitutionGoal::init()
|
||||||
} else {
|
} else {
|
||||||
printError(
|
printError(
|
||||||
"asked '%s' for '%s' but got '%s'",
|
"asked '%s' for '%s' but got '%s'",
|
||||||
sub->config.getUri(),
|
sub->config.getHumanReadableURI(),
|
||||||
worker.store.printStorePath(storePath),
|
worker.store.printStorePath(storePath),
|
||||||
sub->printStorePath(info->path));
|
sub->printStorePath(info->path));
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -127,7 +127,7 @@ Goal::Co PathSubstitutionGoal::init()
|
||||||
warn(
|
warn(
|
||||||
"ignoring substitute for '%s' from '%s', as it's not signed by any of the keys in 'trusted-public-keys'",
|
"ignoring substitute for '%s' from '%s', as it's not signed by any of the keys in 'trusted-public-keys'",
|
||||||
worker.store.printStorePath(storePath),
|
worker.store.printStorePath(storePath),
|
||||||
sub->config.getUri());
|
sub->config.getHumanReadableURI());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,7 +218,9 @@ Goal::Co PathSubstitutionGoal::tryToRun(
|
||||||
Finally updateStats([this]() { outPipe.writeSide.close(); });
|
Finally updateStats([this]() { outPipe.writeSide.close(); });
|
||||||
|
|
||||||
Activity act(
|
Activity act(
|
||||||
*logger, actSubstitute, Logger::Fields{worker.store.printStorePath(storePath), sub->config.getUri()});
|
*logger,
|
||||||
|
actSubstitute,
|
||||||
|
Logger::Fields{worker.store.printStorePath(storePath), sub->config.getHumanReadableURI()});
|
||||||
PushActivity pact(act.id);
|
PushActivity pact(act.id);
|
||||||
|
|
||||||
copyStorePath(*sub, worker.store, subPath, repair, sub->config.isTrusted ? NoCheckSigs : CheckSigs);
|
copyStorePath(*sub, worker.store, subPath, repair, sub->config.isTrusted ? NoCheckSigs : CheckSigs);
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ protected:
|
||||||
auto state(_state.lock());
|
auto state(_state.lock());
|
||||||
if (state->enabled && settings.tryFallback) {
|
if (state->enabled && settings.tryFallback) {
|
||||||
int t = 60;
|
int t = 60;
|
||||||
printError("disabling binary cache '%s' for %s seconds", config->getUri(), t);
|
printError("disabling binary cache '%s' for %s seconds", config->getHumanReadableURI(), t);
|
||||||
state->enabled = false;
|
state->enabled = false;
|
||||||
state->disabledUntil = std::chrono::steady_clock::now() + std::chrono::seconds(t);
|
state->disabledUntil = std::chrono::steady_clock::now() + std::chrono::seconds(t);
|
||||||
}
|
}
|
||||||
|
|
@ -111,10 +111,10 @@ protected:
|
||||||
return;
|
return;
|
||||||
if (std::chrono::steady_clock::now() > state->disabledUntil) {
|
if (std::chrono::steady_clock::now() > state->disabledUntil) {
|
||||||
state->enabled = true;
|
state->enabled = true;
|
||||||
debug("re-enabling binary cache '%s'", config->getUri());
|
debug("re-enabling binary cache '%s'", config->getHumanReadableURI());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw SubstituterDisabled("substituter '%s' is disabled", config->getUri());
|
throw SubstituterDisabled("substituter '%s' is disabled", config->getHumanReadableURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fileExists(const std::string & path) override
|
bool fileExists(const std::string & path) override
|
||||||
|
|
@ -180,7 +180,8 @@ protected:
|
||||||
getFileTransfer()->download(std::move(request), sink);
|
getFileTransfer()->download(std::move(request), sink);
|
||||||
} catch (FileTransferError & e) {
|
} catch (FileTransferError & e) {
|
||||||
if (e.error == FileTransfer::NotFound || e.error == FileTransfer::Forbidden)
|
if (e.error == FileTransfer::NotFound || e.error == FileTransfer::Forbidden)
|
||||||
throw NoSuchBinaryCacheFile("file '%s' does not exist in binary cache '%s'", path, config->getUri());
|
throw NoSuchBinaryCacheFile(
|
||||||
|
"file '%s' does not exist in binary cache '%s'", path, config->getHumanReadableURI());
|
||||||
maybeDisable();
|
maybeDisable();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -205,9 +205,20 @@ struct StoreConfig : public StoreDirConfig
|
||||||
*/
|
*/
|
||||||
virtual StoreReference getReference() const;
|
virtual StoreReference getReference() const;
|
||||||
|
|
||||||
std::string getUri() const
|
/**
|
||||||
|
* Get a textual representation of the store reference.
|
||||||
|
*
|
||||||
|
* @warning This is only suitable for logging or error messages.
|
||||||
|
* This will not roundtrip when parsed as a StoreReference.
|
||||||
|
* Must NOT be used as a cache key or otherwise be relied upon to
|
||||||
|
* be stable.
|
||||||
|
*
|
||||||
|
* Can be implemented by subclasses to make the URI more legible,
|
||||||
|
* e.g. when some query parameters are necessary to make sense of the URI.
|
||||||
|
*/
|
||||||
|
virtual std::string getHumanReadableURI() const
|
||||||
{
|
{
|
||||||
return getReference().render();
|
return getReference().render(/*withParams=*/false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -878,7 +889,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
[[noreturn]] void unsupported(const std::string & op)
|
[[noreturn]] void unsupported(const std::string & op)
|
||||||
{
|
{
|
||||||
throw Unsupported("operation '%s' is not supported by store '%s'", op, config.getUri());
|
throw Unsupported("operation '%s' is not supported by store '%s'", op, config.getHumanReadableURI());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ T & require(Store & store)
|
||||||
{
|
{
|
||||||
auto * castedStore = dynamic_cast<T *>(&store);
|
auto * castedStore = dynamic_cast<T *>(&store);
|
||||||
if (!castedStore)
|
if (!castedStore)
|
||||||
throw UsageError("%s not supported by store '%s'", T::operationName, store.config.getUri());
|
throw UsageError("%s not supported by store '%s'", T::operationName, store.config.getHumanReadableURI());
|
||||||
return *castedStore;
|
return *castedStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,9 @@ struct StoreReference
|
||||||
bool operator==(const StoreReference & rhs) const = default;
|
bool operator==(const StoreReference & rhs) const = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the whole store reference as a URI, including parameters.
|
* Render the whole store reference as a URI, optionally including parameters.
|
||||||
*/
|
*/
|
||||||
std::string render() const;
|
std::string render(bool withParams = true) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a URI into a store reference.
|
* Parse a URI into a store reference.
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ RemoteStore::RemoteStore(const Config & config)
|
||||||
ref<RemoteStore::Connection> RemoteStore::openConnectionWrapper()
|
ref<RemoteStore::Connection> RemoteStore::openConnectionWrapper()
|
||||||
{
|
{
|
||||||
if (failed)
|
if (failed)
|
||||||
throw Error("opening a connection to remote store '%s' previously failed", config.getUri());
|
throw Error("opening a connection to remote store '%s' previously failed", config.getHumanReadableURI());
|
||||||
try {
|
try {
|
||||||
return openConnection();
|
return openConnection();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
@ -95,7 +95,7 @@ void RemoteStore::initConnection(Connection & conn)
|
||||||
if (ex)
|
if (ex)
|
||||||
std::rethrow_exception(ex);
|
std::rethrow_exception(ex);
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
throw Error("cannot open connection to remote store '%s': %s", config.getUri(), e.what());
|
throw Error("cannot open connection to remote store '%s': %s", config.getHumanReadableURI(), e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
setOptions(conn);
|
setOptions(conn);
|
||||||
|
|
|
||||||
|
|
@ -282,12 +282,15 @@ struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStore
|
||||||
|
|
||||||
void init() override
|
void init() override
|
||||||
{
|
{
|
||||||
if (auto cacheInfo = diskCache->upToDateCacheExists(config->getUri())) {
|
/* FIXME: The URI (when used as a cache key) must have several parameters rendered (e.g. the endpoint).
|
||||||
|
This must be represented as a separate opaque string (probably a URI) that has the right query parameters. */
|
||||||
|
auto cacheUri = config->getReference().render(/*withParams=*/false);
|
||||||
|
if (auto cacheInfo = diskCache->upToDateCacheExists(cacheUri)) {
|
||||||
config->wantMassQuery.setDefault(cacheInfo->wantMassQuery);
|
config->wantMassQuery.setDefault(cacheInfo->wantMassQuery);
|
||||||
config->priority.setDefault(cacheInfo->priority);
|
config->priority.setDefault(cacheInfo->priority);
|
||||||
} else {
|
} else {
|
||||||
BinaryCacheStore::init();
|
BinaryCacheStore::init();
|
||||||
diskCache->createCache(config->getUri(), config->storeDir, config->wantMassQuery, config->priority);
|
diskCache->createCache(cacheUri, config->storeDir, config->wantMassQuery, config->priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -525,7 +528,8 @@ struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStore
|
||||||
|
|
||||||
sink(*res.data);
|
sink(*res.data);
|
||||||
} else
|
} else
|
||||||
throw NoSuchBinaryCacheFile("file '%s' does not exist in binary cache '%s'", path, config->getUri());
|
throw NoSuchBinaryCacheFile(
|
||||||
|
"file '%s' does not exist in binary cache '%s'", path, config->getHumanReadableURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePathSet queryAllValidPaths() override
|
StorePathSet queryAllValidPaths() override
|
||||||
|
|
|
||||||
|
|
@ -395,11 +395,14 @@ void Store::querySubstitutablePathInfos(const StorePathCAMap & paths, Substituta
|
||||||
"replaced path '%s' with '%s' for substituter '%s'",
|
"replaced path '%s' with '%s' for substituter '%s'",
|
||||||
printStorePath(path.first),
|
printStorePath(path.first),
|
||||||
sub->printStorePath(subPath),
|
sub->printStorePath(subPath),
|
||||||
sub->config.getUri());
|
sub->config.getHumanReadableURI());
|
||||||
} else if (sub->storeDir != storeDir)
|
} else if (sub->storeDir != storeDir)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
debug("checking substituter '%s' for path '%s'", sub->config.getUri(), sub->printStorePath(subPath));
|
debug(
|
||||||
|
"checking substituter '%s' for path '%s'",
|
||||||
|
sub->config.getHumanReadableURI(),
|
||||||
|
sub->printStorePath(subPath));
|
||||||
try {
|
try {
|
||||||
auto info = sub->queryPathInfo(subPath);
|
auto info = sub->queryPathInfo(subPath);
|
||||||
|
|
||||||
|
|
@ -439,7 +442,8 @@ bool Store::isValidPath(const StorePath & storePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diskCache) {
|
if (diskCache) {
|
||||||
auto res = diskCache->lookupNarInfo(config.getUri(), std::string(storePath.hashPart()));
|
auto res = diskCache->lookupNarInfo(
|
||||||
|
config.getReference().render(/*FIXME withParams=*/false), std::string(storePath.hashPart()));
|
||||||
if (res.first != NarInfoDiskCache::oUnknown) {
|
if (res.first != NarInfoDiskCache::oUnknown) {
|
||||||
stats.narInfoReadAverted++;
|
stats.narInfoReadAverted++;
|
||||||
auto state_(state.lock());
|
auto state_(state.lock());
|
||||||
|
|
@ -455,7 +459,8 @@ bool Store::isValidPath(const StorePath & storePath)
|
||||||
|
|
||||||
if (diskCache && !valid)
|
if (diskCache && !valid)
|
||||||
// FIXME: handle valid = true case.
|
// FIXME: handle valid = true case.
|
||||||
diskCache->upsertNarInfo(config.getUri(), std::string(storePath.hashPart()), 0);
|
diskCache->upsertNarInfo(
|
||||||
|
config.getReference().render(/*FIXME withParams=*/false), std::string(storePath.hashPart()), 0);
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
@ -509,7 +514,7 @@ std::optional<std::shared_ptr<const ValidPathInfo>> Store::queryPathInfoFromClie
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diskCache) {
|
if (diskCache) {
|
||||||
auto res = diskCache->lookupNarInfo(config.getUri(), hashPart);
|
auto res = diskCache->lookupNarInfo(config.getReference().render(/*FIXME withParams=*/false), hashPart);
|
||||||
if (res.first != NarInfoDiskCache::oUnknown) {
|
if (res.first != NarInfoDiskCache::oUnknown) {
|
||||||
stats.narInfoReadAverted++;
|
stats.narInfoReadAverted++;
|
||||||
{
|
{
|
||||||
|
|
@ -554,7 +559,7 @@ void Store::queryPathInfo(const StorePath & storePath, Callback<ref<const ValidP
|
||||||
auto info = fut.get();
|
auto info = fut.get();
|
||||||
|
|
||||||
if (diskCache)
|
if (diskCache)
|
||||||
diskCache->upsertNarInfo(config.getUri(), hashPart, info);
|
diskCache->upsertNarInfo(config.getReference().render(/*FIXME withParams=*/false), hashPart, info);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto state_(state.lock());
|
auto state_(state.lock());
|
||||||
|
|
@ -578,7 +583,8 @@ void Store::queryRealisation(const DrvOutput & id, Callback<std::shared_ptr<cons
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (diskCache) {
|
if (diskCache) {
|
||||||
auto [cacheOutcome, maybeCachedRealisation] = diskCache->lookupRealisation(config.getUri(), id);
|
auto [cacheOutcome, maybeCachedRealisation] =
|
||||||
|
diskCache->lookupRealisation(config.getReference().render(/*FIXME: withParams=*/false), id);
|
||||||
switch (cacheOutcome) {
|
switch (cacheOutcome) {
|
||||||
case NarInfoDiskCache::oValid:
|
case NarInfoDiskCache::oValid:
|
||||||
debug("Returning a cached realisation for %s", id.to_string());
|
debug("Returning a cached realisation for %s", id.to_string());
|
||||||
|
|
@ -604,9 +610,11 @@ void Store::queryRealisation(const DrvOutput & id, Callback<std::shared_ptr<cons
|
||||||
|
|
||||||
if (diskCache) {
|
if (diskCache) {
|
||||||
if (info)
|
if (info)
|
||||||
diskCache->upsertRealisation(config.getUri(), *info);
|
diskCache->upsertRealisation(
|
||||||
|
config.getReference().render(/*FIXME withParams=*/false), *info);
|
||||||
else
|
else
|
||||||
diskCache->upsertAbsentRealisation(config.getUri(), id);
|
diskCache->upsertAbsentRealisation(
|
||||||
|
config.getReference().render(/*FIXME withParams=*/false), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*callbackPtr)(std::shared_ptr<const Realisation>(info));
|
(*callbackPtr)(std::shared_ptr<const Realisation>(info));
|
||||||
|
|
@ -785,12 +793,27 @@ const Store::Stats & Store::getStats()
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string makeCopyPathMessage(std::string_view srcUri, std::string_view dstUri, std::string_view storePath)
|
static std::string
|
||||||
|
makeCopyPathMessage(const StoreConfig & srcCfg, const StoreConfig & dstCfg, std::string_view storePath)
|
||||||
{
|
{
|
||||||
return srcUri == "local" || srcUri == "daemon" ? fmt("copying path '%s' to '%s'", storePath, dstUri)
|
auto src = srcCfg.getReference();
|
||||||
: dstUri == "local" || dstUri == "daemon"
|
auto dst = dstCfg.getReference();
|
||||||
? fmt("copying path '%s' from '%s'", storePath, srcUri)
|
|
||||||
: fmt("copying path '%s' from '%s' to '%s'", storePath, srcUri, dstUri);
|
auto isShorthand = [](const StoreReference & ref) {
|
||||||
|
/* At this point StoreReference **must** be resolved. */
|
||||||
|
const auto & specified = std::get<StoreReference::Specified>(ref.variant);
|
||||||
|
const auto & scheme = specified.scheme;
|
||||||
|
return (scheme == "local" || scheme == "unix") && specified.authority.empty() && ref.params.empty();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isShorthand(src))
|
||||||
|
return fmt("copying path '%s' to '%s'", storePath, dstCfg.getHumanReadableURI());
|
||||||
|
|
||||||
|
if (isShorthand(dst))
|
||||||
|
return fmt("copying path '%s' from '%s'", storePath, srcCfg.getHumanReadableURI());
|
||||||
|
|
||||||
|
return fmt(
|
||||||
|
"copying path '%s' from '%s' to '%s'", storePath, srcCfg.getHumanReadableURI(), dstCfg.getHumanReadableURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
void copyStorePath(
|
void copyStorePath(
|
||||||
|
|
@ -801,11 +824,15 @@ void copyStorePath(
|
||||||
if (!repair && dstStore.isValidPath(storePath))
|
if (!repair && dstStore.isValidPath(storePath))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto srcUri = srcStore.config.getUri();
|
const auto & srcCfg = srcStore.config;
|
||||||
auto dstUri = dstStore.config.getUri();
|
const auto & dstCfg = dstStore.config;
|
||||||
auto storePathS = srcStore.printStorePath(storePath);
|
auto storePathS = srcStore.printStorePath(storePath);
|
||||||
Activity act(
|
Activity act(
|
||||||
*logger, lvlInfo, actCopyPath, makeCopyPathMessage(srcUri, dstUri, storePathS), {storePathS, srcUri, dstUri});
|
*logger,
|
||||||
|
lvlInfo,
|
||||||
|
actCopyPath,
|
||||||
|
makeCopyPathMessage(srcCfg, dstCfg, storePathS),
|
||||||
|
{storePathS, srcCfg.getHumanReadableURI(), dstCfg.getHumanReadableURI()});
|
||||||
PushActivity pact(act.id);
|
PushActivity pact(act.id);
|
||||||
|
|
||||||
auto info = srcStore.queryPathInfo(storePath);
|
auto info = srcStore.queryPathInfo(storePath);
|
||||||
|
|
@ -841,7 +868,7 @@ void copyStorePath(
|
||||||
throw EndOfFile(
|
throw EndOfFile(
|
||||||
"NAR for '%s' fetched from '%s' is incomplete",
|
"NAR for '%s' fetched from '%s' is incomplete",
|
||||||
srcStore.printStorePath(storePath),
|
srcStore.printStorePath(storePath),
|
||||||
srcStore.config.getUri());
|
srcStore.config.getHumanReadableURI());
|
||||||
});
|
});
|
||||||
|
|
||||||
dstStore.addToStore(*info, *source, repair, checkSigs);
|
dstStore.addToStore(*info, *source, repair, checkSigs);
|
||||||
|
|
@ -939,7 +966,7 @@ std::map<StorePath, StorePath> copyPaths(
|
||||||
"replaced path '%s' to '%s' for substituter '%s'",
|
"replaced path '%s' to '%s' for substituter '%s'",
|
||||||
srcStore.printStorePath(storePathForSrc),
|
srcStore.printStorePath(storePathForSrc),
|
||||||
dstStore.printStorePath(storePathForDst),
|
dstStore.printStorePath(storePathForDst),
|
||||||
dstStore.config.getUri());
|
dstStore.config.getHumanReadableURI());
|
||||||
}
|
}
|
||||||
return storePathForDst;
|
return storePathForDst;
|
||||||
};
|
};
|
||||||
|
|
@ -957,15 +984,15 @@ std::map<StorePath, StorePath> copyPaths(
|
||||||
// We can reasonably assume that the copy will happen whenever we
|
// We can reasonably assume that the copy will happen whenever we
|
||||||
// read the path, so log something about that at that point
|
// read the path, so log something about that at that point
|
||||||
uint64_t total = 0;
|
uint64_t total = 0;
|
||||||
auto srcUri = srcStore.config.getUri();
|
const auto & srcCfg = srcStore.config;
|
||||||
auto dstUri = dstStore.config.getUri();
|
const auto & dstCfg = dstStore.config;
|
||||||
auto storePathS = srcStore.printStorePath(missingPath);
|
auto storePathS = srcStore.printStorePath(missingPath);
|
||||||
Activity act(
|
Activity act(
|
||||||
*logger,
|
*logger,
|
||||||
lvlInfo,
|
lvlInfo,
|
||||||
actCopyPath,
|
actCopyPath,
|
||||||
makeCopyPathMessage(srcUri, dstUri, storePathS),
|
makeCopyPathMessage(srcCfg, dstCfg, storePathS),
|
||||||
{storePathS, srcUri, dstUri});
|
{storePathS, srcCfg.getHumanReadableURI(), dstCfg.getHumanReadableURI()});
|
||||||
PushActivity pact(act.id);
|
PushActivity pact(act.id);
|
||||||
|
|
||||||
LambdaSink progressSink([&](std::string_view data) {
|
LambdaSink progressSink([&](std::string_view data) {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ static bool isNonUriPath(const std::string & spec)
|
||||||
&& spec.find("/") != std::string::npos;
|
&& spec.find("/") != std::string::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StoreReference::render() const
|
std::string StoreReference::render(bool withParams) const
|
||||||
{
|
{
|
||||||
std::string res;
|
std::string res;
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@ std::string StoreReference::render() const
|
||||||
},
|
},
|
||||||
variant);
|
variant);
|
||||||
|
|
||||||
if (!params.empty()) {
|
if (withParams && !params.empty()) {
|
||||||
res += "?";
|
res += "?";
|
||||||
res += encodeQuery(params);
|
res += encodeQuery(params);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ struct CmdConfigCheck : StoreCommand
|
||||||
|
|
||||||
void run(ref<Store> store) override
|
void run(ref<Store> store) override
|
||||||
{
|
{
|
||||||
logger->log("Running checks against store uri: " + store->config.getUri());
|
logger->log("Running checks against store uri: " + store->config.getHumanReadableURI());
|
||||||
|
|
||||||
if (store.dynamic_pointer_cast<LocalFSStore>()) {
|
if (store.dynamic_pointer_cast<LocalFSStore>()) {
|
||||||
success &= checkNixInPath();
|
success &= checkNixInPath();
|
||||||
|
|
@ -171,9 +171,9 @@ struct CmdConfigCheck : StoreCommand
|
||||||
{
|
{
|
||||||
if (auto trustedMay = store->isTrustedClient()) {
|
if (auto trustedMay = store->isTrustedClient()) {
|
||||||
std::string_view trusted = trustedMay.value() ? "trusted" : "not trusted";
|
std::string_view trusted = trustedMay.value() ? "trusted" : "not trusted";
|
||||||
checkInfo(fmt("You are %s by store uri: %s", trusted, store->config.getUri()));
|
checkInfo(fmt("You are %s by store uri: %s", trusted, store->config.getHumanReadableURI()));
|
||||||
} else {
|
} else {
|
||||||
checkInfo(fmt("Store uri: %s doesn't have a notion of trusted user", store->config.getUri()));
|
checkInfo(fmt("Store uri: %s doesn't have a notion of trusted user", store->config.getHumanReadableURI()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ struct CmdLog : InstallableCommand
|
||||||
for (auto & sub : subs) {
|
for (auto & sub : subs) {
|
||||||
auto * logSubP = dynamic_cast<LogStore *>(&*sub);
|
auto * logSubP = dynamic_cast<LogStore *>(&*sub);
|
||||||
if (!logSubP) {
|
if (!logSubP) {
|
||||||
printInfo("Skipped '%s' which does not support retrieving build logs", sub->config.getUri());
|
printInfo(
|
||||||
|
"Skipped '%s' which does not support retrieving build logs", sub->config.getHumanReadableURI());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto & logSub = *logSubP;
|
auto & logSub = *logSubP;
|
||||||
|
|
@ -57,7 +58,7 @@ struct CmdLog : InstallableCommand
|
||||||
if (!log)
|
if (!log)
|
||||||
continue;
|
continue;
|
||||||
logger->stop();
|
logger->stop();
|
||||||
printInfo("got build log for '%s' from '%s'", installable->what(), logSub.config.getUri());
|
printInfo("got build log for '%s' from '%s'", installable->what(), logSub.config.getHumanReadableURI());
|
||||||
writeFull(getStandardOutput(), *log);
|
writeFull(getStandardOutput(), *log);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,9 @@ void execProgramInStore(
|
||||||
auto store2 = store.dynamic_pointer_cast<LocalFSStore>();
|
auto store2 = store.dynamic_pointer_cast<LocalFSStore>();
|
||||||
|
|
||||||
if (!store2)
|
if (!store2)
|
||||||
throw Error("store '%s' is not a local store so it does not support command execution", store->config.getUri());
|
throw Error(
|
||||||
|
"store '%s' is not a local store so it does not support command execution",
|
||||||
|
store->config.getHumanReadableURI());
|
||||||
|
|
||||||
if (store->storeDir != store2->getRealStoreDir()) {
|
if (store->storeDir != store2->getRealStoreDir()) {
|
||||||
Strings helperArgs = {
|
Strings helperArgs = {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ struct CmdInfoStore : StoreCommand, MixJSON
|
||||||
void run(ref<Store> store) override
|
void run(ref<Store> store) override
|
||||||
{
|
{
|
||||||
if (!json) {
|
if (!json) {
|
||||||
notice("Store URL: %s", store->config.getUri());
|
notice("Store URL: %s", store->config.getReference().render(/*withParams=*/true));
|
||||||
store->connect();
|
store->connect();
|
||||||
if (auto version = store->getVersion())
|
if (auto version = store->getVersion())
|
||||||
notice("Version: %s", *version);
|
notice("Version: %s", *version);
|
||||||
|
|
@ -34,7 +34,7 @@ struct CmdInfoStore : StoreCommand, MixJSON
|
||||||
nlohmann::json res;
|
nlohmann::json res;
|
||||||
Finally printRes([&]() { printJSON(res); });
|
Finally printRes([&]() { printJSON(res); });
|
||||||
|
|
||||||
res["url"] = store->config.getUri();
|
res["url"] = store->config.getReference().render(/*withParams=*/true);
|
||||||
store->connect();
|
store->connect();
|
||||||
if (auto version = store->getVersion())
|
if (auto version = store->getVersion())
|
||||||
res["version"] = *version;
|
res["version"] = *version;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue