libstore: move log handling fully into handleBuilderOutput

it was split up like this only because the old worker system had no
promises. since we have them now we can use them for encapsulation.

Change-Id: Idbd523eff617d4c53c14b125ab3dfce4979cdab1
This commit is contained in:
eldritch horrors
2025-10-13 11:26:49 +00:00
parent 1210a4e025
commit b04521e4ec
2 changed files with 24 additions and 25 deletions
+24 -21
View File
@@ -1229,6 +1229,30 @@ Goal::WorkResult DerivationGoal::tooMuchLogs()
kj::Promise<Result<std::optional<Goal::WorkResult>>>
DerivationGoal::handleBuilderOutput(AsyncInputStream & in) noexcept
try {
std::string currentLogLine;
size_t currentLogLinePos = 0; // to handle carriage return
auto flushLine = [&] {
KJ_DEFER({
currentLogLine = "";
currentLogLinePos = 0;
});
if (const auto state = handleJSONLogMessage(
currentLogLine, *act, builderActivities, "the derivation builder", false
))
{
return *state;
} else {
logTail.push_back(currentLogLine);
if (logTail.size() > settings.logLines) {
logTail.pop_front();
}
return act->result(resBuildLogLine, currentLogLine);
}
};
auto buf = kj::heapArray<char>(4096);
while (true) {
std::string_view data;
@@ -1417,27 +1441,6 @@ DerivationGoal::handleChildStreams(AsyncInputStream * builderIn, AsyncInputStrea
co_return std::nullopt;
}
Logger::BufferState DerivationGoal::flushLine()
{
KJ_DEFER({
currentLogLine = "";
currentLogLinePos = 0;
});
if (const auto state = handleJSONLogMessage(
currentLogLine, *act, builderActivities, "the derivation builder", false
))
{
return *state;
} else {
logTail.push_back(currentLogLine);
if (logTail.size() > settings.logLines) logTail.pop_front();
return act->result(resBuildLogLine, currentLogLine);
}
}
kj::Promise<Result<OutputPathMap>> DerivationGoal::queryDerivationOutputMap()
try {
OutputPathMap res;
-4
View File
@@ -201,9 +201,6 @@ struct DerivationGoal : public Goal
*/
std::list<std::string> logTail;
std::string currentLogLine;
size_t currentLogLinePos = 0; // to handle carriage return
std::string currentHookLine;
/**
@@ -325,7 +322,6 @@ protected:
kj::Promise<Result<std::optional<WorkResult>>> handleHookOutput(AsyncInputStream & in) noexcept;
kj::Promise<Result<std::optional<WorkResult>>> monitorForSilence() noexcept;
WorkResult tooMuchLogs();
Logger::BufferState flushLine();
virtual std::string buildErrorContents(const std::string & exitMsg, bool diskFull);