From f16668694fe5f565a55860bed27233f1a3650f80 Mon Sep 17 00:00:00 2001 From: Joe Kirchoff Date: Wed, 17 Nov 2021 14:32:43 -0800 Subject: Set horde worker requirements, limit to Win-RemoteExec pool --- zenserver/upstream/upstreamapply.cpp | 41 ++++++++++++++++++++++++++++++++---- 1 file 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 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& Resources, + const std::map& Resources, const bool Exclusive) { CbObjectWriter Writer; -- cgit v1.2.3