diff options
author | eldritch horrors <pennae@lix.systems> | 2024-08-11 21:53:29 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-08-18 09:10:05 +0000 |
commit | 7506d680ac540f39944c2a9f573900c5b1e4a023 (patch) | |
tree | 62af0b975758bf1f0c07f0a2b11026729db79dad /src/libstore/build | |
parent | 38f550708dd01515f7aaf66b0cc548fcd701e1c0 (diff) |
libstore: don't ignore max-build-log-size for ssh-ng
Change-Id: Ieab14662bea6e6f5533325f0e945147be998f9a2
Diffstat (limited to 'src/libstore/build')
-rw-r--r-- | src/libstore/build/derivation-goal.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index 291504a0f..17b6afbb2 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -1278,17 +1278,21 @@ bool DerivationGoal::isReadDesc(int fd) Goal::WorkResult DerivationGoal::handleChildOutput(int fd, std::string_view data) { + auto tooMuchLogs = [&] { + killChild(); + return done( + BuildResult::LogLimitExceeded, {}, + Error("%s killed after writing more than %d bytes of log output", + getName(), settings.maxLogSize)); + }; + // local & `ssh://`-builds are dealt with here. auto isWrittenToLog = isReadDesc(fd); if (isWrittenToLog) { logSize += data.size(); if (settings.maxLogSize && logSize > settings.maxLogSize) { - killChild(); - return done( - BuildResult::LogLimitExceeded, {}, - Error("%s killed after writing more than %d bytes of log output", - getName(), settings.maxLogSize)); + return tooMuchLogs(); } for (auto c : data) @@ -1317,7 +1321,13 @@ Goal::WorkResult DerivationGoal::handleChildOutput(int fd, std::string_view data const auto type = (*json)["type"]; const auto fields = (*json)["fields"]; if (type == resBuildLogLine) { - (*logSink)((fields.size() > 0 ? fields[0].get<std::string>() : "") + "\n"); + const std::string logLine = + (fields.size() > 0 ? fields[0].get<std::string>() : "") + "\n"; + logSize += logLine.size(); + if (settings.maxLogSize && logSize > settings.maxLogSize) { + return tooMuchLogs(); + } + (*logSink)(logLine); } else if (type == resSetPhase && ! fields.is_null()) { const auto phase = fields[0]; if (! phase.is_null()) { |