diff options
| author | Martin Ridgers <[email protected]> | 2021-12-08 09:04:04 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-12-08 09:04:04 +0100 |
| commit | 1037aa9edc9b88d9c59fdf2d2531ac265b571b3c (patch) | |
| tree | 805f277f60b1eba7de8b78ae209d7464bcedd398 /zenserver/compute/apply.cpp | |
| parent | Implement zen/internalfile for POSIX platforms (diff) | |
| parent | Use 'Platform' instead of 'OSFamily' for Horde condition (diff) | |
| download | zen-1037aa9edc9b88d9c59fdf2d2531ac265b571b3c.tar.xz zen-1037aa9edc9b88d9c59fdf2d2531ac265b571b3c.zip | |
Merged main
Diffstat (limited to 'zenserver/compute/apply.cpp')
| -rw-r--r-- | zenserver/compute/apply.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/zenserver/compute/apply.cpp b/zenserver/compute/apply.cpp index 1db3fe631..ddf7ad36c 100644 --- a/zenserver/compute/apply.cpp +++ b/zenserver/compute/apply.cpp @@ -593,9 +593,13 @@ HttpFunctionService::HttpFunctionService(CasStore& Store, CidStore& InCidStore, if (NeedList.empty()) { // We already have everything + CbObject Output; + HttpResponseCode ResponseCode = ExecActionUpstream(Worker, RequestObject, Output); - CbObject Output = ExecActionUpstream(Worker, RequestObject); - + if (ResponseCode != HttpResponseCode::OK) + { + return HttpReq.WriteResponse(ResponseCode); + } return HttpReq.WriteResponse(HttpResponseCode::OK, Output); } @@ -655,8 +659,13 @@ HttpFunctionService::HttpFunctionService(CasStore& Store, CidStore& InCidStore, zen::NiceBytes(TotalNewBytes), NewAttachmentCount); - CbObject Output = ExecActionUpstream(Worker, ActionObj); + CbObject Output; + HttpResponseCode ResponseCode = ExecActionUpstream(Worker, ActionObj, Output); + if (ResponseCode != HttpResponseCode::OK) + { + return HttpReq.WriteResponse(ResponseCode); + } return HttpReq.WriteResponse(HttpResponseCode::OK, Output); } break; @@ -904,8 +913,8 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action) return OutputPackage; } -CbObject -HttpFunctionService::ExecActionUpstream(const WorkerDesc& Worker, CbObject Action) +HttpResponseCode +HttpFunctionService::ExecActionUpstream(const WorkerDesc& Worker, CbObject Action, CbObject& Object) { const IoHash WorkerId = Worker.Descriptor.GetHash(); const IoHash ActionId = Action.GetHash(); @@ -918,14 +927,19 @@ HttpFunctionService::ExecActionUpstream(const WorkerDesc& Worker, CbObject Actio if (!EnqueueResult.Success) { - throw std::runtime_error("Error enqueuing upstream task"); + ZEN_ERROR( + "Error enqueuing upstream Action {}/{}", + WorkerId.ToHexString(), + ActionId.ToHexString()); + return HttpResponseCode::InternalServerError; } CbObjectWriter Writer; Writer.AddHash("worker", WorkerId); Writer.AddHash("action", ActionId); - return std::move(Writer.Save()); + Object = std::move(Writer.Save()); + return HttpResponseCode::OK; } HttpResponseCode @@ -955,8 +969,7 @@ HttpFunctionService::ExecActionUpstreamResult(const IoHash& WorkerId, const IoHa Completed.Error.Reason, Completed.Error.ErrorCode); - throw std::runtime_error( - "Action {}/{} failed"_format(WorkerId.ToHexString(), ActionId.ToHexString()).c_str()); + return HttpResponseCode::InternalServerError; } ZEN_INFO("Action {}/{} completed with {} attachments ({} compressed, {} uncompressed)", |