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

[backport/1.25] release: Cleanups/updates #26247

Merged
merged 4 commits into from
Mar 22, 2023
Merged
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
18 changes: 18 additions & 0 deletions .azure-pipelines/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ parameters:
default: "--flaky_test_attempts=2"

steps:
# Set up tmpfs directories for self-hosted agents which have a surplus of mem.
#
# NB: Do not add any directory that grow larger than spare memory capacity!
- bash: |
TMPDIRS=(
# This is used as the final delivery directory for the binaries
"$(Build.StagingDirectory)/envoy"
# Bazel repository_cache which is cached by AZP (this speeds up cache load/save)
"$(Build.StagingDirectory)/repository_cache")
for tmpdir in "${TMPDIRS[@]}"; do
echo "Mount(tmpfs): ${tmpdir}"
sudo mkdir -p "$tmpdir"
sudo mount -t tmpfs none "$tmpdir"
sudo chown azure-pipelines "$tmpdir"
done
displayName: "Mount/tmpfs directories"
condition: and(succeeded(), eq('${{ parameters.managedAgent }}', false))

- task: Cache@2
inputs:
key: '"${{ parameters.ciTarget }}" | "${{ parameters.artifactSuffix }}" | ./WORKSPACE | **/*.bzl'
Expand Down
1 change: 1 addition & 0 deletions .azure-pipelines/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ stages:
parameters:
managedAgent: false
ciTarget: bazel.release
bazelBuildExtraOptions: "--sandbox_base=/tmp/sandbox_base"

- job: released
dependsOn: ["release"]
Expand Down
2 changes: 1 addition & 1 deletion ci/Dockerfile-envoy
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CMD ["envoy", "-c", "/etc/envoy/envoy.yaml"]

# STAGE: envoy-distroless
# gcr.io/distroless/base-nossl-debian11:nonroot
FROM gcr.io/distroless/base-nossl-debian11:nonroot@sha256:78d2ac043ae89e4ecdf969959ec299d0f7dc0d28f149441032c5da87d6996401 AS envoy-distroless
FROM gcr.io/distroless/base-nossl-debian11:nonroot@sha256:8c880faa0cb8c3fe60cae75de2cf4f6e7b53bd977a351a7e5ab510394e509f24 AS envoy-distroless

COPY --from=binary /usr/local/bin/envoy* /usr/local/bin/
COPY --from=binary /etc/envoy/envoy.yaml /etc/envoy/envoy.yaml
Expand Down
23 changes: 12 additions & 11 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function bazel_binary_build() {
# This is a workaround for https://github.com/bazelbuild/bazel/issues/11834
[[ -n "${ENVOY_RBE}" ]] && rm -rf bazel-bin/"${ENVOY_BIN}"*

bazel build "${BAZEL_BUILD_OPTIONS[@]}" -c "${COMPILE_TYPE}" "${BUILD_TARGET}" ${CONFIG_ARGS}
bazel build "${BAZEL_BUILD_OPTIONS[@]}" --remote_download_toplevel -c "${COMPILE_TYPE}" "${BUILD_TARGET}" ${CONFIG_ARGS}
collect_build_profile "${BINARY_TYPE}"_build

# Copy the built envoy binary somewhere that we can access outside of the
Expand All @@ -140,17 +140,17 @@ function bazel_binary_build() {
if [[ "${COMPILE_TYPE}" == "dbg" || "${COMPILE_TYPE}" == "opt" ]]; then
# Generate dwp file for debugging since we used split DWARF to reduce binary
# size
bazel build "${BAZEL_BUILD_OPTIONS[@]}" -c "${COMPILE_TYPE}" "${BUILD_DEBUG_INFORMATION}" ${CONFIG_ARGS}
bazel build "${BAZEL_BUILD_OPTIONS[@]}" --remote_download_toplevel -c "${COMPILE_TYPE}" "${BUILD_DEBUG_INFORMATION}" ${CONFIG_ARGS}
# Copy the debug information
cp -f bazel-bin/"${ENVOY_BIN}".dwp "${FINAL_DELIVERY_DIR}"/envoy.dwp
fi

# Validation tools for the tools image.
bazel build "${BAZEL_BUILD_OPTIONS[@]}" -c "${COMPILE_TYPE}" \
bazel build "${BAZEL_BUILD_OPTIONS[@]}" --remote_download_toplevel -c "${COMPILE_TYPE}" \
//test/tools/schema_validator:schema_validator_tool ${CONFIG_ARGS}

# Build su-exec utility
bazel build "${BAZEL_BUILD_OPTIONS[@]}" -c "${COMPILE_TYPE}" external:su-exec
bazel build "${BAZEL_BUILD_OPTIONS[@]}" --remote_download_toplevel -c "${COMPILE_TYPE}" external:su-exec
cp_binary_for_image_build "${BINARY_TYPE}" "${COMPILE_TYPE}" "${EXE_NAME}"
}

Expand Down Expand Up @@ -251,7 +251,7 @@ elif [[ "$CI_TARGET" == "bazel.distribution" ]]; then
"--action_env=PACKAGES_MAINTAINER_EMAIL")
fi

bazel build "${BAZEL_BUILD_OPTIONS[@]}" -c opt //distribution:packages.tar.gz
bazel build "${BAZEL_BUILD_OPTIONS[@]}" --remote_download_toplevel -c opt //distribution:packages.tar.gz
if [[ "${ENVOY_BUILD_ARCH}" == "x86_64" ]]; then
cp -a bazel-bin/distribution/packages.tar.gz "${ENVOY_BUILD_DIR}/packages.x64.tar.gz"
else
Expand Down Expand Up @@ -281,7 +281,7 @@ elif [[ "$CI_TARGET" == "bazel.gcc" ]]; then
setup_gcc_toolchain

