From 1f2961aba622d1e790737c914a80d50863bef4bf Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 2 Nov 2023 07:04:09 -0700 Subject: [PATCH] Automated rollback of commit fc3460e92597091997fa4154173e2d4e973ede31. *** Reason for rollback *** Due to https://github.com/bazelbuild/bazel/issues/19749 *** Original change description *** Stablize and flip repository_cache_urls_as_default_canonical_id Introduced in #14268, this flag is very useful for bigger enterprise context where folks often version bumping dependencies without remembering to update the SHA256 of the downloaded file, leading to Bazel picking up older download entries from the repository cache. As we get more questions about this flag in Slack, marking it as stable and flip the default seems to be the r... *** RELNOTES: None PiperOrigin-RevId: 578840189 Change-Id: I390910b5dd838a4a1384c5d24cedde0b7c1b2b98 --- scripts/bootstrap/bootstrap.sh | 3 -- .../bazel/repository/RepositoryOptions.java | 5 +-- .../lib/blackbox/bazel/DefaultToolsSetup.java | 3 -- src/test/py/bazel/test_base.py | 3 -- .../bazel/bazel_repository_cache_test.sh | 43 ++----------------- src/test/shell/testenv.sh.tmpl | 3 -- 6 files changed, 6 insertions(+), 54 deletions(-) diff --git a/scripts/bootstrap/bootstrap.sh b/scripts/bootstrap/bootstrap.sh index 2e3b2c7375326e..87b9df5579cdbb 100755 --- a/scripts/bootstrap/bootstrap.sh +++ b/scripts/bootstrap/bootstrap.sh @@ -31,14 +31,11 @@ fi : ${JAVA_VERSION:="11"} -# TODO: remove `norepository_cache_urls_as_default_canonical_id` once all dependencies are mirrored. -# See https://github.com/bazelbuild/bazel/pull/19549 for more context. _BAZEL_ARGS="--spawn_strategy=standalone \ --nojava_header_compilation \ --strategy=Javac=worker --worker_quit_after_build --ignore_unsupported_sandboxing \ --compilation_mode=opt \ --repository_cache=derived/repository_cache \ - --norepository_cache_urls_as_default_canonical_id \ --extra_toolchains=//scripts/bootstrap:all \ --extra_toolchains=@bazel_tools//tools/python:autodetecting_toolchain \ --enable_bzlmod \ diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java index b67fa4843928b3..0e6a234a8c56f8 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java @@ -263,9 +263,8 @@ public Converter() { public CheckDirectDepsMode checkDirectDependencies; @Option( - name = "repository_cache_urls_as_default_canonical_id", - oldName = "experimental_repository_cache_urls_as_default_canonical_id", - defaultValue = "true", + name = "experimental_repository_cache_urls_as_default_canonical_id", + defaultValue = "false", documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS, effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, metadataTags = {OptionMetadataTag.EXPERIMENTAL}, diff --git a/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java b/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java index 47a19482fe42aa..916175736adce7 100644 --- a/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java +++ b/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java @@ -78,9 +78,6 @@ public void setup(BlackBoxTestContext context) throws IOException { String sharedRepoCache = System.getenv("REPOSITORY_CACHE"); if (sharedRepoCache != null) { lines.add("common --repository_cache=" + sharedRepoCache); - // TODO(sluongng): Remove this flag once all dependencies are mirrored. - // See https://github.com/bazelbuild/bazel/pull/19549 for more context. - lines.add("common --norepository_cache_urls_as_default_canonical_id"); if (OS.getCurrent() == OS.DARWIN) { // For reducing SSD usage on our physical Mac machines. lines.add("common --experimental_repository_cache_hardlinks"); diff --git a/src/test/py/bazel/test_base.py b/src/test/py/bazel/test_base.py index b7459b50939a6d..9366f97cf853cc 100644 --- a/src/test/py/bazel/test_base.py +++ b/src/test/py/bazel/test_base.py @@ -127,9 +127,6 @@ def setUp(self): shared_repo_cache = os.environ.get('REPOSITORY_CACHE') if shared_repo_cache: f.write('common --repository_cache={}\n'.format(shared_repo_cache)) - # TODO(sluongng): Remove this flag once all dependencies are mirrored. - # See https://github.com/bazelbuild/bazel/pull/19549 for more context. - f.write('common --norepository_cache_urls_as_default_canonical_id\n') if TestBase.IsDarwin(): # For reducing SSD usage on our physical Mac machines. f.write('common --experimental_repository_cache_hardlinks\n') diff --git a/src/test/shell/bazel/bazel_repository_cache_test.sh b/src/test/shell/bazel/bazel_repository_cache_test.sh index d52d4bfbfbc7bb..28235a0557c272 100755 --- a/src/test/shell/bazel/bazel_repository_cache_test.sh +++ b/src/test/shell/bazel/bazel_repository_cache_test.sh @@ -494,18 +494,18 @@ EOF || echo "Expected fetch to succeed" } -function test_repository_cache_urls_as_default_canonical_id() { +function test_experimental_repository_cache_urls_as_default_canonical_id() { setup_repository bazel fetch --repository_cache="$repo_cache_dir" \ - --repository_cache_urls_as_default_canonical_id \ + --experimental_repository_cache_urls_as_default_canonical_id \ //zoo:breeding-program >& $TEST_log \ || echo "Expected fetch to succeed" shutdown_server bazel fetch --repository_cache="$repo_cache_dir" \ - --repository_cache_urls_as_default_canonical_id \ + --experimental_repository_cache_urls_as_default_canonical_id \ //zoo:breeding-program >& $TEST_log \ || echo "Expected fetch to succeed" @@ -524,44 +524,9 @@ EOF # As repository cache key should depend on urls, we expect fetching to fail now. bazel fetch --repository_cache="$repo_cache_dir" \ - --repository_cache_urls_as_default_canonical_id \ + --experimental_repository_cache_urls_as_default_canonical_id \ //zoo:breeding-program >& $TEST_log \ && fail "expected failure" || : } -function test_repository_legacy_default_canonical_id() { - setup_repository - - bazel fetch --repository_cache="$repo_cache_dir" \ - --norepository_cache_urls_as_default_canonical_id \ - //zoo:breeding-program >& $TEST_log \ - || echo "Expected fetch to succeed" - - shutdown_server - - bazel fetch --repository_cache="$repo_cache_dir" \ - --norepository_cache_urls_as_default_canonical_id \ - //zoo:breeding-program >& $TEST_log \ - || echo "Expected fetch to succeed" - - # Break url in WORKSPACE - rm WORKSPACE - cat >> $(create_workspace_with_default_repos WORKSPACE) <& $TEST_log \ - || echo "Expected fetch to succeed" -} - run_suite "repository cache tests" diff --git a/src/test/shell/testenv.sh.tmpl b/src/test/shell/testenv.sh.tmpl index e7795aa3657ce4..3efa4aaa5e0f08 100755 --- a/src/test/shell/testenv.sh.tmpl +++ b/src/test/shell/testenv.sh.tmpl @@ -327,9 +327,6 @@ EOF if [[ -n ${REPOSITORY_CACHE:-} ]]; then echo "testenv.sh: Using repository cache at $REPOSITORY_CACHE." echo "common --repository_cache=$REPOSITORY_CACHE" >> $TEST_TMPDIR/bazelrc - # TODO(sluongng): Remove this flag once all dependencies are mirrored. - # See https://github.com/bazelbuild/bazel/pull/19549 for more context. - echo "common --norepository_cache_urls_as_default_canonical_id" >> $TEST_TMPDIR/bazelrc if is_darwin; then # For reducing SSD usage on our physical Mac machines. echo "testenv.sh: Enabling --experimental_repository_cache_hardlinks"