diff options
Diffstat (limited to 'zenserver/upstream')
| -rw-r--r-- | zenserver/upstream/upstreamapply.cpp | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/zenserver/upstream/upstreamapply.cpp b/zenserver/upstream/upstreamapply.cpp index 3267b408e..651c2dcc8 100644 --- a/zenserver/upstream/upstreamapply.cpp +++ b/zenserver/upstream/upstreamapply.cpp @@ -798,9 +798,42 @@ namespace detail { { using namespace fmt::literals; std::string_view HostPlatform = ApplyRecord.WorkerDescriptor["host"sv].AsString(); - // TODO: Enable when Horde accepts the UE style Host Platforms (Win64, Linux, Mac) - // CbObject Requirements = BuildRequirements("OSFamily == '{}'"_format(HostPlatform), {}, false); - CbObject Requirements = BuildRequirements("OSFamily == 'Windows'", {}, false); + if (HostPlatform.empty()) + { + Log().warn("process apply upstream FAILED, 'host' platform not provided"); + return false; + } + + int32_t LogicalCores = ApplyRecord.WorkerDescriptor["cores"sv].AsInt32(); + int64_t Memory = ApplyRecord.WorkerDescriptor["memory"sv].AsInt64(); + 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 + { + Condition = "OSFamily == '{}'"_format(HostPlatform); + } + + std::map<std::string_view, int64_t> Resources; + if (LogicalCores > 0) + { + Resources["LogicalCores"sv] = LogicalCores; + } + if (Memory > 0) + { + Resources["RAM"sv] = std::max(Memory / 1024 / 1024 / 1024, 1LL); + } + + CbObject Requirements = BuildRequirements(Condition, Resources, Exclusive); const IoHash RequirementsId = Requirements.GetHash(); Data.Objects[RequirementsId] = std::move(Requirements); Data.RequirementsId = RequirementsId; @@ -954,7 +987,7 @@ namespace detail { } [[nodiscard]] CbObject BuildRequirements(const std::string_view Condition, - const std::map<std::string_view, int32_t>& Resources, + const std::map<std::string_view, int64_t>& Resources, const bool Exclusive) { CbObjectWriter Writer; |