Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] bazel: Set RBE downloads to minimal #22017

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .azure-pipelines/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ stages:
- script: ci/run_envoy_docker.sh 'ci/do_ci.sh format'
workingDirectory: $(Build.SourcesDirectory)
env:
ENVOY_RBE: "true"
BAZEL_BUILD_EXTRA_OPTIONS: "--config=remote-ci --jobs=$(RbeJobs)"
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
BAZEL_REMOTE_CACHE: grpcs://remotebuildexecution.googleapis.com
BAZEL_REMOTE_INSTANCE: projects/envoy-ci/instances/default_instance
Expand All @@ -53,6 +55,8 @@ stages:
- script: ci/run_envoy_docker.sh 'ci/check_and_fix_format.sh'
workingDirectory: $(Build.SourcesDirectory)
env:
ENVOY_RBE: "true"
BAZEL_BUILD_EXTRA_OPTIONS: "--config=remote-ci --jobs=$(RbeJobs)"
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
BAZEL_REMOTE_CACHE: grpcs://remotebuildexecution.googleapis.com
BAZEL_REMOTE_INSTANCE: projects/envoy-ci/instances/default_instance
Expand Down Expand Up @@ -80,6 +84,8 @@ stages:
- script: ci/run_envoy_docker.sh 'ci/do_ci.sh docs'
workingDirectory: $(Build.SourcesDirectory)
env:
ENVOY_RBE: "true"
BAZEL_BUILD_EXTRA_OPTIONS: "--config=remote-ci --jobs=$(RbeJobs)"
AZP_BRANCH: $(Build.SourceBranch)
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
BAZEL_REMOTE_CACHE: grpcs://remotebuildexecution.googleapis.com
Expand Down Expand Up @@ -109,6 +115,8 @@ stages:
- script: ci/run_envoy_docker.sh 'ci/do_ci.sh deps'
workingDirectory: $(Build.SourcesDirectory)
env:
ENVOY_RBE: "true"
BAZEL_BUILD_EXTRA_OPTIONS: "--config=remote-ci --jobs=$(RbeJobs)"
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
BAZEL_REMOTE_CACHE: grpcs://remotebuildexecution.googleapis.com
BAZEL_REMOTE_INSTANCE: projects/envoy-ci/instances/default_instance
Expand Down Expand Up @@ -181,7 +189,7 @@ stages:
AZP_BRANCH: $(Build.SourceBranch)

- stage: linux_x64
dependsOn: ["precheck"]
dependsOn: [] # "precheck"]
# For post-submit builds, continue even if precheck fails
condition: and(not(canceled()), or(succeeded(), eq(variables['PostSubmit'], true)))
jobs:
Expand All @@ -195,7 +203,7 @@ stages:
ciTarget: bazel.release

- stage: linux_arm64
dependsOn: ["precheck"]
dependsOn: [] # "precheck"]
# For post-submit builds, continue even if precheck fails
condition: and(not(canceled()), or(succeeded(), eq(variables['PostSubmit'], true)))
jobs:
Expand Down Expand Up @@ -430,6 +438,8 @@ stages:
- script: ci/run_envoy_docker.sh 'ci/do_ci.sh docs'
workingDirectory: $(Build.SourcesDirectory)
env:
ENVOY_RBE: "true"
BAZEL_BUILD_EXTRA_OPTIONS: "--config=remote-ci --jobs=$(RbeJobs)"
AZP_BRANCH: $(Build.SourceBranch)
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
BAZEL_REMOTE_CACHE: grpcs://remotebuildexecution.googleapis.com
Expand Down
6 changes: 4 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ build:remote --strategy=Closure=remote,sandboxed,local
build:remote --strategy=Genrule=remote,sandboxed,local
build:remote --remote_timeout=7200
build:remote --google_default_credentials=true
build:remote --remote_download_toplevel
build:remote --remote_download_minimal
run:remote --remote_download_outputs=toplevel

# Windows bazel does not allow sandboxed as a spawn strategy
build:remote-windows --spawn_strategy=remote,local
Expand All @@ -252,7 +253,8 @@ build:remote-windows --strategy=Closure=remote,local
build:remote-windows --strategy=Genrule=remote,local
build:remote-windows --remote_timeout=7200
build:remote-windows --google_default_credentials=true
build:remote-windows --remote_download_toplevel
build:remote-windows --remote_download_minimal
run:remote-windows --remote_download_outputs=toplevel

