diff options
Diffstat (limited to 'zenserver/upstream/upstreamapply.cpp')
| -rw-r--r-- | zenserver/upstream/upstreamapply.cpp | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/zenserver/upstream/upstreamapply.cpp b/zenserver/upstream/upstreamapply.cpp index 1779099ff..e6e54428c 100644 --- a/zenserver/upstream/upstreamapply.cpp +++ b/zenserver/upstream/upstreamapply.cpp @@ -37,6 +37,9 @@ namespace zen { using namespace std::literals; +static const IoBuffer EmptyBuffer; +static const IoHash EmptyBufferId = IoHash::HashBuffer(EmptyBuffer); + namespace detail { class HordeUpstreamApplyEndpoint final : public UpstreamApplyEndpoint @@ -109,7 +112,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}; } @@ -122,7 +126,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}; } @@ -146,7 +151,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}; } @@ -457,13 +463,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"}, @@ -589,7 +588,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 @@ -608,7 +609,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 @@ -683,7 +686,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); @@ -705,6 +710,8 @@ namespace detail { [[nodiscard]] bool ProcessApplyKey(const UpstreamApplyRecord& ApplyRecord, UpstreamData& Data) { + using namespace fmt::literals; + std::string ExecutablePath; std::map<std::string, std::string> Environment; std::set<std::filesystem::path> InputFiles; @@ -736,6 +743,15 @@ namespace detail { } } + for (auto& It : ApplyRecord.WorkerDescriptor["dirs"sv]) + { + std::string_view Directory = It.AsString(); + std::string DummyFile = "{}/.zen_empty_file"_format(Directory); + InputFiles.insert(DummyFile); + Data.Blobs[EmptyBufferId] = EmptyBuffer; + InputFileHashes[DummyFile] = EmptyBufferId; + } + for (auto& It : ApplyRecord.WorkerDescriptor["environment"sv]) { std::string_view Env = It.AsString(); @@ -810,18 +826,10 @@ namespace detail { bool Exclusive = ApplyRecord.WorkerDescriptor["exclusive"sv].AsBool(); // TODO: Remove override when Horde accepts the UE style Host Platforms (Win64, Linux, Mac) - std::string Condition; - if (HostPlatform == "Win64" || HostPlatform == "Windows") - { - Condition = "OSFamily == 'Windows' && Pool == 'Win-RemoteExec'"; - } - else if (HostPlatform == "Mac") - { - Condition = "OSFamily == 'MacOS'"; - } - else + std::string Condition = "Platform == '{}'"_format(HostPlatform); + if (HostPlatform == "Win64") { - Condition = "OSFamily == '{}'"_format(HostPlatform); + Condition += " && Pool == 'Win-RemoteExec'"; } std::map<std::string_view, int64_t> Resources; |