diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-01-24 17:09:01 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-01-31 17:15:46 +0100 |
commit | 66df7f4956c6fe1823eb43d31c3cbac7d8716125 (patch) | |
tree | 3f8bf106b3e189eeb4cfa01f97e8f9bb18678406 /src/buildtool/serve_api/remote/source_tree_client.cpp | |
parent | 3dc81b4b5a89f4e37af45ec9954723c79c3017cf (diff) | |
download | justbuild-66df7f4956c6fe1823eb43d31c3cbac7d8716125.tar.gz |
just-mr: Failure in serve api root tree requests should be fatal
The requests to retrieve the tree of a commit, archive, or distdir
also set up those trees in a way that the serve endpoint can later
build against them, besides allowing just-mr to set up roots
locally. Therefore, if the witnessing entity (Git commit, content
blob, or distdir, respectively) is known to the serve endpoint,
then failing to set up the root tree there should result in a
failure also of the just-mr setup on the client side.
Diffstat (limited to 'src/buildtool/serve_api/remote/source_tree_client.cpp')
-rw-r--r-- | src/buildtool/serve_api/remote/source_tree_client.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/buildtool/serve_api/remote/source_tree_client.cpp b/src/buildtool/serve_api/remote/source_tree_client.cpp index 073181a0..8267df7f 100644 --- a/src/buildtool/serve_api/remote/source_tree_client.cpp +++ b/src/buildtool/serve_api/remote/source_tree_client.cpp @@ -64,8 +64,7 @@ SourceTreeClient::SourceTreeClient(std::string const& server, auto SourceTreeClient::ServeCommitTree(std::string const& commit_id, std::string const& subdir, - bool sync_tree) - -> std::optional<std::string> { + bool sync_tree) -> result_t { justbuild::just_serve::ServeCommitTreeRequest request{}; request.set_commit(commit_id); request.set_subdir(subdir); @@ -77,16 +76,18 @@ auto SourceTreeClient::ServeCommitTree(std::string const& commit_id, if (not status.ok()) { LogStatus(&logger_, LogLevel::Debug, status); - return std::nullopt; + return true; // fatal failure } if (response.status() != ::justbuild::just_serve::ServeCommitTreeResponse::OK) { logger_.Emit(LogLevel::Debug, "ServeCommitTree response returned with {}", static_cast<int>(response.status())); - return std::nullopt; + return /*fatal = */ ( + response.status() != + ::justbuild::just_serve::ServeCommitTreeResponse::NOT_FOUND); } - return response.tree(); + return response.tree(); // success } auto SourceTreeClient::ServeArchiveTree( @@ -94,7 +95,7 @@ auto SourceTreeClient::ServeArchiveTree( std::string const& archive_type, std::string const& subdir, std::optional<PragmaSpecial> const& resolve_symlinks, - bool sync_tree) -> std::optional<std::string> { + bool sync_tree) -> result_t { justbuild::just_serve::ServeArchiveTreeRequest request{}; request.set_content(content); request.set_archive_type(StringToArchiveType(archive_type)); @@ -109,22 +110,24 @@ auto SourceTreeClient::ServeArchiveTree( if (not status.ok()) { LogStatus(&logger_, LogLevel::Debug, status); - return std::nullopt; + return true; // fatal failure } if (response.status() != ::justbuild::just_serve::ServeArchiveTreeResponse::OK) { logger_.Emit(LogLevel::Debug, "ServeArchiveTree response returned with {}", static_cast<int>(response.status())); - return std::nullopt; + return /*fatal = */ ( + response.status() != + ::justbuild::just_serve::ServeArchiveTreeResponse::NOT_FOUND); } - return response.tree(); + return response.tree(); // success } auto SourceTreeClient::ServeDistdirTree( std::shared_ptr<std::unordered_map<std::string, std::string>> const& distfiles, - bool sync_tree) -> std::optional<std::string> { + bool sync_tree) -> result_t { justbuild::just_serve::ServeDistdirTreeRequest request{}; for (auto const& [k, v] : *distfiles) { auto* distfile = request.add_distfiles(); @@ -139,16 +142,18 @@ auto SourceTreeClient::ServeDistdirTree( if (not status.ok()) { LogStatus(&logger_, LogLevel::Debug, status); - return std::nullopt; + return true; // fatal failure } if (response.status() != ::justbuild::just_serve::ServeDistdirTreeResponse::OK) { logger_.Emit(LogLevel::Debug, "ServeDistdirTree response returned with {}", static_cast<int>(response.status())); - return std::nullopt; + return /*fatal = */ ( + response.status() != + ::justbuild::just_serve::ServeDistdirTreeResponse::NOT_FOUND); } - return response.tree(); + return response.tree(); // success } auto SourceTreeClient::ServeContent(std::string const& content) -> bool { |