summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2025-02-04 12:54:19 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2025-02-05 10:42:00 +0100
commit4595a0e8f118db6c81aeb38e0b0286ee34d3bc40 (patch)
treef048f052b8c77cca150b1bb443566e833f976cdc /src
parent22af175ecace7b1cd804369c1447223211778683 (diff)
downloadjustbuild-4595a0e8f118db6c81aeb38e0b0286ee34d3bc40.tar.gz
just-mr gc-repo: support drop only
As opposed to the regular CAS/cache, for the git repository implicit in the repository cache we cannot guarantee that data from older generation is always promoted via hard links. Therefore, a certain amount of data can be duplicated between the repo-cache generations. In order to allow compacting storage to the minimum, add an option to gc-repo to only remove the older generation, without rotating.
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/just_mr/cli.hpp13
-rw-r--r--src/other_tools/just_mr/main.cpp10
2 files changed, 22 insertions, 1 deletions
diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp
index 0c3e63a9..96f7cba2 100644
--- a/src/other_tools/just_mr/cli.hpp
+++ b/src/other_tools/just_mr/cli.hpp
@@ -85,6 +85,10 @@ struct MultiRepoUpdateArguments {
std::vector<std::string> repos_to_update;
};
+struct MultiRepoGcArguments {
+ bool drop_only{false};
+};
+
struct MultiRepoJustSubCmdsArguments {
std::optional<std::string> subcmd_name{std::nullopt};
std::vector<std::string> additional_just_args;
@@ -124,6 +128,7 @@ struct CommandLineArguments {
MultiRepoSetupArguments setup;
MultiRepoFetchArguments fetch;
MultiRepoUpdateArguments update;
+ MultiRepoGcArguments gc;
MultiRepoJustSubCmdsArguments just_cmd;
MultiRepoRemoteAuthArguments auth;
ForwardOnlyArguments launch_fwd;
@@ -338,6 +343,14 @@ static inline void SetupMultiRepoUpdateArguments(
->type_name("");
}
+static inline void SetupMultiRepoGcArguments(
+ gsl::not_null<CLI::App*> const& app,
+ gsl::not_null<MultiRepoGcArguments*> const& clargs) {
+ app->add_flag("--drop-only",
+ clargs->drop_only,
+ "Only drop old repository generations");
+}
+
static inline auto SetupMultiRepoRemoteAuthArguments(
gsl::not_null<CLI::App*> const& app,
gsl::not_null<MultiRepoRemoteAuthArguments*> const& authargs) {
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index 28d4669f..d65cbb50 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -82,6 +82,13 @@ void SetupUpdateCommandArguments(
SetupMultiRepoUpdateArguments(app, &clargs->update);
}
+/// \brief Setup arguments for subcommand "just-mr gc-repo".
+void SetupUpdateGcArguments(
+ gsl::not_null<CLI::App*> const& app,
+ gsl::not_null<CommandLineArguments*> const& clargs) {
+ SetupMultiRepoGcArguments(app, &clargs->gc);
+}
+
/// \brief Setup arguments for subcommand "just-mr setup" and
/// "just-mr setup-env".
void SetupSetupCommandArguments(
@@ -133,6 +140,7 @@ void SetupSetupCommandArguments(
SetupSetupCommandArguments(cmd_setup_env, &clargs);
SetupFetchCommandArguments(cmd_fetch, &clargs);
SetupUpdateCommandArguments(cmd_update, &clargs);
+ SetupUpdateGcArguments(cmd_gc_repo, &clargs);
// for 'just' calls, allow extra arguments
cmd_do->allow_extras();
@@ -336,7 +344,7 @@ auto main(int argc, char* argv[]) -> int {
if (arguments.cmd == SubCommand::kGcRepo) {
return RepositoryGarbageCollector::TriggerGarbageCollection(
- *native_storage_config)
+ *native_storage_config, arguments.gc.drop_only)
? kExitSuccess
: kExitBuiltinCommandFailure;
}