diff options
Diffstat (limited to 'src/other_tools/just_mr/fetch.cpp')
-rw-r--r-- | src/other_tools/just_mr/fetch.cpp | 86 |
1 files changed, 58 insertions, 28 deletions
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index a47b02cf..81709f05 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -452,56 +452,86 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, nr_a != 0 and nr_gt != 0 ? " and " : "", nr_gt != 0 ? str_gt : std::string()); - // setup the APIs for archive fetches + // setup the APIs for archive fetches; only happens if in native mode auto remote_api = JustMR::Utils::GetRemoteApi(common_args.remote_execution_address, common_args.remote_serve_address, auth_args); IExecutionApi::Ptr local_api{std::make_unique<LocalApi>()}; + bool remote_compatible{common_args.compatible == true}; - // setup the API for serving trees of Git repos or archives + // setup the API for serving roots auto serve_api_exists = JustMR::Utils::SetupServeApi( common_args.remote_serve_address, auth_args); + // check configuration of the serve endpoint provided + if (serve_api_exists) { + // check the compatibility mode of the serve endpoint + auto compatible = ServeApi::IsCompatible(); + if (not compatible) { + Logger::Log(LogLevel::Warning, + "Checking compatibility configuration of the provided " + "serve endpoint failed. Serve endpoint ignored."); + serve_api_exists = false; + } + if (*compatible != remote_compatible) { + Logger::Log( + LogLevel::Warning, + "Provided serve endpoint operates in a different compatibility " + "mode than stated. Serve endpoint ignored."); + serve_api_exists = false; + } + // if we have a remote endpoint explicitly given by the user, it must + // match what the serve endpoint expects + if (remote_api and common_args.remote_execution_address and + not ServeApi::CheckServeRemoteExecution()) { + return kExitFetchError; // this check logs error on failure + } + } + // create async maps auto crit_git_op_ptr = std::make_shared<CriticalGitOpGuard>(); auto critical_git_op_map = CreateCriticalGitOpMap(crit_git_op_ptr); - auto content_cas_map = CreateContentCASMap( - common_args.just_mr_paths, - common_args.alternative_mirrors, - common_args.ca_info, - &critical_git_op_map, - serve_api_exists, + auto content_cas_map = + CreateContentCASMap(common_args.just_mr_paths, + common_args.alternative_mirrors, + common_args.ca_info, + &critical_git_op_map, + serve_api_exists, + &(*local_api), + (remote_api and not remote_compatible) + ? std::make_optional(&(*remote_api)) + : std::nullopt, + common_args.jobs); + + auto archive_fetch_map = CreateArchiveFetchMap( + &content_cas_map, + *fetch_dir, &(*local_api), - remote_api ? std::make_optional(&(*remote_api)) : std::nullopt, + (fetch_args.backup_to_remote and remote_api and not remote_compatible) + ? std::make_optional(&(*remote_api)) + : std::nullopt, common_args.jobs); - auto archive_fetch_map = - CreateArchiveFetchMap(&content_cas_map, - *fetch_dir, - &(*local_api), - (fetch_args.backup_to_remote and remote_api) - ? std::make_optional(&(*remote_api)) - : std::nullopt, - common_args.jobs); - auto import_to_git_map = CreateImportToGitMap(&critical_git_op_map, common_args.git_path->string(), *common_args.local_launcher, common_args.jobs); - auto git_tree_fetch_map = CreateGitTreeFetchMap( - &critical_git_op_map, - &import_to_git_map, - common_args.git_path->string(), - *common_args.local_launcher, - serve_api_exists, - &(*local_api), - remote_api ? std::make_optional(&(*remote_api)) : std::nullopt, - fetch_args.backup_to_remote, - common_args.jobs); + auto git_tree_fetch_map = + CreateGitTreeFetchMap(&critical_git_op_map, + &import_to_git_map, + common_args.git_path->string(), + *common_args.local_launcher, + serve_api_exists, + &(*local_api), + (remote_api and not remote_compatible) + ? std::make_optional(&(*remote_api)) + : std::nullopt, + fetch_args.backup_to_remote, + common_args.jobs); // set up progress observer JustMRProgress::Instance().SetTotal(static_cast<int>(nr_a + nr_gt)); |