SERVER-101032 Move clang-format into "bazel run format" (#36625)

GitOrigin-RevId: 14b3ac27154b9dfcbabaf6d296a6ee6e466d222a
This commit is contained in:
Zack Winter 2025-05-29 06:06:47 -07:00 committed by MongoDB Bot
parent 7ea796140e
commit cfdad5342e
20 changed files with 914 additions and 26 deletions

4
.gitattributes vendored
View File

@ -2,7 +2,11 @@
*.pbxproj -crlf -diff -merge *.pbxproj -crlf -diff -merge
*.sh text eol=lf *.sh text eol=lf
**/third_party/**/* rules-lint-ignored=true **/third_party/**/* rules-lint-ignored=true
**/third_party/**/BUILD.bazel rules-lint-ignored=false
external rules-lint-ignored=true external rules-lint-ignored=true
**/*.tpl.h rules-lint-ignored=true
**/*.tpl.cpp rules-lint-ignored=true
src/mongo/bson/column/bson_column_compressed_data.inl rules-lint-ignored=true
*.idl linguist-language=yaml *.idl linguist-language=yaml
MODULE.bazel.lock rules-lint-ignored=true linguist-generated MODULE.bazel.lock rules-lint-ignored=true linguist-generated

View File

@ -32,6 +32,8 @@ py_binary(
format_multirun( format_multirun(
name = "rules_lint_format", name = "rules_lint_format",
c = "//:clang_format",
cc = "//:clang_format",
css = "//:prettier", css = "//:prettier",
graphql = "//:prettier", graphql = "//:prettier",
html = "//:prettier", html = "//:prettier",
@ -39,9 +41,6 @@ format_multirun(
sql = "//:prettier", sql = "//:prettier",
starlark = "@buildifier_prebuilt//:buildifier", starlark = "@buildifier_prebuilt//:buildifier",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
# TODO(SERVER-101033): Enable clang_format once a way to only format a user's changeset is set up
# cc = "//:clang_format",
# c = "//:clang_format",
# TODO(SERVER-101034): Enable rules_lint shfmt after sh files are reformatted with .editorconfig # TODO(SERVER-101034): Enable rules_lint shfmt after sh files are reformatted with .editorconfig
# shell = "@shfmt//:shfmt", # shell = "@shfmt//:shfmt",
) )

View File

@ -2,12 +2,56 @@ import argparse
import os import os
import pathlib import pathlib
import subprocess import subprocess
from typing import List, Union
from buildscripts.unittest_grouper import validate_bazel_groups from buildscripts.unittest_grouper import validate_bazel_groups
def _git_distance(args: list) -> int:
command = ["git", "rev-list", "--count"] + args
result = subprocess.run(command, capture_output=True, text=True, check=True)
return int(result.stdout.strip())
def _get_merge_base(args: list) -> str:
command = ["git", "merge-base"] + args
result = subprocess.run(command, capture_output=True, text=True, check=True)
return result.stdout.strip()
def _git_diff(args: list) -> str:
command = ["git", "diff"] + args
result = subprocess.run(command, capture_output=True, text=True, check=True)
return result.stdout.strip() + os.linesep
def _get_files_changed_since_fork_point(origin_branch: str = "origin/master") -> List[str]:
"""Query git to get a list of files in the repo from a diff."""
# There are 3 diffs we run:
# 1. List of commits between origin/master and HEAD of current branch
# 2. Cached/Staged files (--cached)
# 3. Working Tree files git tracks
fork_point = _get_merge_base(["HEAD", origin_branch])
diff_files = _git_diff(["--name-only", f"{fork_point}..HEAD"])
diff_files += _git_diff(["--name-only", "--cached"])
diff_files += _git_diff(["--name-only"])
file_set = {
os.path.normpath(os.path.join(os.curdir, line.rstrip()))
for line in diff_files.splitlines()
if line
}
return list(file_set)
def run_rules_lint( def run_rules_lint(
rules_lint_format_path: pathlib.Path, rules_lint_format_check_path: pathlib.Path, check: bool rules_lint_format_path: pathlib.Path,
rules_lint_format_check_path: pathlib.Path,
check: bool,
files_to_format: Union[List[str], str] = "all",
) -> bool: ) -> bool:
try: try:
if check: if check:
@ -16,6 +60,8 @@ def run_rules_lint(
else: else:
command = [str(rules_lint_format_path)] command = [str(rules_lint_format_path)]
print("Running rules_lint formatter") print("Running rules_lint formatter")
if files_to_format != "all":
command += files_to_format
repo_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) repo_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
subprocess.run(command, check=True, env=os.environ, cwd=repo_path) subprocess.run(command, check=True, env=os.environ, cwd=repo_path)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
@ -38,7 +84,9 @@ def run_shellscripts_linters(shellscripts_linters: pathlib.Path, check: bool) ->
return True return True
def run_prettier(prettier: pathlib.Path, check: bool) -> bool: def run_prettier(
prettier: pathlib.Path, check: bool, files_to_format: Union[List[str], str] = "all"
) -> bool:
# Explicitly ignore anything in the output directories or any symlinks in the root of the repository # Explicitly ignore anything in the output directories or any symlinks in the root of the repository
# to prevent bad symlinks from failing the run, see https://github.com/prettier/prettier/issues/11568 as # to prevent bad symlinks from failing the run, see https://github.com/prettier/prettier/issues/11568 as
# to why it the paths being present in .prettierignore isn't sufficient # to why it the paths being present in .prettierignore isn't sufficient
@ -56,10 +104,14 @@ def run_prettier(prettier: pathlib.Path, check: bool) -> bool:
command = [ command = [
str(prettier), str(prettier),
"--cache", "--cache",
".",
"--log-level", "--log-level",
"warn", "warn",
] + list(force_exclude_dirs) ]
if files_to_format == "all":
command += ["."]
else:
command += files_to_format
command += list(force_exclude_dirs)
if check: if check:
command.append("--check") command.append("--check")
else: else:
@ -118,6 +170,16 @@ def main() -> int:
required=True, required=True,
type=pathlib.Path, type=pathlib.Path,
) )
parser.add_argument(
"--all",
help="Format all files instead of just formatting files that have changed since the fork point",
action="store_true",
)
parser.add_argument(
"--origin-branch",
help="The branch to use as the fork point for changed files",
default="origin/master",
)
args = parser.parse_args() args = parser.parse_args()
prettier_path: pathlib.Path = args.prettier.resolve() prettier_path: pathlib.Path = args.prettier.resolve()
@ -125,13 +187,39 @@ def main() -> int:
os.chdir(default_dir) os.chdir(default_dir)
validate_bazel_groups(generate_report=True, fix=not args.check) distance = _git_distance([f"{args.origin_branch}..HEAD"])
if distance > 100:
print(
f"The number of commits between current branch and origin branch ({args.origin_branch}) is too large: {distance} commits"
)
print("WARNING!!! Defaulting to formatting all files, this may take a while.")
print(
"Please update your local branch with the latest changes from origin, or use `bazel run format -- --origin-branch other_branch` to select a different origin branch"
)
args.all = True
files_to_format = (
_get_files_changed_since_fork_point(args.origin_branch) if not args.all else "all"
)
def files_to_format_contains_bazel_file(files: Union[List[str], str]) -> bool:
if files == "all":
return True
return any(file.endswith(".bazel") or "BUILD" in file for file in files)
if files_to_format_contains_bazel_file(files_to_format):
validate_bazel_groups(generate_report=True, fix=not args.check)
if files_to_format != "all":
files_to_format = [str(file) for file in files_to_format if os.path.isfile(file)]
return ( return (
0 0
if run_rules_lint(args.rules_lint_format, args.rules_lint_format_check, args.check) if run_rules_lint(
args.rules_lint_format, args.rules_lint_format_check, args.check, files_to_format
)
and run_shellscripts_linters(shellscripts_linters_path, args.check) and run_shellscripts_linters(shellscripts_linters_path, args.check)
and run_prettier(prettier_path, args.check) and run_prettier(prettier_path, args.check, files_to_format)
else 1 else 1
) )

View File

@ -245,3 +245,8 @@ py_binary(
), ),
], ],
) )
sh_binary(
name = "setup_node_env",
srcs = ["setup_node_env.sh"],
)

