Skip to content

Commit a614467

Browse files
authored
Revert "Fix: shim tools requiring go to use rules_go's hermetic SDK" (#54925)
Reverts #54887 This seems to be the root cause of lots of breakages triggering incidents. - https://app.datadoghq.com/ci/ci-cd/explorer?query=ci_level%3Ajob%20%40ci.pipeline.name%3ADataDog%2Fdatadog-agent%20%40git.branch%3Amain%20%40ci.job.name%3A%22new-e2e-windows-systemprobe%3A%20%5B--run%20TestUSMAutoTaggingSuite%5D%22&agg_m=%40ci.job.name&agg_m_source=base&agg_t=cardinality&analyticsOptions=%5B%22line%22%2C%22dog_classic%22%2Cnull%2Cnull%2C%22value%22%5D&buildId=AwAAAaABDCfoRYiVyQAAABhBYUFCRENmb0FBQzM3UFRlUnJsdk9lTGkAAAAkMDFhMDAxMzUtNGZjOS00YmU5LWIzYzYtMmM3YWVhMDJmYWEzAAOPnA&ci_cd_explorer_tab=pipelines&cipipeline_explorer_sort=time%2Cdesc&colorByAttr=meta%5B%27ci.stage.name%27%5D&cols=%40git.branch%2C%40ci.status%2Ctimestamp%2C%40ci.pipeline.name%2C%40ci.stage.name%2C%40ci.job.name%2C%40duration%2C%40ci.pipeline.id%2C%40git.repository.name&currentTab=trace&downstream_pipelines=false&fromUser=false&graphType=flamegraph&index=cipipeline&mode=sliding&partial_retries=false&refresh_mode=sliding&sort=time&spanViewType=metadata&step=86400000&tab=overview&trace=AwAAAaABDCfoRYiVyQAAABhBYUFCRENmb0FBQzM3UFRlUnJsdk9lTGkAAAAkMDFhMDAxMzUtNGZjOS00YmU5LWIzYzYtMmM3YWVhMDJmYWEzAAOPnA&viz=stream&start=1781548681564&end=1786732681564&paused=false - https://app.datadoghq.com/ci/ci-cd/explorer?query=ci_level%3Ajob%20%40ci.pipeline.name%3ADataDog%2Fdatadog-agent%20%40git.branch%3Amain%20%40ci.job.name%3A%22new-e2e-ndm-snmp%22&agg_m=%40ci.job.name&agg_m_source=base&agg_t=cardinality&analyticsOptions=%5B%22line%22%2C%22dog_classic%22%2Cnull%2Cnull%2C%22value%22%5D&ci_cd_explorer_tab=pipelines&cipipeline_explorer_sort=time%2Cdesc&colorByAttr=meta%5B%27ci.stage.name%27%5D&cols=%40git.branch%2C%40ci.status%2Ctimestamp%2C%40ci.pipeline.name%2C%40ci.stage.name%2C%40ci.job.name%2C%40duration%2C%40ci.pipeline.id%2C%40git.repository.name&currentTab=trace&fromUser=false&graphType=flamegraph&index=cipipeline&mode=sliding&refresh_mode=sliding&sort=time&spanViewType=metadata&step=86400000&tab=overview&viz=stream&start=1781548713566&end=1786732713566&paused=false - https://app.datadoghq.com/ci/ci-cd/explorer?query=ci_level%3Ajob%20%40ci.pipeline.name%3ADataDog%2Fdatadog-agent%20%40git.branch%3Amain%20%40ci.job.name%3A%22new-e2e-windows-systemprobe%3A%20%5B--run%20TestUSMAutoTaggingSuite%5D%22&agg_m=%40ci.job.name&agg_m_source=base&agg_t=cardinality&analyticsOptions=%5B%22line%22%2C%22dog_classic%22%2Cnull%2Cnull%2C%22value%22%5D&buildId=AwAAAaABDCfoRYiVyQAAABhBYUFCRENmb0FBQzM3UFRlUnJsdk9lTGkAAAAkMDFhMDAxMzUtNGZjOS00YmU5LWIzYzYtMmM3YWVhMDJmYWEzAAOPnA&ci_cd_explorer_tab=pipelines&cipipeline_explorer_sort=time%2Cdesc&colorByAttr=meta%5B%27ci.stage.name%27%5D&cols=%40git.branch%2C%40ci.status%2Ctimestamp%2C%40ci.pipeline.name%2C%40ci.stage.name%2C%40ci.job.name%2C%40duration%2C%40ci.pipeline.id%2C%40git.repository.name&currentTab=trace&downstream_pipelines=false&fromUser=false&graphType=flamegraph&index=cipipeline&mode=sliding&partial_retries=false&refresh_mode=sliding&sort=time&spanViewType=metadata&step=86400000&trace=AwAAAaABDCfoRYiVyQAAABhBYUFCRENmb0FBQzM3UFRlUnJsdk9lTGkAAAAkMDFhMDAxMzUtNGZjOS00YmU5LWIzYzYtMmM3YWVhMDJmYWEzAAOPnA&viz=stream&start=1781548799627&end=1786732799627&paused=false
1 parent d0e517c commit a614467

9 files changed

Lines changed: 24 additions & 88 deletions

File tree

BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ load("@dd_release_json//:release_json.bzl", "release_json")
1212
load("@gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
1313
load("@package_metadata//rules:package_metadata.bzl", "package_metadata")
1414
load("@rules_license//rules:license.bzl", "license")
15-
load("//bazel/rules/go_shim:defs.bzl", "go_shim")
1615
load("//compliance/rules:purl.bzl", "purl_for_generic")
1716
load("//tasks:build_tags.bzl", "GAZELLE_BUILD_TAGS")
1817

@@ -124,9 +123,9 @@ alias(
124123
)
125124

126125
# bazel run //:go_mod_tidy_all -- -x
127-
go_shim(
126+
alias(
128127
name = "go_mod_tidy_all",
129-
tool = "//bazel/rules/go_mod_tidy_all",
128+
actual = "//bazel/tools:go_mod_tidy_all",
130129
)
131130

132131
run_binary(

bazel/rules/go_mod_tidy_all/BUILD.bazel

Lines changed: 0 additions & 7 deletions
This file was deleted.

bazel/rules/go_shim/BUILD.bazel

Lines changed: 0 additions & 7 deletions
This file was deleted.

bazel/rules/go_shim/defs.bzl

Lines changed: 0 additions & 46 deletions
This file was deleted.

bazel/rules/go_shim/template.bat

Lines changed: 0 additions & 8 deletions
This file was deleted.

bazel/rules/go_shim/template.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

bazel/tools/BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
load("@bazel_skylib//rules:write_file.bzl", "write_file")
22
load("@rules_python//python:py_binary.bzl", "py_binary")
33

4+
py_binary(
5+
name = "go_mod_tidy_all",
6+
srcs = ["go_mod_tidy_all.py"],
7+
args = ["$(rlocationpath @rules_go//go)"],
8+
data = ["@rules_go//go"],
9+
visibility = ["//:__pkg__"],
10+
deps = ["@rules_python//python/runfiles"],
11+
)
12+
413
py_binary(
514
name = "generate_module_bazel",
615
srcs = ["generate_module_bazel.py"],

bazel/rules/go_mod_tidy_all/go_mod_tidy_all.py renamed to bazel/tools/go_mod_tidy_all.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
from subprocess import PIPE, CalledProcessError
1313
from traceback import format_exception_only
1414

15+
from python.runfiles import runfiles
1516

16-
async def _exec(*args, **kwargs):
17-
proc = await asyncio.create_subprocess_exec(*args, **kwargs)
17+
18+
async def _exec(go, *args, **kwargs):
19+
proc = await asyncio.create_subprocess_exec(go, *args, **kwargs)
1820
try:
1921
stdout, _ = await proc.communicate()
2022
except BaseException: # reap the process on any CancelledError, KeyboardInterrupt, SystemExit, TimeoutError, etc.
@@ -28,26 +30,26 @@ async def _exec(*args, **kwargs):
2830
raise
2931
if proc.returncode == 0:
3032
return stdout
31-
raise CalledProcessError(proc.returncode, " ".join(args), output=stdout)
33+
raise CalledProcessError(proc.returncode, " ".join((os.path.basename(go), *args)), output=stdout)
3234

3335

34-
async def _tidy(max_workers, mod_path, args):
36+
async def _tidy(max_workers, go, mod_path, args):
3537
async with max_workers:
36-
await _exec("go", "mod", "tidy", "-C", mod_path, *args)
38+
await _exec(go, "mod", "tidy", "-C", mod_path, *args)
3739

3840

39-
async def main(args):
40-
mod_paths = await _exec("go", "list", "-f", "{{.Dir}}", "-m", stdout=PIPE)
41+
async def main(go, args):
42+
mod_paths = await _exec(go, "list", "-f", "{{.Dir}}", "-m", stdout=PIPE)
4143
max_workers = asyncio.Semaphore((os.cpu_count() or 1) + 4) # TODO(regis): cpu_count -> Py 3.13's process_cpu_count
4244
# global timeout: on cold cache, per-task timeouts were unfairly hit because early tasks download most modules
4345
async with asyncio.timeout(timedelta(minutes=15).total_seconds()), asyncio.TaskGroup() as tg:
4446
for mod_path in mod_paths.decode().splitlines():
45-
tg.create_task(_tidy(max_workers, mod_path, args))
47+
tg.create_task(_tidy(max_workers, go, mod_path, args))
4648

4749

4850
if __name__ == "__main__":
4951
logging.getLogger("asyncio").setLevel(logging.ERROR) # no `Unknown child process pid N, will report returncode 255`
5052
try:
51-
asyncio.run(main(sys.argv[1:]))
53+
asyncio.run(main(runfiles.Create().Rlocation(sys.argv[1]), sys.argv[2:]))
5254
except* BaseException as eg:
5355
sys.exit("\n".join(line.rstrip() for e in eg.exceptions for line in format_exception_only(e)))

internal/tools/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
load("@bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
2+
load("@rules_multitool//multitool:cwd.bzl", "cwd")
23
load("@rules_pkg//pkg:install.bzl", "pkg_install")
34
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_files")
4-
load("//bazel/rules/go_shim:defs.bzl", "go_shim")
55

6-
go_shim(
6+
cwd(
77
name = "gotestsum",
88
tool = "@tools_gotest_gotestsum//:gotestsum",
99
)

0 commit comments

Comments
 (0)