libstore: clarify that build log fd and hook log fd are different

only DerivationGoal can set the hook to anything at all. it always sets
buildOutFD to something that is not related to fromHook in any way, and
mixing the two would have rather dire consequences for log consistency.

Change-Id: Ida86727fd1cd5e1ecd78f07f3bde330a346658a8
This commit is contained in:
eldritch horrors 2024-08-11 21:53:29 +02:00
parent e2d330aeed
commit 5cbca85535

View file

@ -1288,9 +1288,7 @@ Goal::WorkResult DerivationGoal::handleChildOutput(int fd, std::string_view data
}; };
// local & `ssh://`-builds are dealt with here. // local & `ssh://`-builds are dealt with here.
auto isWrittenToLog = fd == builderOutFD->get(); if (fd == builderOutFD->get()) {
if (isWrittenToLog)
{
logSize += data.size(); logSize += data.size();
if (settings.maxLogSize && logSize > settings.maxLogSize) { if (settings.maxLogSize && logSize > settings.maxLogSize) {
return tooMuchLogs(); return tooMuchLogs();
@ -1308,6 +1306,7 @@ Goal::WorkResult DerivationGoal::handleChildOutput(int fd, std::string_view data
} }
if (logSink) (*logSink)(data); if (logSink) (*logSink)(data);
return StillAlive{};
} }
if (hook && fd == hook->fromHook.readSide.get()) { if (hook && fd == hook->fromHook.readSide.get()) {
@ -1318,7 +1317,7 @@ Goal::WorkResult DerivationGoal::handleChildOutput(int fd, std::string_view data
auto s = handleJSONLogMessage(*json, worker.act, hook->activities, true); auto s = handleJSONLogMessage(*json, worker.act, hook->activities, true);
// ensure that logs from a builder using `ssh-ng://` as protocol // ensure that logs from a builder using `ssh-ng://` as protocol
// are also available to `nix log`. // are also available to `nix log`.
if (s && !isWrittenToLog && logSink) { if (s && logSink) {
const auto type = (*json)["type"]; const auto type = (*json)["type"];
const auto fields = (*json)["fields"]; const auto fields = (*json)["fields"];
if (type == resBuildLogLine) { if (type == resBuildLogLine) {