summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-11-20 14:20:06 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-11-21 10:21:29 +0100
commita8d02eac0e6673dea6daa781bf1c31921ec5f63a (patch)
tree6287ca40ee26228c89f9b6ca50e200762ae8b759
parent37968f38e8dc07a27941c52204692c6f3254c22a (diff)
downloadjustbuild-a8d02eac0e6673dea6daa781bf1c31921ec5f63a.tar.gz
content_cas_map: Interrogate just serve endpoint also if doing pure fetch
Before trying to fetch an archive content from other non-local sources, check first the just serve endpoint.
-rw-r--r--src/other_tools/just_mr/fetch.cpp5
-rw-r--r--src/other_tools/just_mr/setup.cpp1
-rw-r--r--src/other_tools/ops_maps/TARGETS1
-rw-r--r--src/other_tools/ops_maps/content_cas_map.cpp17
-rw-r--r--src/other_tools/ops_maps/content_cas_map.hpp1
5 files changed, 25 insertions, 0 deletions
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp
index ade217f2..c4450c2a 100644
--- a/src/other_tools/just_mr/fetch.cpp
+++ b/src/other_tools/just_mr/fetch.cpp
@@ -274,11 +274,16 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
IExecutionApi::Ptr local_api{remote_api ? std::make_unique<LocalApi>()
: nullptr};
+ // setup the API for serving trees of Git repos or archives
+ auto serve_api_exists = JustMR::Utils::SetupServeApi(
+ common_args.remote_serve_address, auth_args);
+
// create async maps
auto content_cas_map =
CreateContentCASMap(common_args.just_mr_paths,
common_args.alternative_mirrors,
common_args.ca_info,
+ serve_api_exists,
local_api ? &(*local_api) : nullptr,
remote_api ? &(*remote_api) : nullptr,
common_args.jobs);
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp
index b71ae3bb..90070db1 100644
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -106,6 +106,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
CreateContentCASMap(common_args.just_mr_paths,
common_args.alternative_mirrors,
common_args.ca_info,
+ serve_api_exists,
local_api ? &(*local_api) : nullptr,
remote_api ? &(*remote_api) : nullptr,
common_args.jobs);
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS
index f30cdf22..5745f69c 100644
--- a/src/other_tools/ops_maps/TARGETS
+++ b/src/other_tools/ops_maps/TARGETS
@@ -70,6 +70,7 @@
[ ["src/other_tools/utils", "content"]
, ["src/buildtool/execution_api/local", "local"]
, ["src/buildtool/file_system", "file_storage"]
+ , ["src/buildtool/serve_api/remote", "serve_api"]
, ["src/buildtool/storage", "fs_utils"]
, ["src/other_tools/just_mr/progress_reporting", "statistics"]
, ["src/other_tools/just_mr/progress_reporting", "progress"]
diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp
index fe55e496..8b7eef20 100644
--- a/src/other_tools/ops_maps/content_cas_map.cpp
+++ b/src/other_tools/ops_maps/content_cas_map.cpp
@@ -15,6 +15,7 @@
#include "src/other_tools/ops_maps/content_cas_map.hpp"
#include "src/buildtool/file_system/file_storage.hpp"
+#include "src/buildtool/serve_api/remote/serve_api.hpp"
#include "src/buildtool/storage/fs_utils.hpp"
#include "src/buildtool/storage/storage.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
@@ -25,12 +26,14 @@
auto CreateContentCASMap(LocalPathsPtr const& just_mr_paths,
MirrorsPtr const& additional_mirrors,
CAInfoPtr const& ca_info,
+ bool serve_api_exists,
IExecutionApi* local_api,
IExecutionApi* remote_api,
std::size_t jobs) -> ContentCASMap {
auto ensure_in_cas = [just_mr_paths,
additional_mirrors,
ca_info,
+ serve_api_exists,
local_api,
remote_api](auto /*unused*/,
auto setter,
@@ -59,6 +62,20 @@ auto CreateContentCASMap(LocalPathsPtr const& just_mr_paths,
(*setter)(true);
return;
}
+ // check if content is known to remote serve service
+ if (serve_api_exists and
+ ServeApi::ContentInRemoteCAS(key.content)) {
+ // try to get content from remote CAS
+ if (remote_api != nullptr and local_api != nullptr and
+ remote_api->RetrieveToCas(
+ {Artifact::ObjectInfo{.digest = digest,
+ .type = ObjectType::File}},
+ local_api)) {
+ JustMRProgress::Instance().TaskTracker().Stop(key.origin);
+ (*setter)(true);
+ return;
+ }
+ }
}
// check if content is in remote CAS, if a remote is given
if (remote_api and local_api and remote_api->IsAvailable(digest) and
diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp
index e11286c7..c871c664 100644
--- a/src/other_tools/ops_maps/content_cas_map.hpp
+++ b/src/other_tools/ops_maps/content_cas_map.hpp
@@ -68,6 +68,7 @@ using ContentCASMap = AsyncMapConsumer<ArchiveContent, bool>;
[[nodiscard]] auto CreateContentCASMap(LocalPathsPtr const& just_mr_paths,
MirrorsPtr const& additional_mirrors,
CAInfoPtr const& ca_info,
+ bool serve_api_exists,
IExecutionApi* local_api,
IExecutionApi* remote_api,
std::size_t jobs) -> ContentCASMap;