View File

@ -1,8 +1,9 @@
// C++ compilation file used for testing bazel compilation. // C++ compilation file used for testing bazel compilation.
#include <dlfcn.h>
#include <iostream> #include <iostream>
#include <dlfcn.h>
int main() { int main() {
void* tcmalloc_so = dlopen( void* tcmalloc_so = dlopen(
"/home/ubuntu/mongo/bazel-bin/_solib_arm64/" "/home/ubuntu/mongo/bazel-bin/_solib_arm64/"

View File

@ -354,7 +354,7 @@ int main(int argc, char** argv) {
} }
} }
} }
found_symbol:; found_symbol:;
} }
if (found_symbol_dep == 1) { if (found_symbol_dep == 1) {
// delete the last comma // delete the last comma

View File

@ -0,0 +1,6 @@
package(default_visibility = ["//visibility:public"])
sh_binary(
name = "setup_node_env",
srcs = ["setup_node_env.sh"],
)

View File

@ -0,0 +1,16 @@
package(default_visibility = ["//visibility:public"])
sh_binary(
name = "kafka_missing_version_import",
srcs = ["kafka_missing_version_import.sh"],
)
sh_binary(
name = "kafka_valid_import",
srcs = ["kafka_valid_import.sh"],
)
sh_binary(
name = "kafka_wrong_version_import",
srcs = ["kafka_wrong_version_import.sh"],
)

View File

@ -613,7 +613,7 @@ tasks:
- func: "bazel run" - func: "bazel run"
vars: vars:
target: >- target: >-
//:format -- --check //:format -- --check --all
- name: bazel_run_codeowners - name: bazel_run_codeowners
tags: tags:

View File

@ -1,9 +1,10 @@
/** /**
* Sample file to demonstrate various clang-format messages * Sample file to demonstrate various clang-format messages
*/ */
#include <stdio.h>
#include <vector>
#include <string> #include <string>
#include <vector>
#include <stdio.h>
// NamespaceIndentation: None // NamespaceIndentation: None
namespace foo { namespace foo {
@ -13,9 +14,10 @@ int foo;
namespace bar { namespace bar {
int bar; int bar;
namespace { namespace {
int anony; int anony;
} // namespace anony } // namespace
} // namespace bar } // namespace bar

View File

@ -1,6 +1,562 @@
package(default_visibility = ["//visibility:public"])
py_binary( py_binary(
name = "validate_compile_commands", name = "validate_compile_commands",
srcs = ["validate_compile_commands.py"], srcs = ["validate_compile_commands.py"],
main = "validate_compile_commands.py", main = "validate_compile_commands.py",
visibility = ["//visibility:public"], )
sh_binary(
name = "wiki_page_minimized_agg_query_fuzzer",
srcs = ["wiki_page_minimized_agg_query_fuzzer.sh"],
)
sh_binary(
name = "antithesis_image_build_and_push",
srcs = ["antithesis_image_build_and_push.sh"],
)
sh_binary(
name = "bazel_RBE_supported",
srcs = ["bazel_RBE_supported.sh"],
)
sh_binary(
name = "bazel_compile",
srcs = ["bazel_compile.sh"],
)
sh_binary(
name = "bazel_coverage",
srcs = ["bazel_coverage.sh"],
)
sh_binary(
name = "bazel_get_binary_path",
srcs = ["bazel_get_binary_path.sh"],
)
sh_binary(
name = "bazel_run",
srcs = ["bazel_run.sh"],
)
sh_binary(
name = "bazel_scons_diff",
srcs = ["bazel_scons_diff.sh"],
)
sh_binary(
name = "bazel_utility_functions",
srcs = ["bazel_utility_functions.sh"],
)
sh_binary(
name = "check_idl_compat",
srcs = ["check_idl_compat.sh"],
)
sh_binary(
name = "check_legacy_command_types",
srcs = ["check_legacy_command_types.sh"],
)
sh_binary(
name = "check_resmoke_failure",
srcs = ["check_resmoke_failure.sh"],
)
sh_binary(
name = "check_run_tests_infrastructure_failure",
srcs = ["check_run_tests_infrastructure_failure.sh"],
)
sh_binary(
name = "cleanup_environment",
srcs = ["cleanup_environment.sh"],
)
sh_binary(
name = "compile_ninja",
srcs = ["compile_ninja.sh"],
)
sh_binary(
name = "compiled_binaries_get",
srcs = ["compiled_binaries_get.sh"],
)
sh_binary(
name = "consolidate_benchmark_txt",
srcs = ["consolidate_benchmark_txt.sh"],
)
sh_binary(
name = "container_registry_login",
srcs = ["container_registry_login.sh"],
)
sh_binary(
name = "crypt_run_tests",
srcs = ["crypt_run_tests.sh"],
)
sh_binary(
name = "do_watchdog_setup",
srcs = ["do_watchdog_setup.sh"],
)
sh_binary(
name = "download_tlc",
srcs = ["download_tlc.sh"],
)
sh_binary(
name = "engflow_workspace_status",
srcs = ["engflow_workspace_status.sh"],
)
sh_binary(
name = "external_auth_aws_setup",
srcs = ["external_auth_aws_setup.sh"],
)
sh_binary(
name = "external_auth_azure_setup",
srcs = ["external_auth_azure_setup.sh"],
)
sh_binary(
name = "external_auth_azure_teardown",
srcs = ["external_auth_azure_teardown.sh"],
)
sh_binary(
name = "external_auth_gcp_setup",
srcs = ["external_auth_gcp_setup.sh"],
)
sh_binary(
name = "external_auth_gcp_teardown",
srcs = ["external_auth_gcp_teardown.sh"],
)
sh_binary(
name = "external_auth_oidc_setup",
srcs = ["external_auth_oidc_setup.sh"],
)
sh_binary(
name = "external_auth_oidc_teardown",
srcs = ["external_auth_oidc_teardown.sh"],
)
sh_binary(
name = "extract_generated_test_configuration",
srcs = ["extract_generated_test_configuration.sh"],
)
sh_binary(
name = "failed_unittests_gather",
srcs = ["failed_unittests_gather.sh"],
)
sh_binary(
name = "fcv_test_git_tag",
srcs = ["fcv_test_git_tag.sh"],
)
sh_binary(
name = "feature_flag_tags_check",
srcs = ["feature_flag_tags_check.sh"],
)
sh_binary(
name = "garasign_gpg_crypt_sign",
srcs = ["garasign_gpg_crypt_sign.sh"],
)
sh_binary(
name = "garasign_gpg_sign",
srcs = ["garasign_gpg_sign.sh"],
)
sh_binary(
name = "garasign_jsign_sign",
srcs = ["garasign_jsign_sign.sh"],
)
sh_binary(
name = "gather_mongo_coredumps",
srcs = ["gather_mongo_coredumps.sh"],
)
sh_binary(
name = "gen_feature_flags",
srcs = ["gen_feature_flags.sh"],
)
sh_binary(
name = "gen_supplementary_data",
srcs = ["gen_supplementary_data.sh"],
)
sh_binary(
name = "gen_tasks_activate",
srcs = ["gen_tasks_activate.sh"],
)
sh_binary(
name = "generate_buildid_debug_symbols_mapping",
srcs = ["generate_buildid_debug_symbols_mapping.sh"],
)
sh_binary(
name = "generate_evergreen_bazelrc",
srcs = ["generate_evergreen_bazelrc.sh"],
)
sh_binary(
name = "generate_version",
srcs = ["generate_version.sh"],
)
sh_binary(
name = "generate_version_burn_in",
srcs = ["generate_version_burn_in.sh"],
)
sh_binary(
name = "get_bin_and_fcv_versions",
srcs = ["get_bin_and_fcv_versions.sh"],
)
sh_binary(
name = "hang_analyzer",
srcs = ["hang_analyzer.sh"],
)
sh_binary(
name = "idl_tests_run",
srcs = ["idl_tests_run.sh"],
)
sh_binary(
name = "jepsen_report",
srcs = ["jepsen_report.sh"],
)
sh_binary(
name = "jepsen_test_fail",
srcs = ["jepsen_test_fail.sh"],
)
sh_binary(
name = "jepsen_test_run",
srcs = ["jepsen_test_run.sh"],
)
sh_binary(
name = "jstestfuzz_minimize",
srcs = ["jstestfuzz_minimize.sh"],
)
sh_binary(
name = "jstestfuzz_run",
srcs = ["jstestfuzz_run.sh"],
)
sh_binary(
name = "jstestfuzz_setup",
srcs = ["jstestfuzz_setup.sh"],
)
sh_binary(
name = "kill_processes",
srcs = ["kill_processes.sh"],
)
sh_binary(
name = "libdeps_run",
srcs = ["libdeps_run.sh"],
)
sh_binary(
name = "libdeps_setup",
srcs = ["libdeps_setup.sh"],
)
sh_binary(
name = "lint_fuzzer_sanity_all",
srcs = ["lint_fuzzer_sanity_all.sh"],
)
sh_binary(
name = "lint_fuzzer_sanity_patch",
srcs = ["lint_fuzzer_sanity_patch.sh"],
)
sh_binary(
name = "lint_shellscripts",
srcs = ["lint_shellscripts.sh"],
)
sh_binary(
name = "lint_yaml",
srcs = ["lint_yaml.sh"],
)
sh_binary(
name = "local_client_logs_tar",
srcs = ["local_client_logs_tar.sh"],
)
sh_binary(
name = "modify_debug_symbols",
srcs = ["modify_debug_symbols.sh"],
)
sh_binary(
name = "monitor_build_status_run",
srcs = ["monitor_build_status_run.sh"],
)
sh_binary(
name = "move_npm_logs",
srcs = ["move_npm_logs.sh"],
)
sh_binary(
name = "multiversion_exclude_tags_generate",
srcs = ["multiversion_exclude_tags_generate.sh"],
)
sh_binary(
name = "multiversion_setup",
srcs = ["multiversion_setup.sh"],
)
sh_binary(
name = "ninja_compile",
srcs = ["ninja_compile.sh"],
)
sh_binary(
name = "package",
srcs = ["package.sh"],
)
sh_binary(
name = "packager.py_run",
srcs = ["packager.py_run.sh"],
)
sh_binary(
name = "packages_publish",
srcs = ["packages_publish.sh"],
)
sh_binary(
name = "papertrail_generate_expansions",
srcs = ["papertrail_generate_expansions.sh"],
)
sh_binary(
name = "powercycle_check_host",
srcs = ["powercycle_check_host.sh"],
)
sh_binary(
name = "powercycle_exit",
srcs = ["powercycle_exit.sh"],
)
sh_binary(
name = "powercycle_run_test",
srcs = ["powercycle_run_test.sh"],
)
sh_binary(
name = "powercycle_save_artifacts",
srcs = ["powercycle_save_artifacts.sh"],
)
sh_binary(
name = "powercycle_sentinel_run",
srcs = ["powercycle_sentinel_run.sh"],
)
sh_binary(
name = "powercycle_setup_host",
srcs = ["powercycle_setup_host.sh"],
)
sh_binary(
name = "powercycle_ssh_failure_exit",
srcs = ["powercycle_ssh_failure_exit.sh"],
)
sh_binary(
name = "powercycle_tasks_generate",
srcs = ["powercycle_tasks_generate.sh"],
)
sh_binary(
name = "prelude",
srcs = ["prelude.sh"],
)
sh_binary(
name = "prelude_db_contrib_tool",
srcs = ["prelude_db_contrib_tool.sh"],
)
sh_binary(
name = "prelude_mongo_task_generator",
srcs = ["prelude_mongo_task_generator.sh"],
)
sh_binary(
name = "prelude_python",
srcs = ["prelude_python.sh"],
)
sh_binary(
name = "prelude_system_env_variables",
srcs = ["prelude_system_env_variables.sh"],
)
sh_binary(
name = "prelude_venv",
srcs = ["prelude_venv.sh"],
)
sh_binary(
name = "prelude_workdir",
srcs = ["prelude_workdir.sh"],
)
sh_binary(
name = "query_tester_test_repo_setup",
srcs = ["query_tester_test_repo_setup.sh"],
)
sh_binary(
name = "query_tester_test_sparse_checkout",
srcs = ["query_tester_test_sparse_checkout.sh"],
)
sh_binary(
name = "randomized_multiversion_tasks_generate",
srcs = ["randomized_multiversion_tasks_generate.sh"],
)
sh_binary(
name = "record_mongodb_server_version",
srcs = ["record_mongodb_server_version.sh"],
)
sh_binary(
name = "resmoke_tests_execute",
srcs = ["resmoke_tests_execute.sh"],
)
sh_binary(
name = "resmoke_tests_runtime_validate",
srcs = ["resmoke_tests_runtime_validate.sh"],
)
sh_binary(
name = "restore_git_history_and_tags",
srcs = ["restore_git_history_and_tags.sh"],
)
sh_binary(
name = "run_python_script",
srcs = ["run_python_script.sh"],
)
sh_binary(
name = "run_python_script_with_report",
srcs = ["run_python_script_with_report.sh"],
)
sh_binary(
name = "run_upload_lock_push",
srcs = ["run_upload_lock_push.sh"],
)
sh_binary(
name = "sasl_windows_cyrussasl_setup",
srcs = ["sasl_windows_cyrussasl_setup.sh"],
)
sh_binary(
name = "sasl_windows_cyrussasl_teardown",
srcs = ["sasl_windows_cyrussasl_teardown.sh"],
)
sh_binary(
name = "scons_compile",
srcs = ["scons_compile.sh"],
)
sh_binary(
name = "scons_raw_compile",
srcs = ["scons_raw_compile.sh"],
)
sh_binary(
name = "scons_splunk",
srcs = ["scons_splunk.sh"],
)
sh_binary(
name = "selinux_run_test",
srcs = ["selinux_run_test.sh"],
)
sh_binary(
name = "selinux_test_executor",
srcs = ["selinux_test_executor.sh"],
)
sh_binary(
name = "selinux_test_setup",
srcs = ["selinux_test_setup.sh"],
)
sh_binary(
name = "stitch_support_create_lib_tar",
srcs = ["stitch_support_create_lib_tar.sh"],
)
sh_binary(
name = "stitch_support_run_tests",
srcs = ["stitch_support_run_tests.sh"],
)
sh_binary(
name = "todos_check",
srcs = ["todos_check.sh"],
)
sh_binary(
name = "verify_build_output_present",
srcs = ["verify_build_output_present.sh"],
)
sh_binary(
name = "wait_for_resmoke_to_shutdown",
srcs = ["wait_for_resmoke_to_shutdown.sh"],
)
sh_binary(
name = "wiki_page",
srcs = ["wiki_page.sh"],
)
sh_binary(
name = "write_mongo_binary_url_to_downstream_expansions",
srcs = ["write_mongo_binary_url_to_downstream_expansions.sh"],
) )

View File

@ -0,0 +1,26 @@
package(default_visibility = ["//visibility:public"])
sh_binary(
name = "build_libfaketime",
srcs = ["build_libfaketime.sh"],
)
sh_binary(
name = "create_fuzz_config",
srcs = ["create_fuzz_config.sh"],
)
sh_binary(
name = "install_jepsen",
srcs = ["install_jepsen.sh"],
)
sh_binary(
name = "move_binaries",
srcs = ["move_binaries.sh"],
)
sh_binary(
name = "nodes",
srcs = ["nodes.sh"],
)

View File

@ -0,0 +1,126 @@
package(default_visibility = ["//visibility:public"])
sh_binary(
name = "add_git_tag",
srcs = ["add_git_tag.sh"],
)
sh_binary(
name = "bolt",
srcs = ["bolt.sh"],
)
sh_binary(
name = "compile_expansions_generate",
srcs = ["compile_expansions_generate.sh"],
)
sh_binary(
name = "credentials_setup",
srcs = ["credentials_setup.sh"],
)
sh_binary(
name = "download_pgo_profile",
srcs = ["download_pgo_profile.sh"],
)
sh_binary(
name = "evergreen_api_credentials_configure",
srcs = ["evergreen_api_credentials_configure.sh"],
)
sh_binary(
name = "files_remove",
srcs = ["files_remove.sh"],
)
sh_binary(
name = "fuse_watchdog_cleanup",
srcs = ["fuse_watchdog_cleanup.sh"],
)
sh_binary(
name = "get_mongot_version",
srcs = ["get_mongot_version.sh"],
)
sh_binary(
name = "modified_patch_files_get_all",
srcs = ["modified_patch_files_get_all.sh"],
)
sh_binary(
name = "notary_client_credentials_setup",
srcs = ["notary_client_credentials_setup.sh"],
)
sh_binary(
name = "process_threads_monitor",
srcs = ["process_threads_monitor.sh"],
)
sh_binary(
name = "remote_credentials_setup",
srcs = ["remote_credentials_setup.sh"],
)
sh_binary(
name = "resmoke_jobs_determine",
srcs = ["resmoke_jobs_determine.sh"],
)
sh_binary(
name = "run_diskstats",
srcs = ["run_diskstats.sh"],
)
sh_binary(
name = "shared_scons_directory_umount",
srcs = ["shared_scons_directory_umount.sh"],
)
sh_binary(
name = "system_resource_info_collect",
srcs = ["system_resource_info_collect.sh"],
)
sh_binary(
name = "task_timeout_determine",
srcs = ["task_timeout_determine.sh"],
)
sh_binary(
name = "tmp_directory_umount",
srcs = ["tmp_directory_umount.sh"],
)
sh_binary(
name = "ulimit_info_collect",
srcs = ["ulimit_info_collect.sh"],
)
sh_binary(
name = "venv_adjust",
srcs = ["venv_adjust.sh"],
)
sh_binary(
name = "venv_setup",
srcs = ["venv_setup.sh"],
)
sh_binary(
name = "version_expansions_generate",
srcs = ["version_expansions_generate.sh"],
)
sh_binary(
name = "win_mount_script_setup",
srcs = ["win_mount_script_setup.sh"],
)
sh_binary(
name = "wiredtiger_develop_use",
srcs = ["wiredtiger_develop_use.sh"],
)

View File

@ -0,0 +1,26 @@
package(default_visibility = ["//visibility:public"])
sh_binary(
name = "cleanup",
srcs = ["cleanup.sh"],
)
sh_binary(
name = "docker-up",
srcs = ["docker-up.sh"],
)
sh_binary(
name = "list-append",
srcs = ["list-append.sh"],
)
sh_binary(
name = "setup",
srcs = ["setup.sh"],
)
sh_binary(
name = "setup_config_fuzzer",
srcs = ["setup_config_fuzzer.sh"],
)

View File

@ -0,0 +1,6 @@
package(default_visibility = ["//visibility:public"])
sh_binary(
name = "clone_repos",
srcs = ["clone_repos.sh"],
)

View File

@ -8,3 +8,8 @@ mongo_js_library(
"*.js", "*.js",
]), ]),
) )
sh_binary(
name = "localhost_cn_with_san",
srcs = ["localhost-cn-with-san.pem.sh"],
)

View File

@ -8,3 +8,8 @@ mongo_js_library(
"*.js", "*.js",
]), ]),
) )
sh_binary(
name = "mkcrl",
srcs = ["mkcrl.sh"],
)

