aboutsummaryrefslogtreecommitdiff
path: root/zenserver/zenserver.cpp
diff options
context:
space:
mode:
authorJoe Kirchoff <[email protected]>2022-03-17 09:55:09 -0700
committerGitHub <[email protected]>2022-03-17 09:55:09 -0700
commit7466cb93fbb9f4082dc253a328222dac8bbe58e4 (patch)
tree2b60020b7ab15867bfabf135bf8217aabe553c6d /zenserver/zenserver.cpp
parentIntroduced basic validation of the clang-format version (diff)
downloadzen-7466cb93fbb9f4082dc253a328222dac8bbe58e4.tar.xz
zen-7466cb93fbb9f4082dc253a328222dac8bbe58e4.zip
Update horde compute to use Jupiter for storage (#60)
Diffstat (limited to 'zenserver/zenserver.cpp')
-rw-r--r--zenserver/zenserver.cpp81
1 files changed, 69 insertions, 12 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index a684272c4..0d9126334 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -279,15 +279,20 @@ public:
#endif
#if ZEN_WITH_COMPUTE_SERVICES
- ZEN_INFO("instantiating compute services");
+ if (ServerOptions.ComputeServiceEnabled)
+ {
+ ZEN_INFO("instantiating compute services");
- std::filesystem::path SandboxDir = m_DataRoot / "exec" / "sandbox";
- zen::CreateDirectories(SandboxDir);
- m_HttpLaunchService = std::make_unique<zen::HttpLaunchService>(*m_CasStore, SandboxDir);
+ std::filesystem::path SandboxDir = m_DataRoot / "exec" / "sandbox";
+ zen::CreateDirectories(SandboxDir);
+ m_HttpLaunchService = std::make_unique<zen::HttpLaunchService>(*m_CasStore, SandboxDir);
- std::filesystem::path ApplySandboxDir = m_DataRoot / "exec" / "apply";
- zen::CreateDirectories(ApplySandboxDir);
- m_HttpFunctionService = std::make_unique<zen::HttpFunctionService>(*m_CasStore, *m_CidStore, ApplySandboxDir);
+ InitializeCompute(ServerOptions);
+ }
+ else
+ {
+ ZEN_INFO("NOT instantiating compute services");
+ }
#endif // ZEN_WITH_COMPUTE_SERVICES
if (ServerOptions.StructuredCacheEnabled)
@@ -327,14 +332,14 @@ public:
m_Http->RegisterService(m_CasService);
#if ZEN_WITH_COMPUTE_SERVICES
- if (m_HttpLaunchService)
+ if (ServerOptions.ComputeServiceEnabled)
{
m_Http->RegisterService(*m_HttpLaunchService);
- }
- if (m_HttpFunctionService)
- {
- m_Http->RegisterService(*m_HttpFunctionService);
+ if (m_HttpFunctionService != nullptr)
+ {
+ m_Http->RegisterService(*m_HttpFunctionService);
+ }
}
#endif // ZEN_WITH_COMPUTE_SERVICES
@@ -360,6 +365,7 @@ public:
void InitializeState(const ZenServerOptions& ServerOptions);
void InitializeStructuredCache(const ZenServerOptions& ServerOptions);
+ void InitializeCompute(const ZenServerOptions& ServerOptions);
#if ZEN_ENABLE_MESH
void StartMesh(int BasePort)
@@ -821,6 +827,57 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions)
m_Http->RegisterService(*m_UpstreamService);
}
+void
+ZenServer::InitializeCompute(const ZenServerOptions& ServerOptions)
+{
+ ServerOptions;
+ const ZenUpstreamCacheConfig& UpstreamConfig = ServerOptions.UpstreamCacheConfig;
+
+ // Horde compute upstream
+ if (UpstreamConfig.HordeConfig.Url.empty() == false && UpstreamConfig.HordeConfig.Url.empty() == false)
+ {
+ std::string_view EndpointName = UpstreamConfig.HordeConfig.Name.empty() ? "Horde"sv : UpstreamConfig.HordeConfig.Name;
+
+ auto ComputeOptions =
+ zen::CloudCacheClientOptions{.Name = EndpointName,
+ .ServiceUrl = UpstreamConfig.HordeConfig.Url,
+ .ComputeCluster = UpstreamConfig.HordeConfig.Cluster,
+ .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds),
+ .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds),
+ .UseLegacyDdc = false};
+
+ auto ComputeAuthConfig = zen::UpstreamAuthConfig{.OAuthUrl = UpstreamConfig.HordeConfig.OAuthUrl,
+ .OAuthClientId = UpstreamConfig.HordeConfig.OAuthClientId,
+ .OAuthClientSecret = UpstreamConfig.HordeConfig.OAuthClientSecret,
+ .OpenIdProvider = UpstreamConfig.HordeConfig.OpenIdProvider,
+ .AccessToken = UpstreamConfig.HordeConfig.AccessToken};
+
+ auto StorageOptions =
+ zen::CloudCacheClientOptions{.Name = EndpointName,
+ .ServiceUrl = UpstreamConfig.JupiterConfig.Url,
+ .BlobStoreNamespace = UpstreamConfig.HordeConfig.Namespace,
+ .ConnectTimeout = std::chrono::milliseconds(UpstreamConfig.ConnectTimeoutMilliseconds),
+ .Timeout = std::chrono::milliseconds(UpstreamConfig.TimeoutMilliseconds)};
+
+ auto StorageAuthConfig = zen::UpstreamAuthConfig{.OAuthUrl = UpstreamConfig.JupiterConfig.OAuthUrl,
+ .OAuthClientId = UpstreamConfig.JupiterConfig.OAuthClientId,
+ .OAuthClientSecret = UpstreamConfig.JupiterConfig.OAuthClientSecret,
+ .OpenIdProvider = UpstreamConfig.JupiterConfig.OpenIdProvider,
+ .AccessToken = UpstreamConfig.JupiterConfig.AccessToken};
+
+ std::filesystem::path ApplySandboxDir = m_DataRoot / "exec" / "apply";
+ zen::CreateDirectories(ApplySandboxDir);
+ m_HttpFunctionService = std::make_unique<zen::HttpFunctionService>(*m_CasStore,
+ *m_CidStore,
+ ApplySandboxDir,
+ ComputeOptions,
+ StorageOptions,
+ ComputeAuthConfig,
+ StorageAuthConfig,
+ *m_AuthMgr);
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
class ZenEntryPoint