diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-10-24T12·47+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-10-24T12·47+0200 |
commit | 96051dd057d46d5953b2fbe3de67269d175306dc (patch) | |
tree | 832bdd7bdbd63fee747838d35a014b9f9451d811 /src | |
parent | be220702a75427b80258a92d1ed8c4573c1478fa (diff) |
More progress indicator improvements
Fixes #1599.
Diffstat (limited to 'src')
-rw-r--r-- | src/build-remote/build-remote.cc | 13 | ||||
-rw-r--r-- | src/libstore/build.cc | 8 | ||||
-rw-r--r-- | src/libstore/store-api.cc | 12 | ||||
-rw-r--r-- | src/libutil/logging.cc | 4 | ||||
-rw-r--r-- | src/libutil/logging.hh | 3 |
5 files changed, 27 insertions, 13 deletions
diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc index d2fac09f8432..419e7205372b 100644 --- a/src/build-remote/build-remote.cc +++ b/src/build-remote/build-remote.cc @@ -201,25 +201,29 @@ connected: auto inputs = 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)); - AutoCloseFD uploadLock = openLockFile(currentLoad + "/" + escapeUri(storeUri) + ".upload-lock", true); - auto old = signal(SIGALRM, handleAlarm); alarm(15 * 60); if (!lockFile(uploadLock.get(), ltWrite, true)) printError("somebody is hogging the upload lock for '%s', continuing..."); alarm(0); signal(SIGALRM, old); + } + + { + Activity act(*logger, lvlTalkative, actUnknown, fmt("copying dependencies to '%s'", storeUri)); copyPaths(store, ref<Store>(sshStore), inputs, NoRepair, NoCheckSigs); - uploadLock = -1; } + uploadLock = -1; + BasicDerivation drv(readDerivation(store->realStoreDir + "/" + baseNameOf(drvPath))); drv.inputSrcs = inputs; - printInfo("building '%s' on '%s'", drvPath, storeUri); auto result = sshStore->buildDerivation(drvPath, drv); if (!result.success()) @@ -230,6 +234,7 @@ connected: if (!store->isValidPath(path)) missing.insert(path); 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 */ copyPaths(ref<Store>(sshStore), store, missing, NoRepair, NoCheckSigs); } diff --git a/src/libstore/build.cc b/src/libstore/build.cc index dcc48bef770b..681879c6aa5f 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1403,7 +1403,7 @@ void DerivationGoal::tryToBuild() auto started = [&]() { 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 : ""}); mcRunningBuilds = std::make_unique<MaintainCount<uint64_t>>(worker.runningBuilds); worker.updateProgress(); @@ -1659,7 +1659,7 @@ HookReply DerivationGoal::tryBuildHook() string reply; while (true) { 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) == "# ") { reply = string(s, 2); @@ -3270,7 +3270,7 @@ void DerivationGoal::handleChildOutput(int fd, const string & data) if (hook && fd == hook->fromHook.readSide.get()) { for (auto c : data) if (c == '\n') { - handleJSONLogMessage(currentHookLine, worker.act, hook->activities); + handleJSONLogMessage(currentHookLine, worker.act, hook->activities, true); currentHookLine.clear(); } else currentHookLine += c; @@ -3287,7 +3287,7 @@ void DerivationGoal::handleEOF(int fd) void DerivationGoal::flushLine() { - if (handleJSONLogMessage(currentLogLine, *act, builderActivities)) + if (handleJSONLogMessage(currentLogLine, *act, builderActivities, false)) ; else { diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 3bc5e4c57c95..17237a03541c 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -565,8 +565,16 @@ void Store::buildPaths(const PathSet & paths, BuildMode buildMode) void copyStorePath(ref<Store> srcStore, ref<Store> dstStore, const Path & storePath, RepairFlag repair, CheckSigsFlag checkSigs) { - Activity act(*logger, lvlInfo, actCopyPath, fmt("copying path '%s'", storePath), - {storePath, srcStore->getUri(), dstStore->getUri()}); + auto srcUri = srcStore->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); auto info = srcStore->queryPathInfo(storePath); diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc index 1a2684a43a5e..011155871122 100644 --- a/src/libutil/logging.cc +++ b/src/libutil/logging.cc @@ -176,7 +176,7 @@ static Logger::Fields getFields(nlohmann::json & json) } 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; @@ -187,7 +187,7 @@ bool handleJSONLogMessage(const std::string & msg, if (action == "start") { auto type = (ActivityType) json["type"]; - if (type == actDownload || type == actUnknown) + if (trusted || type == actDownload) activities.emplace(std::piecewise_construct, std::forward_as_tuple(json["id"]), std::forward_as_tuple(*logger, (Verbosity) json["level"], type, diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh index 70a9f5d86249..677aa4daec4d 100644 --- a/src/libutil/logging.hh +++ b/src/libutil/logging.hh @@ -133,7 +133,8 @@ Logger * makeDefaultLogger(); Logger * makeJSONLogger(Logger & prevLogger); 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 */ |