aboutsummaryrefslogtreecommitdiff
path: root/zenserver/compute/apply.cpp
diff options
context:
space:
mode:
authorJoe Kirchoff <[email protected]>2021-12-01 14:30:25 -0800
committerJoe Kirchoff <[email protected]>2021-12-01 14:30:25 -0800
commitdda7198685d66f64926eb942748df57dca765833 (patch)
treea3e4ca6d18d6d063e99613bbd681440f6127fabf /zenserver/compute/apply.cpp
parentMerge pull request #31 from EpicGames/non-elevated-asio (diff)
downloadzen-dda7198685d66f64926eb942748df57dca765833.tar.xz
zen-dda7198685d66f64926eb942748df57dca765833.zip
Don't throw a runtime_error if remote execute api fails
asio currently doesn't propagate the exception as a 500 error
Diffstat (limited to 'zenserver/compute/apply.cpp')
-rw-r--r--zenserver/compute/apply.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/zenserver/compute/apply.cpp b/zenserver/compute/apply.cpp
index 1f18b054f..7b4fe39e6 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();
@@ -896,13 +905,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 +947,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)",