More progress indicator improvements

Fixes #1599.
This commit is contained in:
Eelco Dolstra 2017-10-24 14:47:23 +02:00
parent be220702a7
commit 96051dd057
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
5 changed files with 28 additions and 14 deletions

View file

@ -201,25 +201,29 @@ connected:
auto inputs = readStrings<PathSet>(source); auto inputs = readStrings<PathSet>(source);
auto outputs = readStrings<PathSet>(source); auto outputs = readStrings<PathSet>(source);
AutoCloseFD uploadLock = openLockFile(currentLoad + "/" + escapeUri(storeUri) + ".upload-lock", true);
{ {
Activity act(*logger, lvlTalkative, actUnknown, fmt("waiting for the upload lock to '%s'", storeUri)); Activity act(*logger, lvlTalkative, actUnknown, fmt("waiting for the upload lock to '%s'", storeUri));
AutoCloseFD uploadLock = openLockFile(currentLoad + "/" + escapeUri(storeUri) + ".upload-lock", true);
auto old = signal(SIGALRM, handleAlarm); auto old = signal(SIGALRM, handleAlarm);
alarm(15 * 60); alarm(15 * 60);
if (!lockFile(uploadLock.get(), ltWrite, true)) if (!lockFile(uploadLock.get(), ltWrite, true))
printError("somebody is hogging the upload lock for '%s', continuing..."); printError("somebody is hogging the upload lock for '%s', continuing...");
alarm(0); alarm(0);
signal(SIGALRM, old); signal(SIGALRM, old);
copyPaths(store, ref<Store>(sshStore), inputs, NoRepair, NoCheckSigs);
uploadLock = -1;
} }
{
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying dependencies to '%s'", storeUri));
copyPaths(store, ref<Store>(sshStore), inputs, NoRepair, NoCheckSigs);
}
uploadLock = -1;
BasicDerivation drv(readDerivation(store->realStoreDir + "/" + baseNameOf(drvPath))); BasicDerivation drv(readDerivation(store->realStoreDir + "/" + baseNameOf(drvPath)));
drv.inputSrcs = inputs; drv.inputSrcs = inputs;
printInfo("building '%s' on '%s'", drvPath, storeUri);
auto result = sshStore->buildDerivation(drvPath, drv); auto result = sshStore->buildDerivation(drvPath, drv);
if (!result.success()) if (!result.success())
@ -230,6 +234,7 @@ connected:
if (!store->isValidPath(path)) missing.insert(path); if (!store->isValidPath(path)) missing.insert(path);
if (!missing.empty()) { if (!missing.empty()) {
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying outputs from '%s'", storeUri));
setenv("NIX_HELD_LOCKS", concatStringsSep(" ", missing).c_str(), 1); /* FIXME: ugly */ setenv("NIX_HELD_LOCKS", concatStringsSep(" ", missing).c_str(), 1); /* FIXME: ugly */
copyPaths(ref<Store>(sshStore), store, missing, NoRepair, NoCheckSigs); copyPaths(ref<Store>(sshStore), store, missing, NoRepair, NoCheckSigs);
} }

View file