echo "Testing ${TEST_TARGETS[*]}"
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" -c fastbuild -- "${TEST_TARGETS[@]}"
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" -c fastbuild --remote_download_minimal -- "${TEST_TARGETS[@]}"

echo "bazel release build with gcc..."
bazel_envoy_binary_build fastbuild
Expand All @@ -304,7 +304,7 @@ elif [[ "$CI_TARGET" == "bazel.debug.server_only" ]]; then
exit 0
elif [[ "$CI_TARGET" == "bazel.asan" ]]; then
setup_clang_toolchain
BAZEL_BUILD_OPTIONS+=(-c dbg "--config=clang-asan" "--build_tests_only")
BAZEL_BUILD_OPTIONS+=(-c dbg "--config=clang-asan" "--build_tests_only" "--remote_download_minimal")
echo "bazel ASAN/UBSAN debug build with tests"
echo "Building and testing envoy tests ${TEST_TARGETS[*]}"
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" "${TEST_TARGETS[@]}"
Expand All @@ -331,7 +331,7 @@ elif [[ "$CI_TARGET" == "bazel.tsan" ]]; then
setup_clang_toolchain
echo "bazel TSAN debug build with tests"
echo "Building and testing envoy tests ${TEST_TARGETS[*]}"
bazel_with_collection test --config=rbe-toolchain-tsan "${BAZEL_BUILD_OPTIONS[@]}" -c dbg --build_tests_only "${TEST_TARGETS[@]}"
bazel_with_collection test --config=rbe-toolchain-tsan "${BAZEL_BUILD_OPTIONS[@]}" -c dbg --build_tests_only --remote_download_minimal "${TEST_TARGETS[@]}"
if [ "${ENVOY_BUILD_FILTER_EXAMPLE}" == "1" ]; then
echo "Building and testing envoy-filter-example tests..."
pushd "${ENVOY_FILTER_EXAMPLE_SRCDIR}"
Expand All @@ -343,7 +343,7 @@ elif [[ "$CI_TARGET" == "bazel.msan" ]]; then
ENVOY_STDLIB=libc++
setup_clang_toolchain
# rbe-toolchain-msan must comes as first to win library link order.
BAZEL_BUILD_OPTIONS=("--config=rbe-toolchain-msan" "${BAZEL_BUILD_OPTIONS[@]}" "-c" "dbg" "--build_tests_only")
BAZEL_BUILD_OPTIONS=("--config=rbe-toolchain-msan" "${BAZEL_BUILD_OPTIONS[@]}" "-c" "dbg" "--build_tests_only" "--remote_download_minimal")
echo "bazel MSAN debug build with tests"
echo "Building and testing envoy tests ${TEST_TARGETS[*]}"
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" -- "${TEST_TARGETS[@]}"
Expand Down Expand Up @@ -385,7 +385,8 @@ elif [[ "$CI_TARGET" == "bazel.compile_time_options" ]]; then
"--define" "uhv=enabled"
"--@envoy//bazel:http3=False"
"--@envoy//source/extensions/filters/http/kill_request:enabled"
"--test_env=ENVOY_HAS_EXTRA_EXTENSIONS=true")
"--test_env=ENVOY_HAS_EXTRA_EXTENSIONS=true"
"--remote_download_minimal")

ENVOY_STDLIB="${ENVOY_STDLIB:-libstdc++}"
setup_clang_toolchain
Expand Down Expand Up @@ -427,7 +428,7 @@ elif [[ "$CI_TARGET" == "bazel.api" ]]; then
echo "Validate Golang protobuf generation..."
"${ENVOY_SRCDIR}"/tools/api/generate_go_protobuf.py
echo "Testing API..."
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" -c fastbuild @envoy_api//test/... @envoy_api//tools/... \
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" --remote_download_minimal -c fastbuild @envoy_api//test/... @envoy_api//tools/... \
@envoy_api//tools:tap2pcap_test
echo "Building API..."
bazel build "${BAZEL_BUILD_OPTIONS[@]}" -c fastbuild @envoy_api//envoy/...
Expand Down
4 changes: 3 additions & 1 deletion ci/setup_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ if [[ -n "${BAZEL_REMOTE_CACHE}" ]]; then
if [[ -n "${BAZEL_REMOTE_INSTANCE}" ]]; then
export BAZEL_BUILD_EXTRA_OPTIONS+=" --remote_instance_name=${BAZEL_REMOTE_INSTANCE}"
echo "instance_name: ${BAZEL_REMOTE_INSTANCE}."
elif [[ -z "${ENVOY_RBE}" ]]; then
fi

if [[ -z "${ENVOY_RBE}" ]]; then
export BAZEL_BUILD_EXTRA_OPTIONS+=" --jobs=HOST_CPUS*.99 --remote_timeout=600"
echo "using local build cache."
fi
Expand Down
3 changes: 3 additions & 0 deletions docs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ 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:-}"

# We want the binary at the end
BAZEL_BUILD_OPTIONS+=(--remote_download_toplevel)

if [[ "${AZP_BRANCH}" =~ ^refs/pull ]]; then
# For PRs use the unmerged PR commit in the version string.
#
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,7 +46,7 @@ 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_toplevel //tools/type_whisperer:api_build_file
cp -f bazel-bin/tools/type_whisperer/BUILD.api_build_file api/BUILD

# Dont run this in git hooks by default
Expand Down