View File

@ -8,3 +8,8 @@ mongo_js_library(
"*.js", "*.js",
]), ]),
) )
sh_binary(
name = "charybdefs_setup",
srcs = ["charybdefs_setup.sh"],
)

View File

@ -26,13 +26,12 @@
* exception statement from all source files in the program, then also delete * exception statement from all source files in the program, then also delete
* it in the license file. * it in the license file.
*/ */
#include "mongo/db/s/resharding/resharding_coordinator.h"
#include "mongo/db/generic_argument_util.h" #include "mongo/db/generic_argument_util.h"
#include "mongo/db/repl/wait_for_majority_service.h" #include "mongo/db/repl/wait_for_majority_service.h"
#include "mongo/db/s/balancer/balance_stats.h" #include "mongo/db/s/balancer/balance_stats.h"
#include "mongo/db/s/balancer/balancer_policy.h" #include "mongo/db/s/balancer/balancer_policy.h"
#include "mongo/db/s/config/sharding_catalog_manager.h" #include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/db/s/resharding/resharding_coordinator.h"
#include "mongo/db/s/resharding/resharding_coordinator_commit_monitor.h" #include "mongo/db/s/resharding/resharding_coordinator_commit_monitor.h"
#include "mongo/db/s/resharding/resharding_coordinator_observer.h" #include "mongo/db/s/resharding/resharding_coordinator_observer.h"
#include "mongo/db/s/resharding/resharding_coordinator_service.h" #include "mongo/db/s/resharding/resharding_coordinator_service.h"
@ -161,8 +160,7 @@ ReshardingCoordinator::ReshardingCoordinator(
_metrics->onStateTransition(boost::none, coordinatorDoc.getState()); _metrics->onStateTransition(boost::none, coordinatorDoc.getState());
} }
void ReshardingCoordinator::_installCoordinatorDoc( void ReshardingCoordinator::_installCoordinatorDoc(const ReshardingCoordinatorDocument& doc) {
const ReshardingCoordinatorDocument& doc) {
invariant(doc.getReshardingUUID() == _coordinatorDoc.getReshardingUUID()); invariant(doc.getReshardingUUID() == _coordinatorDoc.getReshardingUUID());
_coordinatorDoc = doc; _coordinatorDoc = doc;
} }
@ -1224,7 +1222,9 @@ void ReshardingCoordinator::_startCommitMonitor(
resharding::extractShardIdsFromParticipantEntries(_coordinatorDoc.getRecipientShards()), resharding::extractShardIdsFromParticipantEntries(_coordinatorDoc.getRecipientShards()),
**executor, **executor,
_ctHolder->getCommitMonitorToken(), _ctHolder->getCommitMonitorToken(),
_coordinatorDoc.getDemoMode() ? 0 : resharding::gReshardingDelayBeforeRemainingOperationTimeQueryMillis.load()); _coordinatorDoc.getDemoMode()
? 0
: resharding::gReshardingDelayBeforeRemainingOperationTimeQueryMillis.load());
_commitMonitorQuiesced = _commitMonitor->waitUntilRecipientsAreWithinCommitThreshold() _commitMonitorQuiesced = _commitMonitor->waitUntilRecipientsAreWithinCommitThreshold()
.thenRunOn(**executor) .thenRunOn(**executor)
@ -1602,7 +1602,9 @@ void ReshardingCoordinator::_updateCoordinatorDocStateAndCatalogEntries(
opCtx.get(), _metrics.get(), updatedCoordinatorDoc, boost::none); opCtx.get(), _metrics.get(), updatedCoordinatorDoc, boost::none);
// Update in-memory coordinator doc // Update in-memory coordinator doc
installCoordinatorDocOnStateTransition(opCtx.get(), resharding::getCoordinatorDoc(opCtx.get(), _coordinatorDoc.getReshardingUUID())); installCoordinatorDocOnStateTransition(
opCtx.get(),
resharding::getCoordinatorDoc(opCtx.get(), _coordinatorDoc.getReshardingUUID()));
} }
void ReshardingCoordinator::_updateCoordinatorDocStateAndCatalogEntries( void ReshardingCoordinator::_updateCoordinatorDocStateAndCatalogEntries(
@ -1621,7 +1623,8 @@ void ReshardingCoordinator::_removeOrQuiesceCoordinatorDocAndRemoveReshardingFie
auto updatedCoordinatorDoc = resharding::removeOrQuiesceCoordinatorDocAndRemoveReshardingFields( auto updatedCoordinatorDoc = resharding::removeOrQuiesceCoordinatorDocAndRemoveReshardingFields(
opCtx, opCtx,
_metrics.get(), _metrics.get(),
resharding::tryGetCoordinatorDoc(opCtx, _coordinatorDoc.getReshardingUUID()).value_or(_coordinatorDoc), resharding::tryGetCoordinatorDoc(opCtx, _coordinatorDoc.getReshardingUUID())
.value_or(_coordinatorDoc),
abortReason); abortReason);
// Update in-memory coordinator doc. // Update in-memory coordinator doc.
@ -2006,7 +2009,8 @@ void ReshardingCoordinator::_logStatsOnCompletion(bool success) {
statsBuilder.append("totals", totalsBuilder.obj()); statsBuilder.append("totals", totalsBuilder.obj());
bool hadCriticalSection = false; bool hadCriticalSection = false;
if (auto criticalSectionInterval = _metrics->getIntervalFor(resharding_metrics::TimedPhase::kCriticalSection)) { if (auto criticalSectionInterval =
_metrics->getIntervalFor(resharding_metrics::TimedPhase::kCriticalSection)) {
criticalSectionBuilder.append("interval", criticalSectionInterval->toBSON()); criticalSectionBuilder.append("interval", criticalSectionInterval->toBSON());
hadCriticalSection = true; hadCriticalSection = true;
} }
@ -2015,7 +2019,8 @@ void ReshardingCoordinator::_logStatsOnCompletion(bool success) {
hadCriticalSection = true; hadCriticalSection = true;
} }
if (hadCriticalSection) { if (hadCriticalSection) {
criticalSectionBuilder.append("totalWritesDuringCriticalSection", totalWritesDuringCriticalSection); criticalSectionBuilder.append("totalWritesDuringCriticalSection",
totalWritesDuringCriticalSection);
statsBuilder.append("criticalSection", criticalSectionBuilder.obj()); statsBuilder.append("criticalSection", criticalSectionBuilder.obj());
} }

View File

@ -0,0 +1,7 @@
package(default_visibility = ["//visibility:public"])
sh_binary(
name = "model_check",
srcs = ["model-check.sh"],
visibility = ["//visibility:public"],
)