diff options
| author | Stefan Boberg <[email protected]> | 2026-04-02 17:31:56 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2026-04-02 17:31:56 +0200 |
| commit | e490bfe7b9c0f2986065a12281d29e5ab2e452f1 (patch) | |
| tree | 8b3bef1b0bc036675084e0060c1a6b8785ce429d /src/zenhorde | |
| parent | add [[nodiscard]] (diff) | |
| download | zen-sb/compute-oidc-auth.tar.xz zen-sb/compute-oidc-auth.zip | |
Expand environment variables in --data-dir and improve HordeAgentsb/compute-oidc-auth
- Add ExpandEnvironmentVariables() to zencore that substitutes %VAR%
references using GetEnvVariable(), leaving unknown vars unexpanded
- Expand env vars in --data-dir before resolving the absolute path
- Use %UE_HORDE_SHARED_DIR%\zen as default data-dir for Horde agents
- Store exit code and exception info on HordeAgent for caller access
- Take HordeConfig by value in HordeClient constructor
Diffstat (limited to 'src/zenhorde')
| -rw-r--r-- | src/zenhorde/hordeagent.cpp | 9 | ||||
| -rw-r--r-- | src/zenhorde/hordeagent.h | 20 | ||||
| -rw-r--r-- | src/zenhorde/hordeclient.cpp | 2 | ||||
| -rw-r--r-- | src/zenhorde/hordeprovisioner.cpp | 10 | ||||
| -rw-r--r-- | src/zenhorde/include/zenhorde/hordeclient.h | 2 |
5 files changed, 24 insertions, 19 deletions
diff --git a/src/zenhorde/hordeagent.cpp b/src/zenhorde/hordeagent.cpp index 819b2d0cb..5bb763e87 100644 --- a/src/zenhorde/hordeagent.cpp +++ b/src/zenhorde/hordeagent.cpp @@ -167,6 +167,8 @@ HordeAgent::UploadBinaries(const std::filesystem::path& BundleDir, const std::st { ExceptionInfo Ex; m_ChildChannel->ReadException(Ex); + m_ExceptionMessage = Ex.Message; + m_ExceptionDescription = Ex.Description; ZEN_ERROR("upload exception: {} - {}", Ex.Message, Ex.Description); } else @@ -250,9 +252,8 @@ HordeAgent::Poll(bool LogOutput) { if (m_ChildChannel->GetResponseSize() == sizeof(int32_t)) { - int32_t ExitCode; - memcpy(&ExitCode, m_ChildChannel->GetResponseData(), sizeof(int32_t)); - ZEN_INFO("remote process exited with code {}", ExitCode); + memcpy(&m_ExitCode, m_ChildChannel->GetResponseData(), sizeof(int32_t)); + ZEN_INFO("remote process exited with code {}", m_ExitCode); } m_IsValid = false; return false; @@ -262,6 +263,8 @@ HordeAgent::Poll(bool LogOutput) { ExceptionInfo Ex; m_ChildChannel->ReadException(Ex); + m_ExceptionMessage = Ex.Message; + m_ExceptionDescription = Ex.Description; ZEN_ERROR("exception: {} - {}", Ex.Message, Ex.Description); m_HasErrors = true; break; diff --git a/src/zenhorde/hordeagent.h b/src/zenhorde/hordeagent.h index e0ae89ead..bff0dd9de 100644 --- a/src/zenhorde/hordeagent.h +++ b/src/zenhorde/hordeagent.h @@ -36,12 +36,14 @@ public: /** Perform the channel setup handshake (Attach on agent channel, Fork, Attach on child channel). * Returns false if the handshake times out or receives an unexpected message. */ - bool BeginCommunication(); + [[nodiscard]] bool BeginCommunication(); + + void CloseConnection(); /** Upload binary files to the remote agent. * @param BundleDir Directory containing .blob files. * @param BundleLocator Locator string identifying the bundle (from CreateBundle). */ - bool UploadBinaries(const std::filesystem::path& BundleDir, const std::string& BundleLocator); + [[nodiscard]] bool UploadBinaries(const std::filesystem::path& BundleDir, const std::string& BundleLocator); /** Execute a command on the remote machine. */ void Execute(const char* Exe, @@ -54,12 +56,13 @@ public: /** Poll for output and results. Returns true if the agent is still running. * When LogOutput is true, remote stdout is logged via ZEN_INFO. */ - bool Poll(bool LogOutput = true); - - void CloseConnection(); - bool IsValid() const; + [[nodiscard]] bool Poll(bool LogOutput = true); - const MachineInfo& GetMachineInfo() const { return m_MachineInfo; } + [[nodiscard]] bool IsValid() const; + [[nodiscard]] const MachineInfo& GetMachineInfo() const { return m_MachineInfo; } + [[nodiscard]] int32_t GetExitCode() const { return m_ExitCode; } + [[nodiscard]] const std::string& GetExceptionMessage() const { return m_ExceptionMessage; } + [[nodiscard]] const std::string& GetExceptionDescription() const { return m_ExceptionDescription; } private: LoggerRef Log() { return m_Log; } @@ -71,6 +74,9 @@ private: LoggerRef m_Log; bool m_IsValid = false; bool m_HasErrors = false; + int32_t m_ExitCode = 0; + std::string m_ExceptionMessage; + std::string m_ExceptionDescription; MachineInfo m_MachineInfo; }; diff --git a/src/zenhorde/hordeclient.cpp b/src/zenhorde/hordeclient.cpp index 00edc8f1c..da85e78ec 100644 --- a/src/zenhorde/hordeclient.cpp +++ b/src/zenhorde/hordeclient.cpp @@ -15,7 +15,7 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen::horde { -HordeClient::HordeClient(const HordeConfig& Config) : m_Config(Config), m_Log(zen::logging::Get("horde.client")) +HordeClient::HordeClient(HordeConfig Config) : m_Config(std::move(Config)), m_Log("horde.client") { } diff --git a/src/zenhorde/hordeprovisioner.cpp b/src/zenhorde/hordeprovisioner.cpp index 5ad9d46d0..52f6630e6 100644 --- a/src/zenhorde/hordeprovisioner.cpp +++ b/src/zenhorde/hordeprovisioner.cpp @@ -602,14 +602,10 @@ HordeProvisioner::ThreadAgent(AgentWrapper& Wrapper) // Build command line for remote zenserver std::vector<std::string> ArgStrings; - ArgStrings.push_back("compute"); - ArgStrings.push_back("--http=asio"); - - // TEMP HACK - these should be made fully dynamic - // these are currently here to allow spawning the compute agent locally - // for debugging purposes (i.e with a local Horde Server+Agent setup) + ArgStrings.emplace_back("compute"); + ArgStrings.emplace_back("--http=asio"); ArgStrings.push_back(fmt::format("--port={}", m_Config.ZenServicePort)); - ArgStrings.push_back("--data-dir=c:\\temp\\123"); + ArgStrings.emplace_back("--data-dir=%UE_HORDE_SHARED_DIR%\\zen"); if (!m_OrchestratorEndpoint.empty()) { diff --git a/src/zenhorde/include/zenhorde/hordeclient.h b/src/zenhorde/include/zenhorde/hordeclient.h index b6c352d09..87caec019 100644 --- a/src/zenhorde/include/zenhorde/hordeclient.h +++ b/src/zenhorde/include/zenhorde/hordeclient.h @@ -97,7 +97,7 @@ struct ClusterInfo class HordeClient { public: - explicit HordeClient(const HordeConfig& Config); + explicit HordeClient(HordeConfig Config); ~HordeClient(); HordeClient(const HordeClient&) = delete; |