[test-infra] Switch RBE linux build to a new custom image rbe_ubuntu2004. (#32748)

- Add a new docker image "rbe_ubuntu2004" that is built in a way that's
analogous to how our other testing docker images are built (this gives
us control over what exactly is contained in the docker image and
ability to fine-tune our RBE configuration)
- Switch RBE on linux to the new image (which gives us ubuntu20.04-based
builds)

For some reason, RBE seems to have trouble pulling the docker image from
Google Artifact Registry (GAR), which is where our public testing images
normally live, so for now, I used a workaround and I upload a copy of
the rbe_ubuntu2004 docker image to GCR as well, and that makes RBE works
just fine (see comment in the `renerate_linux_rbe_configs.sh` script).

More followup items (config cleanup, getting local sanitizer builds
working etc.) are in go/grpc-rbe-tech-debt-2023
pull/32978/head
Jan Tattermusch 2 years ago committed by GitHub
parent 9f00eda536
commit 30b3d5061a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 62
      templates/tools/dockerfile/test/rbe_ubuntu2004/Dockerfile.template
  2. 6
      third_party/toolchains/BUILD
  3. 2
      third_party/toolchains/README.md
  4. 16
      third_party/toolchains/generate_linux_rbe_configs.sh
  5. 4832
      third_party/toolchains/rbe_ubuntu1804/cc/module.modulemap
  6. 0
      third_party/toolchains/rbe_ubuntu2004/LICENSE
  7. 19
      third_party/toolchains/rbe_ubuntu2004/cc/BUILD
  8. 0
      third_party/toolchains/rbe_ubuntu2004/cc/WORKSPACE
  9. 0
      third_party/toolchains/rbe_ubuntu2004/cc/armeabi_cc_toolchain_config.bzl
  10. 13
      third_party/toolchains/rbe_ubuntu2004/cc/builtin_include_directory_paths
  11. 0
      third_party/toolchains/rbe_ubuntu2004/cc/cc_toolchain_config.bzl
  12. 2
      third_party/toolchains/rbe_ubuntu2004/cc/cc_wrapper.sh
  13. 5255
      third_party/toolchains/rbe_ubuntu2004/cc/module.modulemap
  14. 0
      third_party/toolchains/rbe_ubuntu2004/cc/tools/cpp/empty.cc
  15. 4
      third_party/toolchains/rbe_ubuntu2004/config/BUILD
  16. 1
      tools/dockerfile/test/rbe_ubuntu2004.current_version
  17. 84
      tools/dockerfile/test/rbe_ubuntu2004/Dockerfile
  18. 7
      tools/remote_build/linux.bazelrc

@ -0,0 +1,62 @@
%YAML 1.2
--- |
# Copyright 2023 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:20.04
# Workaround the "tzdata hangs apt-get install during docker image build" issue for ubuntu20.04
# by setting timezone to "Etc/UTC" in advance.
RUN echo "Etc/UTC" > /etc/timezone
RUN apt-get update && apt-get install -y build-essential curl git time wget zip && apt-get clean
<%include file="../../run_tests_python_deps.include"/>
# Some bazel tests expect "python" binary to exist
RUN ln -s /usr/bin/python3 /usr/bin/python
# Install Google's LLVM build for Ubuntu 20.04
# Heavily inspired by https://github.com/GoogleCloudPlatform/container-definitions/tree/master/ubuntu1804_rbe
# See go/llvm-docker
# Note that we are using the google's pre-built tools for multiple reasons:
# * this is what the "official" rbe-ubuntu18-04 image is using: See https://github.com/GoogleCloudPlatform/layer-definitions/tree/master/layers/ubuntu1804/clang
# * for sanitizers to work, we need MSAN and TSAN enabled versions of libc++
# Check https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/latest.txt
# for the value of LLVM_LATEST.
ARG LLVM_LATEST="f2b94bd7eaa83d853dc7568fac87b1f8bf4ddec6"
RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/clang_r<%text>${LLVM_LATEST}</%text>.tar.gz -O /tmp/clang.tar.gz ${'\\'}
&& tar -xzf /tmp/clang.tar.gz -C /usr/local && rm /tmp/clang.tar.gz
RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/libcxx_r<%text>${LLVM_LATEST}</%text>.tar.gz -O /tmp/libcxx.tar.gz ${'\\'}
&& tar -xzf /tmp/libcxx.tar.gz -C /usr/local && rm /tmp/libcxx.tar.gz
RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/libcxx-msan_r<%text>${LLVM_LATEST}</%text>.tar.gz -O /tmp/libcxx-msan.tar.gz ${'\\'}
&& mkdir -p /usr/local/libcxx-msan && tar -xzf /tmp/libcxx-msan.tar.gz -C /usr/local/libcxx-msan && rm /tmp/libcxx-msan.tar.gz
RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/libcxx-tsan_r<%text>${LLVM_LATEST}</%text>.tar.gz -O /tmp/libcxx-tsan.tar.gz ${'\\'}
&& mkdir -p /usr/local/libcxx-tsan && tar -xzf /tmp/libcxx-tsan.tar.gz -C /usr/local/libcxx-tsan && rm /tmp/libcxx-tsan.tar.gz
RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/lld_r<%text>${LLVM_LATEST}</%text>.tar.gz -O /tmp/lld.tar.gz ${'\\'}
&& tar -xzf /tmp/lld.tar.gz -C /usr/local && rm /tmp/lld.tar.gz
ENV ASAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
ENV CC=/usr/local/bin/clang
ENV GCOV=/dev/null
ENV LD_LIBRARY_PATH=/usr/local/lib/x86_64-unknown-linux-gnu
ENV MSAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
ENV TSAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
ENV UBSAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
# TODO(jtattermusch): Remove python2 once some tests stop failing without it.
RUN apt-get update && apt-get install -y python2 && apt-get clean
# Define the default command.
CMD ["bash"]

@ -21,20 +21,20 @@ load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_rbe
# The default toolchain suite for RBE linux, pass it to --crosstool_top
alias(
name = "rbe_linux_default_toolchain_suite",
actual = "//third_party/toolchains/rbe_ubuntu1804/cc:toolchain",
actual = "//third_party/toolchains/rbe_ubuntu2004/cc:toolchain",
)
# The default CC toolchain suite for RBE linux
alias(
name = "rbe_linux_default_cc_toolchain",
actual = "//third_party/toolchains/rbe_ubuntu1804/config:cc-toolchain",
actual = "//third_party/toolchains/rbe_ubuntu2004/config:cc-toolchain",
)
# The default platform for RBE Linux
platform(
name = "rbe_linux_default_platform",
# Inherit from the platform target generated by 'rbe_configs_gen'.
parents = ["//third_party/toolchains/rbe_ubuntu1804/config:platform"],
parents = ["//third_party/toolchains/rbe_ubuntu2004/config:platform"],
exec_properties = create_rbe_exec_properties_dict(
docker_add_capabilities = "SYS_PTRACE",
docker_privileged = True,

@ -1,6 +1,6 @@
# RBE toolchain configuration (Linux and Windows)
- rbe_ubuntu1804: Autogenerated toolchain configuration for linux RBE.
- rbe_ubuntu2004: Autogenerated toolchain configuration for linux RBE.
Run `generate_linux_rbe_configs.sh` to regenerate.
- rbe_windows_bazel_5.2.0_vs2019: The autogenerated toolchain configuration for windows RBE.

@ -34,8 +34,16 @@ popd
# location of the "rbe_config_gen" binary as build by the previous step.
RBE_CONFIGS_GEN_TOOL_PATH="${TEMP_DIR}/bazel-toolchains/rbe_configs_gen"
# the container under which RBE actions will run
LINUX_RBE_DOCKER_IMAGE=l.gcr.io/google/rbe-ubuntu18-04@sha256:48b67b41118dbcdfc265e7335f454fbefa62681ab8d47200971fc7a52fb32054
# Actions on RBE will run under a dedicated docker image from our collection of testing docker images.
LINUX_RBE_DOCKERFILE_DIR=tools/dockerfile/test/rbe_ubuntu2004
# Use the "current version" of the above dockerfile.
LINUX_RBE_DOCKER_IMAGE=$(cat ${LINUX_RBE_DOCKERFILE_DIR}.current_version)
# RBE currently has problems pulling images for Google Artifact Registry ("us-docker.pkg.dev/grpc-testing")
# so to workaround this, the original image was manually pushed to Google Container Registry ("gcr.io/grpc-testing")
# as well and RBE will use the mirrored image instead. See b/275571385
# TODO(jtattermusch): get rid of this hack.
LINUX_RBE_DOCKER_IMAGE_IN_GCR=$(echo -n "${LINUX_RBE_DOCKER_IMAGE}" | sed 's|^us-docker.pkg.dev/grpc-testing/testing-images-public/|gcr.io/grpc-testing/rbe_images_mirror/|')
# Bazel version used for configuring
# Needs to be one of the versions from bazel/supported_versions.txt chosen so that the result is compatible
@ -45,14 +53,14 @@ BAZEL_VERSION=5.4.0
# TODO(jtattermusch): experiment with --cpp_env_json to simplify bazel build configuration.
# Where to store the generated configs (relative to repo root)
CONFIG_OUTPUT_PATH=third_party/toolchains/rbe_ubuntu1804
CONFIG_OUTPUT_PATH=third_party/toolchains/rbe_ubuntu2004
# Delete old generated configs.
rm -rf "${REPO_ROOT}/${CONFIG_OUTPUT_PATH}"
${RBE_CONFIGS_GEN_TOOL_PATH} \
--bazel_version="${BAZEL_VERSION}" \
--toolchain_container="${LINUX_RBE_DOCKER_IMAGE}" \
--toolchain_container="${LINUX_RBE_DOCKER_IMAGE_IN_GCR}" \
--output_src_root="${REPO_ROOT}" \
--output_config_path="${CONFIG_OUTPUT_PATH}" \
--exec_os=linux \

File diff suppressed because it is too large Load Diff

@ -80,20 +80,21 @@ cc_toolchain_config(
target_libc = "glibc_2.19",
abi_version = "clang",
abi_libc_version = "glibc_2.19",
cxx_builtin_include_directories = ["/usr/local/include",
"/usr/local/lib/clang/12.0.0/include",
cxx_builtin_include_directories = ["/usr/local/lib/clang/15.0.0/include",
"/usr/local/include",
"/usr/include/x86_64-linux-gnu",
"/usr/include",
"/usr/local/lib/clang/12.0.0/share",
"/usr/include/c++/7.5.0",
"/usr/include/x86_64-linux-gnu/c++/7.5.0",
"/usr/include/c++/7.5.0/backward",
"/usr/local/lib/clang/15.0.0/share",
"/usr/include/c++/9",
"/usr/include/x86_64-linux-gnu/c++/9",
"/usr/include/c++/9/backward",
"/usr/local/include/x86_64-unknown-linux-gnu/c++/v1",
"/usr/local/include/c++/v1"],
tool_paths = {"ar": "/usr/bin/ar",
"ld": "/usr/bin/ld",
"llvm-cov": "/usr/local/bin/llvm-cov",
"cpp": "/usr/bin/cpp",
"gcc": "/usr/local/bin/clang-12",
"gcc": "/usr/local/bin/clang-15",
"dwp": "/usr/bin/dwp",
"gcov": "/dev/null",
"nm": "/usr/bin/nm",
@ -104,6 +105,8 @@ cc_toolchain_config(
"-Wall",
"-Wthread-safety",
"-Wself-assign",
"-Wunused-but-set-parameter",
"-Wno-free-nonheap-object",
"-fcolor-diagnostics",
"-fno-omit-frame-pointer"],
opt_compile_flags = ["-g0",
@ -114,7 +117,7 @@ cc_toolchain_config(
"-fdata-sections"],
dbg_compile_flags = ["-g"],
cxx_flags = ["-std=c++0x"],
link_flags = ["-fuse-ld=/usr/bin/ld.gold",
link_flags = ["-fuse-ld=/usr/local/bin/ld.lld",
"-Wl,-no-as-needed",
"-Wl,-z,relro,-z,now",
"-B/usr/local/bin"],

@ -1,15 +1,16 @@
This file is generated by cc_configure and contains builtin include directories
that /usr/local/bin/clang-12 reported. This file is a dependency of every compilation action and
that /usr/local/bin/clang-15 reported. This file is a dependency of every compilation action and
changes to it will be reflected in the action cache key. When some of these
paths change, Bazel will make sure to rerun the action, even though none of
declared action inputs or the action commandline changes.
/usr/local/lib/clang/15.0.0/include
/usr/local/include
/usr/local/lib/clang/12.0.0/include
/usr/include/x86_64-linux-gnu
/usr/include
/usr/local/lib/clang/12.0.0/share
/usr/include/c++/7.5.0
/usr/include/x86_64-linux-gnu/c++/7.5.0
/usr/include/c++/7.5.0/backward
/usr/local/lib/clang/15.0.0/share
/usr/include/c++/9
/usr/include/x86_64-linux-gnu/c++/9
/usr/include/c++/9/backward
/usr/local/include/x86_64-unknown-linux-gnu/c++/v1
/usr/local/include/c++/v1

@ -22,4 +22,4 @@ set -eu
# Call the C++ compiler
/usr/local/bin/clang-12 "$@"
/usr/local/bin/clang-15 "$@"

File diff suppressed because it is too large Load Diff

@ -29,7 +29,7 @@ toolchain(
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
toolchain = "//third_party/toolchains/rbe_ubuntu1804/cc:cc-compiler-k8",
toolchain = "//third_party/toolchains/rbe_ubuntu2004/cc:cc-compiler-k8",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
@ -42,7 +42,7 @@ platform(
"@bazel_tools//tools/cpp:clang",
],
exec_properties = {
"container-image": "docker://gcr.io/cloud-marketplace/google/rbe-ubuntu18-04@sha256:48b67b41118dbcdfc265e7335f454fbefa62681ab8d47200971fc7a52fb32054",
"container-image": "docker://gcr.io/grpc-testing/rbe_images_mirror/rbe_ubuntu2004@sha256:d3951aeadf43e3bee6adc5b86d26cdaf0b9d1b5baf790d7b2530d1c197adc9f8",
"OSFamily": "Linux",
},
)

@ -0,0 +1 @@
us-docker.pkg.dev/grpc-testing/testing-images-public/rbe_ubuntu2004:58594aefea3481a4839f8411e365b58ef9f34fcc@sha256:d3951aeadf43e3bee6adc5b86d26cdaf0b9d1b5baf790d7b2530d1c197adc9f8

@ -0,0 +1,84 @@
# Copyright 2023 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:20.04
# Workaround the "tzdata hangs apt-get install during docker image build" issue for ubuntu20.04
# by setting timezone to "Etc/UTC" in advance.
RUN echo "Etc/UTC" > /etc/timezone
RUN apt-get update && apt-get install -y build-essential curl git time wget zip && apt-get clean
#====================
# run_tests.py python dependencies
# Basic python dependencies to be able to run tools/run_tests python scripts
# These dependencies are not sufficient to build gRPC Python, gRPC Python
# deps are defined elsewhere (e.g. python_deps.include)
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
python3-setuptools \
python3-yaml \
&& apt-get clean
# use pinned version of pip to avoid sudden breakages
RUN python3 -m pip install --upgrade pip==19.3.1
# TODO(jtattermusch): currently six is needed for tools/run_tests scripts
# but since our python2 usage is deprecated, we should get rid of it.
RUN python3 -m pip install six==1.16.0
# Google Cloud Platform API libraries
# These are needed for uploading test results to BigQuery (e.g. by tools/run_tests scripts)
RUN python3 -m pip install --upgrade google-auth==1.23.0 google-api-python-client==1.12.8 oauth2client==4.1.0
# Some bazel tests expect "python" binary to exist
RUN ln -s /usr/bin/python3 /usr/bin/python
# Install Google's LLVM build for Ubuntu 20.04
# Heavily inspired by https://github.com/GoogleCloudPlatform/container-definitions/tree/master/ubuntu1804_rbe
# See go/llvm-docker
# Note that we are using the google's pre-built tools for multiple reasons:
# * this is what the "official" rbe-ubuntu18-04 image is using: See https://github.com/GoogleCloudPlatform/layer-definitions/tree/master/layers/ubuntu1804/clang
# * for sanitizers to work, we need MSAN and TSAN enabled versions of libc++
# Check https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/latest.txt
# for the value of LLVM_LATEST.
ARG LLVM_LATEST="f2b94bd7eaa83d853dc7568fac87b1f8bf4ddec6"
RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/clang_r${LLVM_LATEST}.tar.gz -O /tmp/clang.tar.gz \
&& tar -xzf /tmp/clang.tar.gz -C /usr/local && rm /tmp/clang.tar.gz
RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/libcxx_r${LLVM_LATEST}.tar.gz -O /tmp/libcxx.tar.gz \
&& tar -xzf /tmp/libcxx.tar.gz -C /usr/local && rm /tmp/libcxx.tar.gz
RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/libcxx-msan_r${LLVM_LATEST}.tar.gz -O /tmp/libcxx-msan.tar.gz \
&& mkdir -p /usr/local/libcxx-msan && tar -xzf /tmp/libcxx-msan.tar.gz -C /usr/local/libcxx-msan && rm /tmp/libcxx-msan.tar.gz
RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/libcxx-tsan_r${LLVM_LATEST}.tar.gz -O /tmp/libcxx-tsan.tar.gz \
&& mkdir -p /usr/local/libcxx-tsan && tar -xzf /tmp/libcxx-tsan.tar.gz -C /usr/local/libcxx-tsan && rm /tmp/libcxx-tsan.tar.gz
RUN wget -q https://storage.googleapis.com/clang-builds-stable/clang-ubuntu20_04/lld_r${LLVM_LATEST}.tar.gz -O /tmp/lld.tar.gz \
&& tar -xzf /tmp/lld.tar.gz -C /usr/local && rm /tmp/lld.tar.gz
ENV ASAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
ENV CC=/usr/local/bin/clang
ENV GCOV=/dev/null
ENV LD_LIBRARY_PATH=/usr/local/lib/x86_64-unknown-linux-gnu
ENV MSAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
ENV TSAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
ENV UBSAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer
# TODO(jtattermusch): Remove python2 once some tests stop failing without it.
RUN apt-get update && apt-get install -y python2 && apt-get clean
# Define the default command.
CMD ["bash"]

@ -54,6 +54,10 @@ build:msan --test_timeout=60,900,1800,3600
build:msan --test_tag_filters=-no_linux,-nomsan,-json_run_localhost
build:msan --cxxopt=--stdlib=libc++
build:msan --linkopt=--stdlib=libc++
# use MSAN-instrumented version of libc++
# TODO(jtattermusch): include the modified LD_LIBRARY_PATH in an msan-specific
# toolchain configuration, instead of needing to explicitly set it here.
build:msan --action_env=LD_LIBRARY_PATH=/usr/local/libcxx-msan/lib/x86_64-unknown-linux-gnu
# thread sanitizer: most settings are already in %workspace%/.bazelrc
# we only need a few additional ones that are Foundry specific
@ -78,3 +82,6 @@ build:ubsan --linkopt=-fsanitize=memory
build:ubsan --cxxopt=--stdlib=libc++
build:ubsan --action_env=MSAN_OPTIONS=halt_on_error=0
build:ubsan --test_tag_filters=-no_linux,-noubsan
# use MSAN-instrumented version of libc++
# TODO(jtattermusch): run UBSAN without enabling MSAN too.
build:ubsan --action_env=LD_LIBRARY_PATH=/usr/local/libcxx-msan/lib/x86_64-unknown-linux-gnu

Loading…
Cancel
Save