summaryrefslogtreecommitdiff
path: root/src/buildtool/serve_api/remote/config.hpp
diff options
context:
space:
mode:
authorAlberto Sartori <alberto.sartori@huawei.com>2025-02-24 14:16:42 +0100
committerAlberto Sartori <alberto.sartori@huawei.com>2025-02-25 11:27:16 +0100
commit455003d0e924414db339395e8367166e7820c5da (patch)
tree54d117565ea7edf059f4a18ebb1aaceca764ec5c /src/buildtool/serve_api/remote/config.hpp
parente61131b18ad90e9fc067e6036cbcd6c64b28c986 (diff)
downloadjustbuild-455003d0e924414db339395e8367166e7820c5da.tar.gz
just serve: allow clients to access execution endpoint with a different address
To properly use `just serve`, both the client and the serve instance must talk to the very same execution endpoint. Typically, both the client and serve can reach out to the execution endpoint via the same IP address. However, it might be possible that the client and a serve instance know the same execution endpoint by means of differnet IP addresses. For example, the client knows the execution endpoint address through an _external_ IP address, while the serve instance, deployed within the same network infrastructure, only knows the _internal_ IP address. This patch adds the subkey `"client address"` -- of the key `"execution endpoint"` -- in the serve configuration file, to specify the alternative pair `address:port` used by the client.
Diffstat (limited to 'src/buildtool/serve_api/remote/config.hpp')
-rw-r--r--src/buildtool/serve_api/remote/config.hpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/buildtool/serve_api/remote/config.hpp b/src/buildtool/serve_api/remote/config.hpp
index 582727e0..82119828 100644
--- a/src/buildtool/serve_api/remote/config.hpp
+++ b/src/buildtool/serve_api/remote/config.hpp
@@ -34,9 +34,12 @@
struct RemoteServeConfig final {
class Builder;
- // Server address of remote execution.
+ // Server address of the serve endpoint.
std::optional<ServerAddress> const remote_address;
+ // Execution endpoint used by the client.
+ std::optional<ServerAddress> const client_execution_address;
+
// Known Git repositories to serve server.
std::vector<std::filesystem::path> const known_repositories;
@@ -56,6 +59,13 @@ struct RemoteServeConfig final {
class RemoteServeConfig::Builder final {
public:
// Set remote execution and cache address, unsets if parsing `address` fails
+ auto SetClientExecutionAddress(std::optional<std::string> value) noexcept
+ -> Builder& {
+ client_execution_address_ = std::move(value);
+ return *this;
+ }
+
+ // Set remote execution and cache address, unsets if parsing `address` fails
auto SetRemoteAddress(std::optional<std::string> value) noexcept
-> Builder& {
remote_address_ = std::move(value);
@@ -110,7 +120,15 @@ class RemoteServeConfig::Builder final {
*remote_address_)};
}
}
-
+ auto client_execution_address = default_config.client_execution_address;
+ if (client_execution_address_.has_value()) {
+ client_execution_address = ParseAddress(*client_execution_address_);
+ if (not client_execution_address) {
+ return unexpected{
+ fmt::format("Setting client execution address '{}' failed.",
+ *client_execution_address_)};
+ }
+ }
auto known_repositories = default_config.known_repositories;
if (known_repositories_.has_value()) {
try {
@@ -154,6 +172,7 @@ class RemoteServeConfig::Builder final {
return RemoteServeConfig{
.remote_address = std::move(remote_address),
+ .client_execution_address = std::move(client_execution_address),
.known_repositories = std::move(known_repositories),
.jobs = jobs,
.build_jobs = build_jobs,
@@ -162,9 +181,12 @@ class RemoteServeConfig::Builder final {
}
private:
- // Server address of remote execution.
+ // Server address of the serve endpoint.
std::optional<std::string> remote_address_;
+ // Execution endpoint used by the client.
+ std::optional<std::string> client_execution_address_;
+
// Known Git repositories to serve server.
std::optional<std::vector<std::filesystem::path>> known_repositories_;