summaryrefslogtreecommitdiff
path: root/src/buildtool/main
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/main
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/main')
-rw-r--r--src/buildtool/main/main.cpp1
-rw-r--r--src/buildtool/main/serve.cpp16
2 files changed, 17 insertions, 0 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 72a5b060..5acba963 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -192,6 +192,7 @@ void SetupLogging(LogArguments const& clargs) {
-> std::optional<RemoteServeConfig> {
RemoteServeConfig::Builder builder;
builder.SetRemoteAddress(srvargs.remote_serve_address)
+ .SetClientExecutionAddress(srvargs.client_remote_address)
.SetKnownRepositories(srvargs.repositories)
.SetJobs(cargs.jobs)
.SetActionTimeout(bargs.timeout)
diff --git a/src/buildtool/main/serve.cpp b/src/buildtool/main/serve.cpp
index 531074c3..5d5f49fb 100644
--- a/src/buildtool/main/serve.cpp
+++ b/src/buildtool/main/serve.cpp
@@ -415,6 +415,22 @@ void ReadJustServeConfig(gsl::not_null<CommandLineArguments*> const& clargs) {
}
clargs->endpoint.remote_execution_address = address->String();
}
+ // read the address used by the client
+ auto client_address =
+ exec_endpoint->Get("client address", Expression::none_t{});
+ if (client_address.IsNotNull()) {
+ if (not client_address->IsString()) {
+ Logger::Log(
+ LogLevel::Error,
+ "In serve service config file {}:\nValue for execution "
+ "endpoint key \"client address\" has to be a string, but "
+ "found {}",
+ clargs->serve.config.string(),
+ client_address->ToString());
+ std::exit(kExitFailure);
+ }
+ clargs->serve.client_remote_address = client_address->String();
+ }
if (not ParseRetryCliOptions(serve_config, &clargs->retry)) {
std::exit(kExitFailure);
}