diff options
| author | Martin Ridgers <[email protected]> | 2021-12-08 09:10:20 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-12-08 09:10:20 +0100 |
| commit | 3655347983570f17ecb1b0374f8a79501c0f870e (patch) | |
| tree | c6b9c52c403e6a1ceeb76f05a38f88375459bf47 /zenserver/upstream/upstreamapply.cpp | |
| parent | Merged main (diff) | |
| parent | Return status_code as ErrorCode from jupiter api if not successful (diff) | |
| download | zen-3655347983570f17ecb1b0374f8a79501c0f870e.tar.xz zen-3655347983570f17ecb1b0374f8a79501c0f870e.zip | |
Merged main
Diffstat (limited to 'zenserver/upstream/upstreamapply.cpp')
| -rw-r--r-- | zenserver/upstream/upstreamapply.cpp | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/zenserver/upstream/upstreamapply.cpp b/zenserver/upstream/upstreamapply.cpp index 2b805fe14..f673ec3b3 100644 --- a/zenserver/upstream/upstreamapply.cpp +++ b/zenserver/upstream/upstreamapply.cpp @@ -115,7 +115,8 @@ namespace detail { ElapsedSeconds += Result.ElapsedSeconds; if (!Result.Success) { - return {.Error{.ErrorCode = Result.ErrorCode, .Reason = std::move(Result.Reason)}, + return {.Error{.ErrorCode = Result.ErrorCode ? Result.ErrorCode : -1, + .Reason = !Result.Reason.empty() ? std::move(Result.Reason) : "Failed to upload blobs"}, .Bytes = Bytes, .ElapsedSeconds = ElapsedSeconds}; } @@ -128,7 +129,8 @@ namespace detail { ElapsedSeconds += Result.ElapsedSeconds; if (!Result.Success) { - return {.Error{.ErrorCode = Result.ErrorCode, .Reason = std::move(Result.Reason)}, + return {.Error{.ErrorCode = Result.ErrorCode ? Result.ErrorCode : -1, + .Reason = !Result.Reason.empty() ? std::move(Result.Reason) : "Failed to upload objects"}, .Bytes = Bytes, .ElapsedSeconds = ElapsedSeconds}; } @@ -152,7 +154,8 @@ namespace detail { m_PendingTasks.erase(UpstreamData.TaskId); } - return {.Error{.ErrorCode = Result.ErrorCode, .Reason = std::move(Result.Reason)}, + return {.Error{.ErrorCode = Result.ErrorCode ? Result.ErrorCode : -1, + .Reason = !Result.Reason.empty() ? std::move(Result.Reason) : "Failed to post compute task"}, .Bytes = Bytes, .ElapsedSeconds = ElapsedSeconds}; } @@ -185,12 +188,12 @@ namespace detail { CloudCacheExistsResult ExistsResult = Session.BlobExists(Keys); ElapsedSeconds += ExistsResult.ElapsedSeconds; - if (ExistsResult.ErrorCode != 0) + if (!ExistsResult.Success) { return {.Bytes = Bytes, .ElapsedSeconds = ElapsedSeconds, - .ErrorCode = ExistsResult.ErrorCode, - .Reason = std::move(ExistsResult.Reason)}; + .ErrorCode = ExistsResult.ErrorCode ? ExistsResult.ErrorCode : -1, + .Reason = !ExistsResult.Reason.empty() ? std::move(ExistsResult.Reason) : "Failed to check if blobs exist"}; } // TODO: Batch upload missing blobs @@ -209,8 +212,8 @@ namespace detail { { return {.Bytes = Bytes, .ElapsedSeconds = ElapsedSeconds, - .ErrorCode = Result.ErrorCode, - .Reason = std::move(Result.Reason)}; + .ErrorCode = ExistsResult.ErrorCode ? ExistsResult.ErrorCode : -1, + .Reason = !ExistsResult.Reason.empty() ? std::move(ExistsResult.Reason) : "Failed to put blobs"}; } } @@ -236,12 +239,12 @@ namespace detail { CloudCacheExistsResult ExistsResult = Session.ObjectExists(Keys); ElapsedSeconds += ExistsResult.ElapsedSeconds; - if (ExistsResult.ErrorCode != 0) + if (!ExistsResult.Success) { return {.Bytes = Bytes, .ElapsedSeconds = ElapsedSeconds, - .ErrorCode = ExistsResult.ErrorCode, - .Reason = std::move(ExistsResult.Reason)}; + .ErrorCode = ExistsResult.ErrorCode ? ExistsResult.ErrorCode : -1, + .Reason = !ExistsResult.Reason.empty() ? std::move(ExistsResult.Reason) : "Failed to check if objects exist"}; } // TODO: Batch upload missing objects @@ -260,8 +263,8 @@ namespace detail { { return {.Bytes = Bytes, .ElapsedSeconds = ElapsedSeconds, - .ErrorCode = Result.ErrorCode, - .Reason = std::move(Result.Reason)}; + .ErrorCode = ExistsResult.ErrorCode ? ExistsResult.ErrorCode : -1, + .Reason = !ExistsResult.Reason.empty() ? std::move(ExistsResult.Reason) : "Failed to put objects"}; } } @@ -330,7 +333,7 @@ namespace detail { CloudCacheResult UpdatesResult = Session.GetComputeUpdates(m_ChannelId); Bytes += UpdatesResult.Bytes; ElapsedSeconds += UpdatesResult.ElapsedSeconds; - if (UpdatesResult.ErrorCode != 0) + if (!UpdatesResult.Success) { return {.Error{.ErrorCode = UpdatesResult.ErrorCode, .Reason = std::move(UpdatesResult.Reason)}, .Bytes = Bytes, @@ -463,13 +466,6 @@ namespace detail { Bytes += ObjectTreeResult.Bytes; ElapsedSeconds += ObjectTreeResult.ElapsedSeconds; - if (ObjectTreeResult.ErrorCode != 0) - { - return {.Error{.ErrorCode = ObjectTreeResult.ErrorCode, .Reason = std::move(ObjectTreeResult.Reason)}, - .Bytes = Bytes, - .ElapsedSeconds = ElapsedSeconds}; - } - if (!ObjectTreeResult.Success) { return {.Error{.ErrorCode = -1, .Reason = "Failed to get result object data"}, @@ -516,7 +512,7 @@ namespace detail { CloudCacheResult ObjectResult = Session.GetObject(It.first); Bytes += ObjectTreeResult.Bytes; ElapsedSeconds += ObjectTreeResult.ElapsedSeconds; - if (ObjectTreeResult.ErrorCode != 0) + if (!ObjectTreeResult.Success) { return {.Error{.ErrorCode = ObjectResult.ErrorCode, .Reason = std::move(ObjectResult.Reason)}, .Bytes = Bytes, @@ -540,7 +536,7 @@ namespace detail { CloudCacheResult BlobResult = Session.GetBlob(It.first); Bytes += ObjectTreeResult.Bytes; ElapsedSeconds += ObjectTreeResult.ElapsedSeconds; - if (BlobResult.ErrorCode != 0) + if (!BlobResult.Success) { return {.Error{.ErrorCode = BlobResult.ErrorCode, .Reason = std::move(BlobResult.Reason)}, .Bytes = Bytes, @@ -595,7 +591,9 @@ namespace detail { { return {.Error{.ErrorCode = ExitCode, .Reason = "Build.output file not found in task results"}, .Bytes = Bytes, - .ElapsedSeconds = ElapsedSeconds}; + .ElapsedSeconds = ElapsedSeconds, + .StdOut = std::move(StdOut), + .StdErr = std::move(StdErr)}; } // Get Output directory node @@ -614,7 +612,9 @@ namespace detail { { return {.Error{.ErrorCode = ExitCode, .Reason = "Outputs directory not found in task results"}, .Bytes = Bytes, - .ElapsedSeconds = ElapsedSeconds}; + .ElapsedSeconds = ElapsedSeconds, + .StdOut = std::move(StdOut), + .StdErr = std::move(StdErr)}; } // load build.output as CbObject @@ -689,7 +689,9 @@ namespace detail { { return {.Error{.ErrorCode = -1, .Reason = "Failed to get result object attachment data"}, .Bytes = Bytes, - .ElapsedSeconds = ElapsedSeconds}; + .ElapsedSeconds = ElapsedSeconds, + .StdOut = std::move(StdOut), + .StdErr = std::move(StdErr)}; } OutputPackage.SetObject(BuildOutputObject); @@ -749,8 +751,8 @@ namespace detail { std::string_view Directory = It.AsString(); std::string DummyFile = "{}/.zen_empty_file"_format(Directory); InputFiles.insert(DummyFile); - Data.Blobs[EmptyBufferId] = EmptyBuffer; - InputFileHashes[DummyFile] = EmptyBufferId; + Data.Blobs[EmptyBufferId] = EmptyBuffer; + InputFileHashes[DummyFile] = EmptyBufferId; } for (auto& It : ApplyRecord.WorkerDescriptor["environment"sv]) |