aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Kirchoff <[email protected]>2021-11-17 14:32:43 -0800
committerJoe Kirchoff <[email protected]>2021-11-17 14:32:43 -0800
commitf16668694fe5f565a55860bed27233f1a3650f80 (patch)
tree323ca05534613439e869ca7e4d15b7f419cd835a
parentChanged upstream DisplayName to UpstreamEndpointInfo with name and url. (diff)
downloadzen-f16668694fe5f565a55860bed27233f1a3650f80.tar.xz
zen-f16668694fe5f565a55860bed27233f1a3650f80.zip
Set horde worker requirements, limit to Win-RemoteExec pool
-rw-r--r--zenserver/upstream/upstreamapply.cpp41
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;