aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-16 14:05:02 +0200
committerStefan Boberg <[email protected]>2021-09-16 14:05:02 +0200
commit397067ff20be5d1441cc1d8103913484e15da0ca (patch)
treed2dba835fa1c46eee9915c1a38d83ad3e202216b
parentFixed up mesh logging (diff)
downloadzen-397067ff20be5d1441cc1d8103913484e15da0ca.tar.xz
zen-397067ff20be5d1441cc1d8103913484e15da0ca.zip
Fixed marshaling of outputs including sanity checks, logging
-rw-r--r--zenserver/compute/apply.cpp22
-rw-r--r--zenserver/compute/apply.h1
2 files changed, 21 insertions, 2 deletions
diff --git a/zenserver/compute/apply.cpp b/zenserver/compute/apply.cpp
index 2c3243655..e40c6918d 100644
--- a/zenserver/compute/apply.cpp
+++ b/zenserver/compute/apply.cpp
@@ -806,11 +806,14 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action)
CbPackage OutputPackage;
CbObject Output = zen::LoadCompactBinaryObject(OutputData.Data[0]);
+ uint64_t TotalAttachmentBytes = 0;
+ uint64_t TotalRawAttachmentBytes = 0;
+
Output.IterateAttachments([&](CbFieldView Field) {
IoHash Hash = Field.AsHash();
std::filesystem::path OutputPath{SandboxPath / "Outputs" / Hash.ToHexString()};
- FileContents ChunkData = zen::ReadFile(SandboxPath / "build.output");
+ FileContents ChunkData = zen::ReadFile(OutputPath);
if (ChunkData.ErrorCode)
{
@@ -819,12 +822,27 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action)
ZEN_ASSERT(OutputData.Data.size() == 1);
- CbAttachment Attachment(CompressedBuffer::FromCompressed(SharedBuffer(ChunkData.Data[0])));
+ CompressedBuffer AttachmentBuffer = CompressedBuffer::FromCompressed(SharedBuffer(ChunkData.Data[0]));
+
+ if (!AttachmentBuffer)
+ {
+ throw std::runtime_error("Invalid output encountered (not valid CompressedBuffer format)");
+ }
+
+ TotalAttachmentBytes += AttachmentBuffer.GetCompressedSize();
+ TotalRawAttachmentBytes += AttachmentBuffer.GetCompressedSize();
+
+ CbAttachment Attachment(AttachmentBuffer);
OutputPackage.AddAttachment(Attachment);
});
OutputPackage.SetObject(Output);
+ ZEN_DEBUG("Action completed with {} attachments ({} compressed, {} uncompressed)",
+ OutputPackage.GetAttachments().size(),
+ NiceBytes(TotalAttachmentBytes),
+ NiceBytes(TotalRawAttachmentBytes));
+
return OutputPackage;
}
diff --git a/zenserver/compute/apply.h b/zenserver/compute/apply.h
index 474156a5e..86b262213 100644
--- a/zenserver/compute/apply.h
+++ b/zenserver/compute/apply.h
@@ -28,6 +28,7 @@ public:
virtual void HandleRequest(HttpServerRequest& Request) override;
private:
+ spdlog::logger& Log() { return m_Log; }
spdlog::logger& m_Log;
HttpRequestRouter m_Router;
CasStore& m_CasStore;