build:remote-clang --config=remote
build:remote-clang --config=rbe-toolchain-clang
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ BAZEL_REMOTE_CACHE=grpcs://remotebuildexecution.googleapis.com
BAZEL_BUILD_EXTRA_OPTIONS=--config=remote-ci --config=remote --jobs=<Number of jobs>
```

By default the `--config=remote` implies [`--remote_download_toplevel`](https://docs.bazel.build/versions/master/command-line-reference.html#flag--remote_download_toplevel),
change this to `minimal` or `all` depending on where you're running the container by adding them to `BAZEL_BUILD_EXTRA_OPTIONS`.
By default the `--config=remote` implies [`--remote_download_minimal`](https://docs.bazel.build/versions/master/command-line-reference.html#flag--remote_download_minimal),
change this to `toplevel` or `all` depending on where you're running the container by adding them to `BAZEL_BUILD_EXTRA_OPTIONS`.

### Disk performance

Expand Down
8 changes: 7 additions & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ function bazel_binary_build() {
echo "ENVOY_BIN=${ENVOY_BIN}"

# This is a workaround for https://github.com/bazelbuild/bazel/issues/11834
[[ -n "${ENVOY_RBE}" ]] && rm -rf bazel-bin/"${ENVOY_BIN}"*
[[ -n "${ENVOY_RBE}" ]] && {
rm -rf bazel-bin/"${ENVOY_BIN}"*
# Seemingly due to above bug, `download_minimal` doesnt download the target
BAZEL_BUILD_OPTIONS+=("--remote_download_outputs=toplevel")
}

bazel build "${BAZEL_BUILD_OPTIONS[@]}" -c "${COMPILE_TYPE}" "${BUILD_TARGET}" ${CONFIG_ARGS}
collect_build_profile "${BINARY_TYPE}"_build
Expand Down Expand Up @@ -236,6 +240,8 @@ elif [[ "$CI_TARGET" == "bazel.distribution" ]]; then

setup_clang_toolchain

BAZEL_BUILD_OPTIONS+=("--remote_download_outputs=toplevel")

# By default the packages will be signed by the first available key.
# If there is no key available, a throwaway key is created
# and the packages signed with it, for the purpose of testing only.
Expand Down
1 change: 1 addition & 0 deletions docs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fi
# This is for local RBE setup, should be no-op for builds without RBE setting in bazelrc files.
IFS=" " read -ra BAZEL_BUILD_OPTIONS <<< "${BAZEL_BUILD_OPTIONS:-}"
BAZEL_BUILD_OPTIONS+=(
"--remote_download_outputs=toplevel"
"--action_env=DOCS_TAG"
"--action_env=BUILD_SHA"
"--action_env=SPHINX_RUNNER_ARGS"
Expand Down
16 changes: 9 additions & 7 deletions tools/base/envoy_python.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,15 @@ def envoy_jinja_env(
native.genrule(
name = name_env,
cmd = """
TEMPLATE_PATH=$$(realpath %s) \
&& echo -n "\
echo -n "\
\nimport pathlib \
\nfrom envoy.base.utils.jinja_env import JinjaEnvironment \
\nenv = JinjaEnvironment.load(\\"$$TEMPLATE_PATH\\", %s)" \
\npath=pathlib.Path(__file__).parent.joinpath(pathlib.Path(\\"%s\\").name) \
\nenv = JinjaEnvironment.load(str(path), %s)" \
> $@
""" % (template_arg, load_args),
outs = [name_env_py],
tools = [name_templates],
exec_tools = [name_templates],
)

py_library(
Expand Down Expand Up @@ -315,10 +316,11 @@ def envoy_py_data(name, src, format = None, entry_point = base_entry_point):
native.genrule(
name = name_env,
cmd = """
PICKLE_PATH=$$(realpath %s) \
PICKLE_DATA=$$(cat %s | base64) \
&& echo -n "\
\nfrom envoy.base.utils.data_env import DataEnvironment \
\ndata = DataEnvironment.load(\\"$$PICKLE_PATH\\")" \
\nimport base64 \
\nimport pickle \
\ndata = pickle.loads(base64.b64decode(\\"\\"\\"$$PICKLE_DATA\\"\\"\\"))\n" \
> $@
""" % pickle_arg,
outs = [name_env_py],
Expand Down
2 changes: 2 additions & 0 deletions tools/proto_format/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ genrule(
--xformed=$(location :xformed) \
--protoprinted=$(location //tools/protoprint:protoprinted) \
""" % PATH,
# TODO(phlax): make protoprint work without repo `PATH`
tags = ["no-remote"],
tools = [
":format_api",
":xformed",
Expand Down
2 changes: 1 addition & 1 deletion tools/proto_format/proto_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ if [[ "$1" == "freeze" ]]; then
fi

# Generate api/BUILD file based on updated type database.
bazel build "${BAZEL_BUILD_OPTIONS[@]}" //tools/type_whisperer:api_build_file
bazel build "${BAZEL_BUILD_OPTIONS[@]}" --remote_download_outputs=toplevel //tools/type_whisperer:api_build_file
cp -f bazel-bin/tools/type_whisperer/BUILD.api_build_file api/BUILD
7 changes: 6 additions & 1 deletion tools/protoprint/protoprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import os
import pathlib
import re
import shutil
import subprocess
import sys
from collections import deque
Expand Down Expand Up @@ -92,7 +93,11 @@ def clang_format(contents):
Returns:
clang-formatted string
"""
clang_format_path = os.getenv("CLANG_FORMAT", "clang-format")
clang_format_path = os.getenv("CLANG_FORMAT", shutil.which("clang-format"))
if not clang_format_path:
if not os.path.exists("/opt/llvm/bin/clang-format"):
raise RuntimeError("Unable to find clang-format, sorry")
clang_format_path = "/opt/llvm/bin/clang-format"
return subprocess.run(
[clang_format_path,
'--style=%s' % CLANG_FORMAT_STYLE, '--assume-filename=.proto'],
Expand Down