diff options
| author | Per Larsson <[email protected]> | 2021-12-09 17:01:57 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-12-09 17:01:57 +0100 |
| commit | 20f3c16b0012cfb8ce7bf9b6dd06a2720b6885c6 (patch) | |
| tree | fbb0f274840a12c32d93c7e342c0427f2617a651 /zenserver/compute/apply.cpp | |
| parent | Disabled cache tracker. (diff) | |
| parent | Return status_code as ErrorCode from jupiter api if not successful (diff) | |
| download | zen-20f3c16b0012cfb8ce7bf9b6dd06a2720b6885c6.tar.xz zen-20f3c16b0012cfb8ce7bf9b6dd06a2720b6885c6.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 1f18b054f..ae4dd4528 100644 --- a/zenserver/compute/apply.cpp +++ b/zenserver/compute/apply.cpp @@ -578,9 +578,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); } @@ -638,8 +642,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; @@ -881,8 +890,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(); @@ -895,14 +904,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 @@ -932,8 +946,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)", |