@ -1403,7 +1403,7 @@ void DerivationGoal::tryToBuild()
auto started = [&]() { auto started = [&]() {
act = std::make_unique<Activity>(*logger, lvlInfo, actBuild, act = std::make_unique<Activity>(*logger, lvlInfo, actBuild,
fmt("building '%s'", drvPath), hook ? fmt("building '%s' on '%s'", drvPath, machineName) : fmt("building '%s'", drvPath),
Logger::Fields{drvPath, hook ? machineName : ""}); Logger::Fields{drvPath, hook ? machineName : ""});
mcRunningBuilds = std::make_unique<MaintainCount<uint64_t>>(worker.runningBuilds); mcRunningBuilds = std::make_unique<MaintainCount<uint64_t>>(worker.runningBuilds);
worker.updateProgress(); worker.updateProgress();
@ -1659,7 +1659,7 @@ HookReply DerivationGoal::tryBuildHook()
string reply; string reply;
while (true) { while (true) {
string s = readLine(worker.hook->fromHook.readSide.get()); string s = readLine(worker.hook->fromHook.readSide.get());
if (handleJSONLogMessage(s, worker.act, worker.hook->activities)) if (handleJSONLogMessage(s, worker.act, worker.hook->activities, true))
; ;
else if (string(s, 0, 2) == "# ") { else if (string(s, 0, 2) == "# ") {
reply = string(s, 2); reply = string(s, 2);
@ -3270,7 +3270,7 @@ void DerivationGoal::handleChildOutput(int fd, const string & data)
if (hook && fd == hook->fromHook.readSide.get()) { if (hook && fd == hook->fromHook.readSide.get()) {
for (auto c : data) for (auto c : data)
if (c == '\n') { if (c == '\n') {
handleJSONLogMessage(currentHookLine, worker.act, hook->activities); handleJSONLogMessage(currentHookLine, worker.act, hook->activities, true);
currentHookLine.clear(); currentHookLine.clear();
} else } else
currentHookLine += c; currentHookLine += c;
@ -3287,7 +3287,7 @@ void DerivationGoal::handleEOF(int fd)
void DerivationGoal::flushLine() void DerivationGoal::flushLine()
{ {
if (handleJSONLogMessage(currentLogLine, *act, builderActivities)) if (handleJSONLogMessage(currentLogLine, *act, builderActivities, false))
; ;
else { else {

View file

@ -565,8 +565,16 @@ void Store::buildPaths(const PathSet & paths, BuildMode buildMode)
void copyStorePath(ref<Store> srcStore, ref<Store> dstStore, void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
const Path & storePath, RepairFlag repair, CheckSigsFlag checkSigs) const Path & storePath, RepairFlag repair, CheckSigsFlag checkSigs)
{ {
Activity act(*logger, lvlInfo, actCopyPath, fmt("copying path '%s'", storePath), auto srcUri = srcStore->getUri();
{storePath, srcStore->getUri(), dstStore->getUri()}); auto dstUri = dstStore->getUri();
Activity act(*logger, lvlInfo, actCopyPath,
srcUri == "local"
? fmt("copying path '%s' to '%s'", storePath, dstUri)
: dstUri == "local"
? fmt("copying path '%s' from '%s'", storePath, srcUri)
: fmt("copying path '%s' from '%s' to '%s'", storePath, srcUri, dstUri),
{storePath, srcUri, dstUri});
PushActivity pact(act.id); PushActivity pact(act.id);
auto info = srcStore->queryPathInfo(storePath); auto info = srcStore->queryPathInfo(storePath);

View file

@ -176,7 +176,7 @@ static Logger::Fields getFields(nlohmann::json & json)
} }
bool handleJSONLogMessage(const std::string & msg, bool handleJSONLogMessage(const std::string & msg,
const Activity & act, std::map<ActivityId, Activity> & activities) const Activity & act, std::map<ActivityId, Activity> & activities, bool trusted)
{ {
if (!hasPrefix(msg, "@nix ")) return false; if (!hasPrefix(msg, "@nix ")) return false;
@ -187,7 +187,7 @@ bool handleJSONLogMessage(const std::string & msg,
if (action == "start") { if (action == "start") {
auto type = (ActivityType) json["type"]; auto type = (ActivityType) json["type"];
if (type == actDownload || type == actUnknown) if (trusted || type == actDownload)
activities.emplace(std::piecewise_construct, activities.emplace(std::piecewise_construct,
std::forward_as_tuple(json["id"]), std::forward_as_tuple(json["id"]),
std::forward_as_tuple(*logger, (Verbosity) json["level"], type, std::forward_as_tuple(*logger, (Verbosity) json["level"], type,

View file

@ -133,7 +133,8 @@ Logger * makeDefaultLogger();
Logger * makeJSONLogger(Logger & prevLogger); Logger * makeJSONLogger(Logger & prevLogger);
bool handleJSONLogMessage(const std::string & msg, bool handleJSONLogMessage(const std::string & msg,
const Activity & act, std::map<ActivityId, Activity> & activities); const Activity & act, std::map<ActivityId, Activity> & activities,
bool trusted);
extern Verbosity verbosity; /* suppress msgs > this */ extern Verbosity verbosity; /* suppress msgs > this */