summaryrefslogtreecommitdiff
path: root/src/buildtool/serve_api/serve_service/target.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-03-19 16:56:26 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-03-19 17:39:18 +0100
commit62ceea46f33fe6a6704b40aaa2c980c8b29eff5e (patch)
treefde64d5ff8f739b1dc7de8c48f45dadf1b869a87 /src/buildtool/serve_api/serve_service/target.cpp
parentc5344fadd9a032171eed799aa1d91dc9247c810f (diff)
downloadjustbuild-62ceea46f33fe6a6704b40aaa2c980c8b29eff5e.tar.gz
serve target: Fix sharding inconsistencies
When running in single node, serve endpoint should not even consider sharding. Additionally, garbage collection uplinking should also take the shard into account. For this purpose, a TargetCache instance now remembers if it was explicitly sharded and passed that information to the GarbageCollector for uplinking.
Diffstat (limited to 'src/buildtool/serve_api/serve_service/target.cpp')
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index 67102c49..c5b9aa60 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -180,13 +180,14 @@ auto TargetService::ServeTarget(
}
// get a target cache instance with the correct computed shard
- auto const& tc = Storage::Instance().TargetCache().WithShard(
- untagged_execution_backend.hash());
+ auto shard = address ? std::make_optional(untagged_execution_backend.hash())
+ : std::nullopt;
+ auto const& tc = Storage::Instance().TargetCache().WithShard(shard);
auto const& tc_key =
TargetCacheKey{{target_cache_key_digest, ObjectType::File}};
// check if target-level cache entry has already been computed
- if (auto target_entry = tc->Read(tc_key); target_entry) {
+ if (auto target_entry = tc.Read(tc_key); target_entry) {
// make sure all artifacts referenced in the target cache value are in
// the remote cas
@@ -413,7 +414,7 @@ auto TargetService::ServeTarget(
auto result = AnalyseTarget(configured_target,
&result_map,
&repository_config,
- *tc,
+ tc,
&stats,
RemoteServeConfig::Jobs(),
std::nullopt /*request_action_input*/,
@@ -528,7 +529,7 @@ auto TargetService::ServeTarget(
traverser.GetLocalApi(),
traverser.GetRemoteApi(),
RemoteServeConfig::TCStrategy(),
- *tc,
+ tc,
&logger,
true /*strict_logging*/);
@@ -565,7 +566,7 @@ auto TargetService::ServeTarget(
// now that the target cache key is in, make sure remote CAS has all
// required entries
- if (auto target_entry = tc->Read(tc_key); target_entry) {
+ if (auto target_entry = tc.Read(tc_key); target_entry) {
// make sure all artifacts referenced in the target cache value are in
// the remote cas
std::vector<Artifact::ObjectInfo> tc_artifacts;