diff --git a/.dockerignore b/.dockerignore index d99408bd2b9e..147dc71dc819 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,8 +6,10 @@ !/configs/*yaml !/linux/amd64/release.tar.zst !/linux/amd64/schema_validator_tool +!/linux/amd64/router_check_tool !/linux/arm64/release.tar.zst !/linux/arm64/schema_validator_tool +!/linux/arm64/router_check_tool !/local !/test/config/integration/certs !/windows diff --git a/.github/workflows/mobile-ios_build.yml b/.github/workflows/mobile-ios_build.yml index a568b2bf86a3..f2c149085325 100644 --- a/.github/workflows/mobile-ios_build.yml +++ b/.github/workflows/mobile-ios_build.yml @@ -42,7 +42,7 @@ jobs: command: ./bazelw container-command: request: ${{ needs.load.outputs.request }} - runs-on: macos-12 + runs-on: macos-12-large source: | source ./ci/mac_ci_setup.sh ./bazelw shutdown @@ -81,7 +81,7 @@ jobs: command: ./bazelw container-command: request: ${{ needs.load.outputs.request }} - runs-on: macos-12 + runs-on: macos-12-large source: | source ./ci/mac_ci_setup.sh ./bazelw shutdown @@ -126,7 +126,7 @@ jobs: command: ./bazelw container-command: request: ${{ needs.load.outputs.request }} - runs-on: macos-12 + runs-on: macos-12-large source: | source ./ci/mac_ci_setup.sh steps-post: | @@ -137,6 +137,7 @@ jobs: expected: >- ${{ matrix.expected || format('received headers with status {0}', matrix.expected-status) }} + timeout: ${{ matrix.timeout || '5m' }} env: ANDROID_NDK_HOME: ANDROID_HOME: @@ -163,6 +164,7 @@ jobs: expected: >- \[2\] Uploaded 7 MB of data target: swift-async-await + timeout: 10m - name: Build objc hello world app: //examples/objective-c/hello_world:app expected-status: 301 diff --git a/.github/workflows/mobile-perf.yml b/.github/workflows/mobile-perf.yml index f6b72b0fd543..f0d9d6e97325 100644 --- a/.github/workflows/mobile-perf.yml +++ b/.github/workflows/mobile-perf.yml @@ -61,17 +61,9 @@ jobs: --config=mobile-remote-release-clang //test/performance:test_binary_size # Ensure files don't leak back into the main binary - source: >- - rm - source/common/http/route_config_update_requster.h - source/common/listener_manager/listener_manager_impl.h - source/server/overload_manager_impl.cc - source/common/network/listen_socket_impl.h - source/common/network/tcp_listener_impl.h - source/server/guarddog_impl.h - source/server/watchdog_impl.h - source/server/options_impl.cc - source/extensions/access_loggers/common/file_access_log_impl.h + source: |- + TOREMOVE=$(cat mobile/test/performance/files_em_does_not_use | grep -vE '^#') + rm $TOREMOVE target: size-current - name: Main size args: >- diff --git a/api/envoy/extensions/filters/http/composite/v3/composite.proto b/api/envoy/extensions/filters/http/composite/v3/composite.proto index a6132b7043dd..a1f7639c410e 100644 --- a/api/envoy/extensions/filters/http/composite/v3/composite.proto +++ b/api/envoy/extensions/filters/http/composite/v3/composite.proto @@ -53,9 +53,11 @@ message ExecuteFilterAction { config.core.v3.TypedExtensionConfig typed_config = 1 [(udpa.annotations.field_migrate).oneof_promotion = "config_type"]; - // Dynamic configuration of filter obtained via extension configuration discovery - // service. + // Dynamic configuration of filter obtained via extension configuration discovery service. // Only one of ``typed_config`` or ``dynamic_config`` can be set. + // When composite filter is in upstream filter chain, the ``dynamic_config`` + // can not be set. TBD: Refactor cluster manager init sequence to Support this. + // Please check https://github.com/envoyproxy/envoy/issues/33218 for details. DynamicConfig dynamic_config = 2 [(udpa.annotations.field_migrate).oneof_promotion = "config_type"]; } diff --git a/bazel/coverage/fuzz_coverage_wrapper.sh b/bazel/coverage/fuzz_coverage_wrapper.sh index 2cdc1a348147..61bb8a60f31d 100755 --- a/bazel/coverage/fuzz_coverage_wrapper.sh +++ b/bazel/coverage/fuzz_coverage_wrapper.sh @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e TEST_BINARY=$1 shift diff --git a/bazel/external/boringssl_fips.genrule_cmd b/bazel/external/boringssl_fips.genrule_cmd index 44f21fc9c515..0c050743f478 100755 --- a/bazel/external/boringssl_fips.genrule_cmd +++ b/bazel/external/boringssl_fips.genrule_cmd @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/bazel/gen_sh_test_runner.sh b/bazel/gen_sh_test_runner.sh index 5665ce914814..9c3683c5bcb0 100755 --- a/bazel/gen_sh_test_runner.sh +++ b/bazel/gen_sh_test_runner.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Used in a genrule to wrap sh_test script for execution in # //test/coverage:coverage_tests single binary. diff --git a/bazel/get_workspace_status b/bazel/get_workspace_status index bc43475f01ac..472e9ed20c6c 100755 --- a/bazel/get_workspace_status +++ b/bazel/get_workspace_status @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This file was imported from https://github.com/bazelbuild/bazel at d6fec93. diff --git a/bazel/setup_clang.sh b/bazel/setup_clang.sh index a20b21cb1c34..1a8e2466f3cb 100755 --- a/bazel/setup_clang.sh +++ b/bazel/setup_clang.sh @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e BAZELRC_FILE="${BAZELRC_FILE:-./clang.bazelrc}" diff --git a/bazel/setup_local_tsan.sh b/bazel/setup_local_tsan.sh index a5bd56ceb812..ac115a3caa7a 100755 --- a/bazel/setup_local_tsan.sh +++ b/bazel/setup_local_tsan.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash BAZELRC_FILE="${BAZELRC_FILE:-$(bazel info workspace)/local_tsan.bazelrc}" diff --git a/bazel/sh_test_wrapper.sh b/bazel/sh_test_wrapper.sh index 8a290d6684d5..fd10ffee5671 100755 --- a/bazel/sh_test_wrapper.sh +++ b/bazel/sh_test_wrapper.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Dummy shell implementation for nooping tests. # TODO(lizan): remove when we have a solution for diff --git a/bazel/test/verify_tap_test.sh b/bazel/test/verify_tap_test.sh index 4a047e27e907..4423291bfd15 100755 --- a/bazel/test/verify_tap_test.sh +++ b/bazel/test/verify_tap_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -ex diff --git a/bazel/test_for_benchmark_wrapper.sh b/bazel/test_for_benchmark_wrapper.sh index 0a53ca0ada3e..f5086aa41c7d 100755 --- a/bazel/test_for_benchmark_wrapper.sh +++ b/bazel/test_for_benchmark_wrapper.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Set the benchmark time to 0 to just verify that the benchmark runs to # completion. We're interacting with two different flag parsers, so the order diff --git a/bazel/version_update_post.sh b/bazel/version_update_post.sh index ac877c1861f3..430669248126 100644 --- a/bazel/version_update_post.sh +++ b/bazel/version_update_post.sh @@ -1,5 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e set -o pipefail diff --git a/bazel/volatile_env.sh b/bazel/volatile_env.sh index e995c865a62f..5c3cc4afd0fa 100644 --- a/bazel/volatile_env.sh +++ b/bazel/volatile_env.sh @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ ! -f bazel-out/volatile-status.txt ]]; then # shellcheck disable=SC2016 diff --git a/changelogs/current.yaml b/changelogs/current.yaml index f35b5b537359..b03e154d3940 100644 --- a/changelogs/current.yaml +++ b/changelogs/current.yaml @@ -408,6 +408,12 @@ new_features: - area: http change: | Added DownstreamRemoteReset to CoreResponseFlag, and it is set when stream is remote reset. +- area: match_delegate + change: | + Convert match_delegate fiter into dual filter so it can be installed in the upstream filter chain. +- area: composite + change: | + Convert composite fiter into dual filter so it can be installed in the upstream filter chain. - area: tracing change: | Added support for variant span attribute type for the OpenTelemetry tracer. diff --git a/ci/Dockerfile-envoy b/ci/Dockerfile-envoy index c8c246511211..8c4293aa3f27 100644 --- a/ci/Dockerfile-envoy +++ b/ci/Dockerfile-envoy @@ -54,7 +54,7 @@ FROM envoy AS envoy-tools ARG TARGETPLATFORM ENV TARGETPLATFORM="${TARGETPLATFORM:-linux/amd64}" COPY --chown=0:0 --chmod=755 \ - "${TARGETPLATFORM}/schema_validator_tool" /usr/local/bin/schema_validator_tool + "${TARGETPLATFORM}/schema_validator_tool" "${TARGETPLATFORM}/router_check_tool" /usr/local/bin/ # STAGE: envoy-distroless diff --git a/ci/build_setup.sh b/ci/build_setup.sh index c56a6eb746a7..139538d6ff53 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Configure environment variables for Bazel build and test. diff --git a/ci/check_and_fix_format.sh b/ci/check_and_fix_format.sh index a07de6f7a183..28a928d6c9e3 100755 --- a/ci/check_and_fix_format.sh +++ b/ci/check_and_fix_format.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 9f0208fa49fd..b9843000e094 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run a CI build/test target, e.g. docs, asan. @@ -134,6 +134,8 @@ function cp_binary_for_image_build() { # Tools for the tools image. Strip to save size. strip bazel-bin/test/tools/schema_validator/schema_validator_tool \ -o "${BASE_TARGET_DIR}"/"${TARGET_DIR}"/schema_validator_tool + strip bazel-bin/test/tools/router_check/router_check_tool \ + -o "${BASE_TARGET_DIR}"/"${TARGET_DIR}"/router_check_tool # Copy the su-exec utility binary into the image cp -f bazel-bin/external/com_github_ncopa_suexec/su-exec "${BASE_TARGET_DIR}"/"${TARGET_DIR}" @@ -199,6 +201,8 @@ function bazel_binary_build() { # Validation tools for the tools image. bazel build "${BAZEL_BUILD_OPTIONS[@]}" --remote_download_toplevel -c "${COMPILE_TYPE}" \ //test/tools/schema_validator:schema_validator_tool "${CONFIG_ARGS[@]}" + bazel build "${BAZEL_BUILD_OPTIONS[@]}" --remote_download_toplevel -c "${COMPILE_TYPE}" \ + //test/tools/router_check:router_check_tool "${CONFIG_ARGS[@]}" # Build su-exec utility bazel build "${BAZEL_BUILD_OPTIONS[@]}" --remote_download_toplevel -c "${COMPILE_TYPE}" external:su-exec @@ -853,6 +857,12 @@ case $CI_TARGET in cp -a \ bazel-bin/test/tools/schema_validator/schema_validator_tool.stripped \ "${ENVOY_BINARY_DIR}/schema_validator_tool" + bazel build "${BAZEL_BUILD_OPTIONS[@]}" "${BAZEL_RELEASE_OPTIONS[@]}" \ + --remote_download_toplevel \ + //test/tools/router_check:router_check_tool.stripped + cp -a \ + bazel-bin/test/tools/router_check/router_check_tool.stripped \ + "${ENVOY_BINARY_DIR}/router_check_tool" echo "Release files created in ${ENVOY_BINARY_DIR}" ;; diff --git a/ci/docker_ci.sh b/ci/docker_ci.sh index fdf6cdaf74b5..2e16ebf98a2a 100755 --- a/ci/docker_ci.sh +++ b/ci/docker_ci.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Do not ever set -x here, it is a security hazard as it will place the credentials below in the # CI logs. diff --git a/ci/docker_rebuild_google-vrp.sh b/ci/docker_rebuild_google-vrp.sh index 36dc9d80ef79..a65804f876f6 100755 --- a/ci/docker_rebuild_google-vrp.sh +++ b/ci/docker_rebuild_google-vrp.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Script to rebuild Dockerfile-envoy-google-vrp locally (i.e. not in CI) for development purposes. # This makes use of the latest envoy:dev base image on Docker Hub as the base and takes an diff --git a/ci/envoy_build_sha.sh b/ci/envoy_build_sha.sh index 03d8eb936ab9..916da9b84b76 100644 --- a/ci/envoy_build_sha.sh +++ b/ci/envoy_build_sha.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ENVOY_BUILD_CONTAINER="$(grep envoyproxy/envoy-build-ubuntu "$(dirname "$0")"/../.bazelrc | sed -e 's#.*envoyproxy/envoy-build-ubuntu:\(.*\)#\1#' | uniq)" diff --git a/ci/filter_example_setup.sh b/ci/filter_example_setup.sh index 94511ac5babe..19b10272973b 100644 --- a/ci/filter_example_setup.sh +++ b/ci/filter_example_setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Configure environment for Envoy Filter Example build and test. diff --git a/ci/format_pre.sh b/ci/format_pre.sh index f4627dea89d8..ad7054ca2c17 100755 --- a/ci/format_pre.sh +++ b/ci/format_pre.sh @@ -1,4 +1,6 @@ -#!/bin/bash -E +#!/usr/bin/env bash + +set -E # Pre-checks for validation and linting # diff --git a/ci/mac_ci_setup.sh b/ci/mac_ci_setup.sh index 2646a366e957..a830536bc735 100755 --- a/ci/mac_ci_setup.sh +++ b/ci/mac_ci_setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Installs the dependencies required for a macOS build via homebrew. # Tools are not upgraded to new versions. diff --git a/ci/mac_ci_steps.sh b/ci/mac_ci_steps.sh index 98fbf618d744..2f2cc584f3c5 100755 --- a/ci/mac_ci_steps.sh +++ b/ci/mac_ci_steps.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/ci/reopen_branch.sh b/ci/reopen_branch.sh index 068bfad31bcd..20aff14b79fc 100755 --- a/ci/reopen_branch.sh +++ b/ci/reopen_branch.sh @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e ENVOY_GIT_USERNAME="${ENVOY_GIT_USERNAME:-envoy-bot}" ENVOY_GIT_EMAIL="${ENVOY_GIT_EMAIL:-envoy-bot@users.noreply.github.com}" diff --git a/ci/run_clang_tidy.sh b/ci/run_clang_tidy.sh index b3660cb78971..4716ce1f8cc6 100755 --- a/ci/run_clang_tidy.sh +++ b/ci/run_clang_tidy.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eo pipefail diff --git a/ci/run_envoy_docker.sh b/ci/run_envoy_docker.sh index 094572f3b56d..809d141fb9da 100755 --- a/ci/run_envoy_docker.sh +++ b/ci/run_envoy_docker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/ci/test_docker_ci.sh b/ci/test_docker_ci.sh index bd9748aa2b05..f29964f35311 100755 --- a/ci/test_docker_ci.sh +++ b/ci/test_docker_ci.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run this with `./ci/test_docker_ci.sh`. # diff --git a/ci/upload_gcs_artifact.sh b/ci/upload_gcs_artifact.sh index 339a4e98dc4d..f088f60299b8 100755 --- a/ci/upload_gcs_artifact.sh +++ b/ci/upload_gcs_artifact.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e -o pipefail diff --git a/ci/verify_examples.sh b/ci/verify_examples.sh index f267a4a464f7..28ac5dfe9b15 100755 --- a/ci/verify_examples.sh +++ b/ci/verify_examples.sh @@ -1,4 +1,6 @@ -#!/bin/bash -E +#!/usr/bin/env bash + +set -E TESTFILTER="${1:-*}" TESTEXCLUDES="${2}" diff --git a/configs/configgen.sh b/configs/configgen.sh index 72347b1faecc..7e5a34bd1e8f 100755 --- a/configs/configgen.sh +++ b/configs/configgen.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/configs/google-vrp/launch_envoy.sh b/configs/google-vrp/launch_envoy.sh index f9aaa78f82b9..7b253b407ca7 100755 --- a/configs/google-vrp/launch_envoy.sh +++ b/configs/google-vrp/launch_envoy.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash cd /etc/envoy || exit envoy "$@" diff --git a/contrib/cryptomb/private_key_providers/test/test_data/generate-keys.sh b/contrib/cryptomb/private_key_providers/test/test_data/generate-keys.sh index 95b1e59faf37..b3f85eb0f11a 100755 --- a/contrib/cryptomb/private_key_providers/test/test_data/generate-keys.sh +++ b/contrib/cryptomb/private_key_providers/test/test_data/generate-keys.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/contrib/qat/private_key_providers/test/test_data/generate-keys.sh b/contrib/qat/private_key_providers/test/test_data/generate-keys.sh index 8272498f9ea0..5b9d3f999ab2 100755 --- a/contrib/qat/private_key_providers/test/test_data/generate-keys.sh +++ b/contrib/qat/private_key_providers/test/test_data/generate-keys.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/distribution/distrotest.sh b/distribution/distrotest.sh index 0a3ec6a48d3f..faa2ab33c1c0 100755 --- a/distribution/distrotest.sh +++ b/distribution/distrotest.sh @@ -1,4 +1,6 @@ -#!/bin/bash -E +#!/usr/bin/env bash + +set -E FAILED=() TESTNAME= diff --git a/docs/root/configuration/operations/overload_manager/overload_manager.rst b/docs/root/configuration/operations/overload_manager/overload_manager.rst index dcc522e31d12..6f785adb30ef 100644 --- a/docs/root/configuration/operations/overload_manager/overload_manager.rst +++ b/docs/root/configuration/operations/overload_manager/overload_manager.rst @@ -382,4 +382,5 @@ with the following statistics: :widths: 1, 1, 2 scale_percent, Gauge, "Scaled value of the action as a percent (0-99=scaling, 100=saturated)" + shed_load_count, Counter, "Total count the load is sheded" diff --git a/docs/root/operations/tools/route_table_check_tool.rst b/docs/root/operations/tools/route_table_check_tool.rst index 24a129adcea6..afebcd471c58 100644 --- a/docs/root/operations/tools/route_table_check_tool.rst +++ b/docs/root/operations/tools/route_table_check_tool.rst @@ -72,6 +72,8 @@ Output If the ``--only-show-failures`` flag is provided, only the failed test cases are written to a file. Building + The tool is included in the :ref:`tools image `. + The tool can be built locally using Bazel. :: bazel build //test/tools/router_check:router_check_tool diff --git a/envoy/upstream/cluster_manager.h b/envoy/upstream/cluster_manager.h index 7857015e7642..1c311730228a 100644 --- a/envoy/upstream/cluster_manager.h +++ b/envoy/upstream/cluster_manager.h @@ -214,6 +214,21 @@ class ClusterManager { virtual ~ClusterManager() = default; + // API to initialize the ClusterManagerImpl instance based on the given Bootstrap config. + // + // This method *must* be called prior to invoking any other methods on the class and *must* only + // be called once. This method should be called immediately after ClusterManagerImpl construction + // and from the same thread in which the ClusterManagerImpl was constructed. + // + // The initialization is separated from the constructor because lots of work, including ADS + // initialization, is done in this method. If the contents of this method are invoked during + // construction, a derived class cannot override any of the virtual methods and have them invoked + // instead, since the base class's methods are used when in a base class constructor. + virtual absl::Status initialize(const envoy::config::bootstrap::v3::Bootstrap& bootstrap) PURE; + + // API to return whether the ClusterManagerImpl instance is initialized. + virtual bool initialized() PURE; + /** * Add or update a cluster via API. The semantics of this API are: * 1) The hash of the config is used to determine if an already existing cluster has changed. @@ -491,6 +506,8 @@ class ClusterManagerFactory { /** * Allocate a cluster manager from configuration proto. + * The cluster manager init() method needs to be called right after this method. + * Please check https://github.com/envoyproxy/envoy/issues/33218 for details. */ virtual ClusterManagerPtr clusterManagerFromProto(const envoy::config::bootstrap::v3::Bootstrap& bootstrap) PURE; diff --git a/mobile/bazelw b/mobile/bazelw index 53714b34fbfd..7d16ff11b932 100755 --- a/mobile/bazelw +++ b/mobile/bazelw @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/mobile/ci/linux_ci_setup.sh b/mobile/ci/linux_ci_setup.sh index f8149613f449..7ca6d31ecb99 100755 --- a/mobile/ci/linux_ci_setup.sh +++ b/mobile/ci/linux_ci_setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/mobile/ci/mac_ci_setup.sh b/mobile/ci/mac_ci_setup.sh index eb0fb8ad7a69..1fd4760ac10e 100755 --- a/mobile/ci/mac_ci_setup.sh +++ b/mobile/ci/mac_ci_setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/mobile/ci/start_android_emulator.sh b/mobile/ci/start_android_emulator.sh index 8b582c343304..e38e92d741f3 100755 --- a/mobile/ci/start_android_emulator.sh +++ b/mobile/ci/start_android_emulator.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/mobile/ci/start_ios_simulator.sh b/mobile/ci/start_ios_simulator.sh index 442d8be1180f..de5ea3649fdb 100755 --- a/mobile/ci/start_ios_simulator.sh +++ b/mobile/ci/start_ios_simulator.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/mobile/ci/test_size_regression.sh b/mobile/ci/test_size_regression.sh index 81b96e52a559..58ae87727e67 100755 --- a/mobile/ci/test_size_regression.sh +++ b/mobile/ci/test_size_regression.sh @@ -1,5 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e set -o pipefail # Checks the absolute size and the relative size increase of a file. diff --git a/mobile/docs/build.sh b/mobile/docs/build.sh index c53756660690..7435afa51ce4 100755 --- a/mobile/docs/build.sh +++ b/mobile/docs/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/mobile/docs/publish.sh b/mobile/docs/publish.sh index 03b40a059e77..5554a8b841f4 100755 --- a/mobile/docs/publish.sh +++ b/mobile/docs/publish.sh @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e # This is run on every commit that GitHub Actions picks up. It assumes that docs have already been # built via docs/build.sh. The commit behavior differs depending on the nature of the commit: diff --git a/mobile/remote b/mobile/remote index 34ddd25cd16c..d6828af230ac 100755 --- a/mobile/remote +++ b/mobile/remote @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/mobile/test/kotlin/integration/ReceiveTrailersTest.kt b/mobile/test/kotlin/integration/ReceiveTrailersTest.kt index 229158820208..9902d8a441f2 100644 --- a/mobile/test/kotlin/integration/ReceiveTrailersTest.kt +++ b/mobile/test/kotlin/integration/ReceiveTrailersTest.kt @@ -89,12 +89,13 @@ class ReceiveTrailersTest { .sendHeaders(requestHeadersDefault, false) .sendData(body) .close(requestTrailers) + expectation.await(10, TimeUnit.SECONDS) + trailersReceived.await(10, TimeUnit.SECONDS) engine.terminate() assertThat(trailersReceived.count).isEqualTo(0) - trailersReceived.await(10, TimeUnit.SECONDS) assertThat(expectation.count).isEqualTo(0) assertThat(responseStatus).isEqualTo(200) assertThat(trailerValues).contains(TRAILER_VALUE) diff --git a/mobile/test/performance/files_em_does_not_use b/mobile/test/performance/files_em_does_not_use new file mode 100644 index 000000000000..46569cf0675f --- /dev/null +++ b/mobile/test/performance/files_em_does_not_use @@ -0,0 +1,10 @@ +# .github/workflows/mobile-perf.yml regression tests these files are not used in the E-M build. +source/common/http/route_config_update_requster.h +source/common/listener_manager/listener_manager_impl.h +source/server/overload_manager_impl.cc +source/common/network/listen_socket_impl.h +source/common/network/tcp_listener_impl.h +source/server/guarddog_impl.h +source/server/watchdog_impl.h +source/server/options_impl.cc +source/extensions/access_loggers/common/file_access_log_impl.h diff --git a/mobile/third_party/rbe_configs/cc/cc_wrapper.sh b/mobile/third_party/rbe_configs/cc/cc_wrapper.sh index fb34ce88c37b..02b92a1444a2 100644 --- a/mobile/third_party/rbe_configs/cc/cc_wrapper.sh +++ b/mobile/third_party/rbe_configs/cc/cc_wrapper.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2015 The Bazel Authors. All rights reserved. # diff --git a/mobile/tools/ktfmt.sh b/mobile/tools/ktfmt.sh index 2f585038a07c..812955885347 100755 --- a/mobile/tools/ktfmt.sh +++ b/mobile/tools/ktfmt.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/source/common/formatter/http_specific_formatter.cc b/source/common/formatter/http_specific_formatter.cc index 0479fc608a17..4ff9dd4fceae 100644 --- a/source/common/formatter/http_specific_formatter.cc +++ b/source/common/formatter/http_specific_formatter.cc @@ -405,7 +405,8 @@ FormatterProviderPtr HttpBuiltInCommandParser::parse(const std::string& command, } // Check flags for the command. - CommandSyntaxChecker::verifySyntax((*it).second.first, command, subcommand, max_length); + THROW_IF_NOT_OK( + CommandSyntaxChecker::verifySyntax((*it).second.first, command, subcommand, max_length)); // Create a pointer to the formatter by calling a function // associated with formatter's name. diff --git a/source/common/formatter/stream_info_formatter.h b/source/common/formatter/stream_info_formatter.h index 7ab2bb046bd2..cfbcc27d86f3 100644 --- a/source/common/formatter/stream_info_formatter.h +++ b/source/common/formatter/stream_info_formatter.h @@ -329,7 +329,8 @@ class CommonStreamInfoFormatterBase : public FormatterProviderBase& length) { +absl::Status CommandSyntaxChecker::verifySyntax(CommandSyntaxFlags flags, + const std::string& command, + const std::string& subcommand, + const absl::optional& length) { if ((flags == COMMAND_ONLY) && ((subcommand.length() != 0) || length.has_value())) { - throwEnvoyExceptionOrPanic(fmt::format("{} does not take any parameters or length", command)); + return absl::InvalidArgumentError( + fmt::format("{} does not take any parameters or length", command)); } if ((flags & PARAMS_REQUIRED).any() && (subcommand.length() == 0)) { - throwEnvoyExceptionOrPanic(fmt::format("{} requires parameters", command)); + return absl::InvalidArgumentError(fmt::format("{} requires parameters", command)); } if ((flags & LENGTH_ALLOWED).none() && length.has_value()) { - throwEnvoyExceptionOrPanic(fmt::format("{} does not allow length to be specified.", command)); + return absl::InvalidArgumentError( + fmt::format("{} does not allow length to be specified.", command)); } + return absl::OkStatus(); } const absl::optional> diff --git a/source/common/formatter/substitution_format_utility.h b/source/common/formatter/substitution_format_utility.h index 80b8a1368074..596e1f549b7e 100644 --- a/source/common/formatter/substitution_format_utility.h +++ b/source/common/formatter/substitution_format_utility.h @@ -23,9 +23,9 @@ class CommandSyntaxChecker { static constexpr CommandSyntaxFlags PARAMS_OPTIONAL = 1 << 1; static constexpr CommandSyntaxFlags LENGTH_ALLOWED = 1 << 2; - static void verifySyntax(CommandSyntaxChecker::CommandSyntaxFlags flags, - const std::string& command, const std::string& subcommand, - const absl::optional& length); + static absl::Status verifySyntax(CommandSyntaxChecker::CommandSyntaxFlags flags, + const std::string& command, const std::string& subcommand, + const absl::optional& length); }; /** diff --git a/source/common/http/matching/data_impl.h b/source/common/http/matching/data_impl.h index 7bcf9e251d12..bc98d85f6cb3 100644 --- a/source/common/http/matching/data_impl.h +++ b/source/common/http/matching/data_impl.h @@ -67,10 +67,14 @@ class HttpMatchingDataImpl : public HttpMatchingData { using HttpMatchingDataImplSharedPtr = std::shared_ptr; struct HttpFilterActionContext { + // Identify whether the filter is in downstream filter chain or upstream filter chain. + const bool is_downstream_ = true; const std::string& stat_prefix_; OptRef factory_context_; + OptRef upstream_factory_context_; OptRef server_factory_context_; }; + } // namespace Matching } // namespace Http } // namespace Envoy diff --git a/source/common/upstream/cluster_manager_impl.cc b/source/common/upstream/cluster_manager_impl.cc index 80119fe2498b..941682c88260 100644 --- a/source/common/upstream/cluster_manager_impl.cc +++ b/source/common/upstream/cluster_manager_impl.cc @@ -370,7 +370,8 @@ ClusterManagerImpl::ClusterManagerImpl( makeOptRefFromPtr(xds_config_tracker_.get())); } -absl::Status ClusterManagerImpl::init(const envoy::config::bootstrap::v3::Bootstrap& bootstrap) { +absl::Status +ClusterManagerImpl::initialize(const envoy::config::bootstrap::v3::Bootstrap& bootstrap) { ASSERT(!initialized_); initialized_ = true; @@ -2224,7 +2225,6 @@ ClusterManagerPtr ProdClusterManagerFactory::clusterManagerFromProto( context_.accessLogManager(), context_.mainThreadDispatcher(), context_.admin(), context_.messageValidationContext(), context_.api(), http_context_, context_.grpcContext(), context_.routerContext(), server_)}; - THROW_IF_NOT_OK(cluster_manager_impl->init(bootstrap)); return cluster_manager_impl; } diff --git a/source/common/upstream/cluster_manager_impl.h b/source/common/upstream/cluster_manager_impl.h index 95c95fbded13..163ecdbee7d6 100644 --- a/source/common/upstream/cluster_manager_impl.h +++ b/source/common/upstream/cluster_manager_impl.h @@ -246,17 +246,9 @@ class ClusterManagerImpl : public ClusterManager, public MissingClusterNotifier, Logger::Loggable { public: - // Initializes the ClusterManagerImpl instance based on the given Bootstrap config. - // - // This method *must* be called prior to invoking any other methods on the class and *must* only - // be called once. This method should be called immediately after ClusterManagerImpl construction - // and from the same thread in which the ClusterManagerImpl was constructed. - // - // The initialization is separated from the constructor because lots of work, including ADS - // initialization, is done in this method. If the contents of this method are invoked during - // construction, a derived class cannot override any of the virtual methods and have them invoked - // instead, since the base class's methods are used when in a base class constructor. - absl::Status init(const envoy::config::bootstrap::v3::Bootstrap& bootstrap); + absl::Status initialize(const envoy::config::bootstrap::v3::Bootstrap& bootstrap) override; + + bool initialized() override { return initialized_; } std::size_t warmingClusterCount() const { return warming_clusters_.size(); } diff --git a/source/common/version/generate_version_linkstamp.sh b/source/common/version/generate_version_linkstamp.sh index d8873f8b5a33..d749f8307278 100755 --- a/source/common/version/generate_version_linkstamp.sh +++ b/source/common/version/generate_version_linkstamp.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script generates a header file that is used by version_lib whenever linkstamp is not allowed. # linkstamp is used to link in version_linkstamp.cc into the version_lib. diff --git a/source/extensions/extensions_metadata.yaml b/source/extensions/extensions_metadata.yaml index 74bd6c33d5d5..3c943169d237 100644 --- a/source/extensions/extensions_metadata.yaml +++ b/source/extensions/extensions_metadata.yaml @@ -278,8 +278,10 @@ envoy.filters.http.upstream_codec: envoy.filters.http.composite: categories: - envoy.filters.http + - envoy.filters.http.upstream security_posture: unknown status: stable + status_upstream: alpha type_urls: - envoy.extensions.filters.http.composite.v3.Composite envoy.filters.http.compressor: diff --git a/source/extensions/filters/http/common/factory_base.h b/source/extensions/filters/http/common/factory_base.h index 3773237ae85e..6dacd1fe47a8 100644 --- a/source/extensions/filters/http/common/factory_base.h +++ b/source/extensions/filters/http/common/factory_base.h @@ -159,6 +159,26 @@ class DualFactoryBase : public CommonFactoryBase, createFilterFactoryFromProtoTyped(const ConfigProto& proto_config, const std::string& stats_prefix, DualInfo info, Server::Configuration::ServerFactoryContext& context) PURE; + + // This method is for dual filter to create filter from server context when it is configured + // in downstream. If a dual filter is in upstream, it must not call this method. + Envoy::Http::FilterFactoryCb createFilterFactoryFromProtoWithServerContext( + const Protobuf::Message& proto_config, const std::string& stats_prefix, + Server::Configuration::ServerFactoryContext& server_context) override { + return createFilterFactoryFromProtoWithServerContextTyped( + MessageUtil::downcastAndValidate( + proto_config, server_context.messageValidationVisitor()), + stats_prefix, server_context); + } + +private: + virtual Envoy::Http::FilterFactoryCb + createFilterFactoryFromProtoWithServerContextTyped(const ConfigProto&, const std::string&, + Server::Configuration::ServerFactoryContext&) { + ExceptionUtil::throwEnvoyException( + "Creating filter factory from server factory context is not supported"); + return nullptr; + } }; } // namespace Common diff --git a/source/extensions/filters/http/composite/action.cc b/source/extensions/filters/http/composite/action.cc index d4cbf7f7fe1c..742fbc444a0e 100644 --- a/source/extensions/filters/http/composite/action.cc +++ b/source/extensions/filters/http/composite/action.cc @@ -25,6 +25,11 @@ Matcher::ActionFactoryCb ExecuteFilterActionFactory::createActionFactoryCb( } if (composite_action.has_dynamic_config()) { + if (!context.is_downstream_) { + throw EnvoyException(fmt::format("When composite filter is in upstream, the composite action " + "config must not be dynamic.")); + } + if (!context.factory_context_.has_value() || !context.server_factory_context_.has_value()) { throw EnvoyException(fmt::format("Failed to get factory context or server factory context.")); } @@ -53,6 +58,17 @@ Matcher::ActionFactoryCb ExecuteFilterActionFactory::createActionFactoryCb( }; } + if (context.is_downstream_) { + return createActionFactoryCbDownstream(composite_action, context, validation_visitor); + } else { + return createActionFactoryCbUpstream(composite_action, context, validation_visitor); + } +} + +Matcher::ActionFactoryCb ExecuteFilterActionFactory::createActionFactoryCbDownstream( + const envoy::extensions::filters::http::composite::v3::ExecuteFilterAction& composite_action, + Http::Matching::HttpFilterActionContext& context, + ProtobufMessage::ValidationVisitor& validation_visitor) { auto& factory = Config::Utility::getAndCheckFactory( composite_action.typed_config()); @@ -69,8 +85,8 @@ Matcher::ActionFactoryCb ExecuteFilterActionFactory::createActionFactoryCb( callback = callback_or_status.value(); } - // If above failed, try to create the filter factory creation function from server factory - // context (if exists). + // If above failed, for downstream case, try to create the filter factory creation function + // from server factory context if exists. if (callback == nullptr && context.server_factory_context_.has_value()) { callback = factory.createFilterFactoryFromProtoWithServerContext( *message, context.stat_prefix_, context.server_factory_context_.value()); @@ -86,6 +102,37 @@ Matcher::ActionFactoryCb ExecuteFilterActionFactory::createActionFactoryCb( }; } +Matcher::ActionFactoryCb ExecuteFilterActionFactory::createActionFactoryCbUpstream( + const envoy::extensions::filters::http::composite::v3::ExecuteFilterAction& composite_action, + Http::Matching::HttpFilterActionContext& context, + ProtobufMessage::ValidationVisitor& validation_visitor) { + auto& factory = + Config::Utility::getAndCheckFactory( + composite_action.typed_config()); + ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( + composite_action.typed_config().typed_config(), validation_visitor, factory); + + Envoy::Http::FilterFactoryCb callback = nullptr; + + // First, try to create the filter factory creation function from upstream factory context (if + // exists). + if (context.upstream_factory_context_.has_value()) { + auto callback_or_status = factory.createFilterFactoryFromProto( + *message, context.stat_prefix_, context.upstream_factory_context_.value()); + THROW_IF_STATUS_NOT_OK(callback_or_status, throw); + callback = callback_or_status.value(); + } + + if (callback == nullptr) { + throw EnvoyException("Failed to get filter factory creation function"); + } + std::string name = composite_action.typed_config().name(); + + return [cb = std::move(callback), n = std::move(name)]() -> Matcher::ActionPtr { + return std::make_unique(cb, n); + }; +} + REGISTER_FACTORY(ExecuteFilterActionFactory, Matcher::ActionFactory); } // namespace Composite diff --git a/source/extensions/filters/http/composite/action.h b/source/extensions/filters/http/composite/action.h index af8241a03887..55dab9bac336 100644 --- a/source/extensions/filters/http/composite/action.h +++ b/source/extensions/filters/http/composite/action.h @@ -41,6 +41,17 @@ class ExecuteFilterActionFactory ProtobufTypes::MessagePtr createEmptyConfigProto() override { return std::make_unique(); } + +private: + Matcher::ActionFactoryCb createActionFactoryCbDownstream( + const envoy::extensions::filters::http::composite::v3::ExecuteFilterAction& composite_action, + Http::Matching::HttpFilterActionContext& context, + ProtobufMessage::ValidationVisitor& validation_visitor); + + Matcher::ActionFactoryCb createActionFactoryCbUpstream( + const envoy::extensions::filters::http::composite::v3::ExecuteFilterAction& composite_action, + Http::Matching::HttpFilterActionContext& context, + ProtobufMessage::ValidationVisitor& validation_visitor); }; DECLARE_FACTORY(ExecuteFilterActionFactory); diff --git a/source/extensions/filters/http/composite/config.cc b/source/extensions/filters/http/composite/config.cc index 5702472fa016..074b80d06ad2 100644 --- a/source/extensions/filters/http/composite/config.cc +++ b/source/extensions/filters/http/composite/config.cc @@ -10,13 +10,14 @@ namespace Extensions { namespace HttpFilters { namespace Composite { -Http::FilterFactoryCb CompositeFilterFactory::createFilterFactoryFromProtoTyped( +absl::StatusOr CompositeFilterFactory::createFilterFactoryFromProtoTyped( const envoy::extensions::filters::http::composite::v3::Composite&, - const std::string& stat_prefix, Server::Configuration::FactoryContext& factory_context) { + const std::string& stat_prefix, DualInfo dual_info, + Server::Configuration::ServerFactoryContext&) { const auto& prefix = stat_prefix + "composite."; - auto stats = std::make_shared(FilterStats{ - ALL_COMPOSITE_FILTER_STATS(POOL_COUNTER_PREFIX(factory_context.scope(), prefix))}); + auto stats = std::make_shared( + FilterStats{ALL_COMPOSITE_FILTER_STATS(POOL_COUNTER_PREFIX(dual_info.scope, prefix))}); return [stats](Http::FilterChainFactoryCallbacks& callbacks) -> void { auto filter = std::make_shared(*stats, callbacks.dispatcher()); @@ -29,6 +30,8 @@ Http::FilterFactoryCb CompositeFilterFactory::createFilterFactoryFromProtoTyped( * Static registration for the composite filter. @see RegisterFactory. */ REGISTER_FACTORY(CompositeFilterFactory, Server::Configuration::NamedHttpFilterConfigFactory); +REGISTER_FACTORY(UpstreamCompositeFilterFactory, + Server::Configuration::UpstreamHttpFilterConfigFactory); } // namespace Composite } // namespace HttpFilters diff --git a/source/extensions/filters/http/composite/config.h b/source/extensions/filters/http/composite/config.h index 8d088994378e..f0858670a9ff 100644 --- a/source/extensions/filters/http/composite/config.h +++ b/source/extensions/filters/http/composite/config.h @@ -22,13 +22,14 @@ namespace Composite { * Config registration for the composite filter. @see NamedHttpFilterConfigFactory. */ class CompositeFilterFactory - : public Common::FactoryBase { + : public Common::DualFactoryBase { public: - CompositeFilterFactory() : FactoryBase("envoy.filters.http.composite") {} + CompositeFilterFactory() : DualFactoryBase("envoy.filters.http.composite") {} - Http::FilterFactoryCb createFilterFactoryFromProtoTyped( + absl::StatusOr createFilterFactoryFromProtoTyped( const envoy::extensions::filters::http::composite::v3::Composite& proto_config, - const std::string& stats_prefix, Server::Configuration::FactoryContext& context) override; + const std::string& stats_prefix, DualInfo dual_info, + Server::Configuration::ServerFactoryContext& context) override; Server::Configuration::MatchingRequirementsPtr matchingRequirements() override { auto requirements = std::make_unique< @@ -48,7 +49,10 @@ class CompositeFilterFactory } }; +using UpstreamCompositeFilterFactory = CompositeFilterFactory; + DECLARE_FACTORY(CompositeFilterFactory); +DECLARE_FACTORY(UpstreamCompositeFilterFactory); } // namespace Composite } // namespace HttpFilters diff --git a/source/extensions/filters/http/match_delegate/config.cc b/source/extensions/filters/http/match_delegate/config.cc index c2e6d3e5cdf4..a0eeac644a14 100644 --- a/source/extensions/filters/http/match_delegate/config.cc +++ b/source/extensions/filters/http/match_delegate/config.cc @@ -271,23 +271,52 @@ void DelegatingStreamFilter::setEncoderFilterCallbacks( absl::StatusOr MatchDelegateConfig::createFilterFactoryFromProtoTyped( const envoy::extensions::common::matching::v3::ExtensionWithMatcher& proto_config, const std::string& prefix, Server::Configuration::FactoryContext& context) { - ASSERT(proto_config.has_extension_config()); auto& factory = Config::Utility::getAndCheckFactory( proto_config.extension_config()); + Envoy::Http::Matching::HttpFilterActionContext action_context{ + .is_downstream_ = true, + .stat_prefix_ = prefix, + .factory_context_ = context, + .upstream_factory_context_ = absl::nullopt, + .server_factory_context_ = context.serverFactoryContext()}; + return createFilterFactory(proto_config, prefix, context.messageValidationVisitor(), + action_context, context, factory); +} +absl::StatusOr MatchDelegateConfig::createFilterFactoryFromProtoTyped( + const envoy::extensions::common::matching::v3::ExtensionWithMatcher& proto_config, + const std::string& prefix, Server::Configuration::UpstreamFactoryContext& context) { + ASSERT(proto_config.has_extension_config()); + auto& factory = + Config::Utility::getAndCheckFactory( + proto_config.extension_config()); + Envoy::Http::Matching::HttpFilterActionContext action_context{ + .is_downstream_ = false, + .stat_prefix_ = prefix, + .factory_context_ = absl::nullopt, + .upstream_factory_context_ = context, + .server_factory_context_ = context.serverFactoryContext()}; + return createFilterFactory(proto_config, prefix, + context.serverFactoryContext().messageValidationVisitor(), + action_context, context, factory); +} + +template +absl::StatusOr MatchDelegateConfig::createFilterFactory( + const envoy::extensions::common::matching::v3::ExtensionWithMatcher& proto_config, + const std::string& prefix, ProtobufMessage::ValidationVisitor& validation, + Envoy::Http::Matching::HttpFilterActionContext& action_context, FactoryCtx& context, + FilterCfgFactory& factory) { auto message = Config::Utility::translateAnyToFactoryConfig( - proto_config.extension_config().typed_config(), context.messageValidationVisitor(), factory); + proto_config.extension_config().typed_config(), validation, factory); auto filter_factory_or_error = factory.createFilterFactoryFromProto(*message, prefix, context); RETURN_IF_STATUS_NOT_OK(filter_factory_or_error); auto filter_factory = filter_factory_or_error.value(); Factory::MatchTreeValidationVisitor validation_visitor(*factory.matchingRequirements()); - Envoy::Http::Matching::HttpFilterActionContext action_context{prefix, context, - context.serverFactoryContext()}; - Matcher::MatchTreeFactory matcher_factory(action_context, context.serverFactoryContext(), validation_visitor); @@ -336,9 +365,12 @@ FilterConfigPerRoute::createFilterMatchTree( requirements->mutable_data_input_allow_list()->add_type_url(TypeUtil::descriptorFullNameToTypeUrl( xds::type::matcher::v3::HttpAttributesCelMatchInput::default_instance().GetTypeName())); Envoy::Http::Matching::HttpFilterActionContext action_context{ - fmt::format("http.{}.", - server_context.scope().symbolTable().toString(server_context.scope().prefix())), - absl::nullopt, server_context}; + .is_downstream_ = true, + .stat_prefix_ = fmt::format("http.{}.", server_context.scope().symbolTable().toString( + server_context.scope().prefix())), + .factory_context_ = absl::nullopt, + .upstream_factory_context_ = absl::nullopt, + .server_factory_context_ = server_context}; Factory::MatchTreeValidationVisitor validation_visitor(*requirements); Matcher::MatchTreeFactory, }; class MatchDelegateConfig - : public Extensions::HttpFilters::Common::ExceptionFreeFactoryBase< + : public Extensions::HttpFilters::Common::CommonFactoryBase< envoy::extensions::common::matching::v3::ExtensionWithMatcher, - envoy::extensions::common::matching::v3::ExtensionWithMatcherPerRoute> { + envoy::extensions::common::matching::v3::ExtensionWithMatcherPerRoute>, + public Server::Configuration::NamedHttpFilterConfigFactory, + public Server::Configuration::UpstreamHttpFilterConfigFactory { public: - MatchDelegateConfig() : ExceptionFreeFactoryBase("envoy.filters.http.match_delegate") {} + MatchDelegateConfig() + : CommonFactoryBase( + "envoy.filters.http.match_delegate") {} + + absl::StatusOr + createFilterFactoryFromProto(const Protobuf::Message& proto_config, + const std::string& stats_prefix, + Server::Configuration::FactoryContext& context) override { + return createFilterFactoryFromProtoTyped( + MessageUtil::downcastAndValidate< + const envoy::extensions::common::matching::v3::ExtensionWithMatcher&>( + proto_config, context.messageValidationVisitor()), + stats_prefix, context); + } + + absl::StatusOr + createFilterFactoryFromProto(const Protobuf::Message& proto_config, + const std::string& stats_prefix, + Server::Configuration::UpstreamFactoryContext& context) override { + return createFilterFactoryFromProtoTyped( + MessageUtil::downcastAndValidate< + const envoy::extensions::common::matching::v3::ExtensionWithMatcher&&>( + proto_config, context.serverFactoryContext().messageValidationVisitor()), + stats_prefix, context); + } private: absl::StatusOr createFilterFactoryFromProtoTyped( const envoy::extensions::common::matching::v3::ExtensionWithMatcher& proto_config, - const std::string&, Server::Configuration::FactoryContext& context) override; + const std::string& prefix, Server::Configuration::FactoryContext& context); + absl::StatusOr createFilterFactoryFromProtoTyped( + const envoy::extensions::common::matching::v3::ExtensionWithMatcher& proto_config, + const std::string& prefix, Server::Configuration::UpstreamFactoryContext& context); + + template + absl::StatusOr createFilterFactory( + const envoy::extensions::common::matching::v3::ExtensionWithMatcher& proto_config, + const std::string& prefix, ProtobufMessage::ValidationVisitor& validation, + Envoy::Http::Matching::HttpFilterActionContext& action_context, FactoryCtx& context, + FilterCfgFactory& factory); Router::RouteSpecificFilterConfigConstSharedPtr createRouteSpecificFilterConfigTyped( const envoy::extensions::common::matching::v3::ExtensionWithMatcherPerRoute& proto_config, @@ -139,7 +176,10 @@ class FilterConfigPerRoute : public Router::RouteSpecificFilterConfig { Matcher::MatchTreeSharedPtr match_tree_; }; +using UpstreamMatchDelegateConfig = MatchDelegateConfig; + DECLARE_FACTORY(MatchDelegateConfig); +DECLARE_FACTORY(UpstreamMatchDelegateConfig); namespace Factory { DECLARE_FACTORY(SkipActionFactory); diff --git a/source/server/backtrace.cc b/source/server/backtrace.cc index f0249b9080cc..7a1254c1f8b6 100644 --- a/source/server/backtrace.cc +++ b/source/server/backtrace.cc @@ -1,6 +1,6 @@ #include "source/server/backtrace.h" -#include +#include #include "absl/strings/str_split.h" diff --git a/source/server/config_validation/cluster_manager.cc b/source/server/config_validation/cluster_manager.cc index cc1834be90a9..41cd09a7c95e 100644 --- a/source/server/config_validation/cluster_manager.cc +++ b/source/server/config_validation/cluster_manager.cc @@ -15,7 +15,6 @@ ClusterManagerPtr ValidationClusterManagerFactory::clusterManagerFromProto( context_.accessLogManager(), context_.mainThreadDispatcher(), context_.admin(), context_.messageValidationContext(), context_.api(), http_context_, context_.grpcContext(), context_.routerContext(), server_)}; - THROW_IF_NOT_OK(cluster_manager->init(bootstrap)); return cluster_manager; } diff --git a/source/server/configuration_impl.cc b/source/server/configuration_impl.cc index 7070baf2097d..883b47531507 100644 --- a/source/server/configuration_impl.cc +++ b/source/server/configuration_impl.cc @@ -128,7 +128,11 @@ absl::Status MainImpl::initialize(const envoy::config::bootstrap::v3::Bootstrap& } ENVOY_LOG(info, "loading {} cluster(s)", bootstrap.static_resources().clusters().size()); + + // clusterManagerFromProto() and init() have to be called consecutively. cluster_manager_ = cluster_manager_factory.clusterManagerFromProto(bootstrap); + status = cluster_manager_->initialize(bootstrap); + RETURN_IF_NOT_OK(status); const auto& listeners = bootstrap.static_resources().listeners(); ENVOY_LOG(info, "loading {} listener(s)", listeners.size()); diff --git a/source/server/overload_manager_impl.cc b/source/server/overload_manager_impl.cc index 4ebfd5b5cb15..f68b105f1d30 100644 --- a/source/server/overload_manager_impl.cc +++ b/source/server/overload_manager_impl.cc @@ -317,6 +317,7 @@ LoadShedPointImpl::LoadShedPointImpl(const envoy::config::overload::v3::LoadShed Random::RandomGenerator& random_generator) : scale_percent_(makeGauge(stats_scope, config.name(), "scale_percent", Stats::Gauge::ImportMode::NeverImport)), + shed_load_counter_(makeCounter(stats_scope, config.name(), "shed_load_count")), random_generator_(random_generator) { for (const auto& trigger_config : config.triggers()) { if (!triggers_.try_emplace(trigger_config.name(), createTriggerFromConfig(trigger_config)) @@ -354,10 +355,15 @@ bool LoadShedPointImpl::shouldShedLoad() { float unit_float_probability_shed_load = probability_shed_load_.load(); // This should be ok as we're using unit float which saturates at 1.0f. if (unit_float_probability_shed_load == 1.0f) { + shed_load_counter_.inc(); return true; } - return random_generator_.bernoulli(UnitFloat(unit_float_probability_shed_load)); + if (random_generator_.bernoulli(UnitFloat(unit_float_probability_shed_load))) { + shed_load_counter_.inc(); + return true; + } + return false; } OverloadManagerImpl::OverloadManagerImpl(Event::Dispatcher& dispatcher, Stats::Scope& stats_scope, diff --git a/source/server/overload_manager_impl.h b/source/server/overload_manager_impl.h index fb6e43b5d1d5..53771fc94563 100644 --- a/source/server/overload_manager_impl.h +++ b/source/server/overload_manager_impl.h @@ -90,6 +90,7 @@ class LoadShedPointImpl : public LoadShedPoint { absl::flat_hash_map triggers_; std::atomic probability_shed_load_{0}; Stats::Gauge& scale_percent_; + Stats::Counter& shed_load_counter_; Random::RandomGenerator& random_generator_; }; diff --git a/test/common/formatter/substitution_formatter_test.cc b/test/common/formatter/substitution_formatter_test.cc index ac8c5915ac5a..72d5b4a929ff 100644 --- a/test/common/formatter/substitution_formatter_test.cc +++ b/test/common/formatter/substitution_formatter_test.cc @@ -4391,9 +4391,9 @@ TEST(SubstitutionFormatParser, SyntaxVerifierFail) { }; for (const auto& test_case : test_cases) { - EXPECT_THROW(CommandSyntaxChecker::verifySyntax(std::get<0>(test_case), "TEST_TOKEN", - std::get<1>(test_case), std::get<2>(test_case)), - EnvoyException); + EXPECT_FALSE(CommandSyntaxChecker::verifySyntax(std::get<0>(test_case), "TEST_TOKEN", + std::get<1>(test_case), std::get<2>(test_case)) + .ok()); } } @@ -4422,8 +4422,9 @@ TEST(SubstitutionFormatParser, SyntaxVerifierPass) { absl::nullopt}}; for (const auto& test_case : test_cases) { - EXPECT_NO_THROW(CommandSyntaxChecker::verifySyntax( - std::get<0>(test_case), "TEST_TOKEN", std::get<1>(test_case), std::get<2>(test_case))); + EXPECT_TRUE(CommandSyntaxChecker::verifySyntax(std::get<0>(test_case), "TEST_TOKEN", + std::get<1>(test_case), std::get<2>(test_case)) + .ok()); } } } // namespace diff --git a/test/common/runtime/filesystem_setup.sh b/test/common/runtime/filesystem_setup.sh index 60c4f6fdd0b5..f58e686df532 100755 --- a/test/common/runtime/filesystem_setup.sh +++ b/test/common/runtime/filesystem_setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/test/common/tls/ocsp/test_data/certs.sh b/test/common/tls/ocsp/test_data/certs.sh index ea3b2c99b1ea..bc531ad2e94d 100755 --- a/test/common/tls/ocsp/test_data/certs.sh +++ b/test/common/tls/ocsp/test_data/certs.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Create test certificates and OCSP responses for them for unittests. diff --git a/test/common/tls/test_data/certs.sh b/test/common/tls/test_data/certs.sh index a63bbddacec9..3c78220a084f 100755 --- a/test/common/tls/test_data/certs.sh +++ b/test/common/tls/test_data/certs.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/test/common/upstream/cluster_manager_impl_test.cc b/test/common/upstream/cluster_manager_impl_test.cc index 17644f883a1c..a0090bcf27b4 100644 --- a/test/common/upstream/cluster_manager_impl_test.cc +++ b/test/common/upstream/cluster_manager_impl_test.cc @@ -279,7 +279,7 @@ class ClusterManagerImplTest : public testing::Test { factory_.runtime_, factory_.local_info_, log_manager_, factory_.dispatcher_, admin_, validation_context_, *factory_.api_, local_cluster_update_, local_hosts_removed_, http_context_, grpc_context_, router_context_, server_); - THROW_IF_NOT_OK(cluster_manager_->init(bootstrap)); + THROW_IF_NOT_OK(cluster_manager_->initialize(bootstrap)); } void createWithUpdateOverrideClusterManager(const Bootstrap& bootstrap) { @@ -288,7 +288,7 @@ class ClusterManagerImplTest : public testing::Test { factory_.runtime_, factory_.local_info_, log_manager_, factory_.dispatcher_, admin_, validation_context_, *factory_.api_, http_context_, grpc_context_, router_context_, server_); - THROW_IF_NOT_OK(cluster_manager_->init(bootstrap)); + THROW_IF_NOT_OK(cluster_manager_->initialize(bootstrap)); } void checkStats(uint64_t added, uint64_t modified, uint64_t removed, uint64_t active, diff --git a/test/common/upstream/test_cluster_manager.h b/test/common/upstream/test_cluster_manager.h index d05bfc493376..e9836c75dbb0 100644 --- a/test/common/upstream/test_cluster_manager.h +++ b/test/common/upstream/test_cluster_manager.h @@ -174,7 +174,7 @@ class TestClusterManagerImpl : public ClusterManagerImpl { new TestClusterManagerImpl(bootstrap, factory, context, stats, tls, runtime, local_info, log_manager, main_thread_dispatcher, admin, validation_context, api, http_context, grpc_context, router_context, server)}; - THROW_IF_NOT_OK(cluster_manager->init(bootstrap)); + THROW_IF_NOT_OK(cluster_manager->initialize(bootstrap)); return cluster_manager; } diff --git a/test/config/integration/certs/certs.sh b/test/config/integration/certs/certs.sh index 5611b126fada..9fa7534f0f4d 100755 --- a/test/config/integration/certs/certs.sh +++ b/test/config/integration/certs/certs.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/test/config_test/example_configs_test_setup.sh b/test/config_test/example_configs_test_setup.sh index b36b2c91e139..6a388dde641f 100755 --- a/test/config_test/example_configs_test_setup.sh +++ b/test/config_test/example_configs_test_setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/test/exe/build_id_test.sh b/test/exe/build_id_test.sh index 660eb24d3601..0dc2f1a1282b 100755 --- a/test/exe/build_id_test.sh +++ b/test/exe/build_id_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e -o pipefail diff --git a/test/exe/envoy_static_test.sh b/test/exe/envoy_static_test.sh index b2a60aa98e67..763c10b06a91 100755 --- a/test/exe/envoy_static_test.sh +++ b/test/exe/envoy_static_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ENVOY_BIN=${TEST_SRCDIR}/envoy/source/exe/envoy-static diff --git a/test/exe/pie_test.sh b/test/exe/pie_test.sh index 11fbfac09e56..82d3bbbf1fe0 100755 --- a/test/exe/pie_test.sh +++ b/test/exe/pie_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/test/exe/version_out_test.sh b/test/exe/version_out_test.sh index 1698912b57f6..3b17b9c8687a 100755 --- a/test/exe/version_out_test.sh +++ b/test/exe/version_out_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e -o pipefail diff --git a/test/extensions/filters/http/composite/BUILD b/test/extensions/filters/http/composite/BUILD index becf74159766..dc9662b95305 100644 --- a/test/extensions/filters/http/composite/BUILD +++ b/test/extensions/filters/http/composite/BUILD @@ -21,6 +21,7 @@ envoy_extension_cc_test( "//source/extensions/filters/http/composite:filter_lib", "//source/extensions/filters/http/fault:config", "//source/extensions/filters/http/fault:fault_filter_lib", + "//test/integration/filters:set_response_code_filter_lib", "//test/mocks/access_log:access_log_mocks", "//test/mocks/http:http_mocks", "//test/mocks/server:factory_context_mocks", diff --git a/test/extensions/filters/http/composite/composite_filter_integration_test.cc b/test/extensions/filters/http/composite/composite_filter_integration_test.cc index 2e72d31089a4..4bf95feed437 100644 --- a/test/extensions/filters/http/composite/composite_filter_integration_test.cc +++ b/test/extensions/filters/http/composite/composite_filter_integration_test.cc @@ -36,10 +36,17 @@ using test::integration::filters::SetResponseCodeFilterConfig; using test::integration::filters::SetResponseCodePerRouteFilterConfig; using xds::type::matcher::v3::Matcher_OnMatch; -class CompositeFilterIntegrationTest : public testing::TestWithParam, +struct CompositeFilterTestParams { + Network::Address::IpVersion version; + bool is_downstream; +}; + +class CompositeFilterIntegrationTest : public testing::TestWithParam, public HttpIntegrationTest { public: - CompositeFilterIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, GetParam()) {} + CompositeFilterIntegrationTest() + : HttpIntegrationTest(Http::CodecType::HTTP1, GetParam().version), + downstream_filter_(GetParam().is_downstream) {} ExtensionWithMatcherPerRoute createPerRouteConfig( std::function base_action_function) { @@ -136,7 +143,8 @@ class CompositeFilterIntegrationTest : public testing::TestWithParam getValuesForCompositeFilterTest() { + std::vector ret; + for (auto ip_version : TestEnvironment::getIpVersionsForTest()) { + CompositeFilterTestParams params; + params.version = ip_version; + params.is_downstream = true; + ret.push_back(params); + params.version = ip_version; + params.is_downstream = false; + ret.push_back(params); + } + return ret; + } + + static std::string CompositeFilterTestParamsToString( + const ::testing::TestParamInfo& params) { + return absl::StrCat( + (params.param.version == Network::Address::IpVersion::v4 ? "IPv4_" : "IPv6_"), + params.param.is_downstream ? "Downstream" : "Upstream"); + } + + bool downstream_filter_{true}; }; -INSTANTIATE_TEST_SUITE_P(IpVersions, CompositeFilterIntegrationTest, - testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), - TestUtility::ipTestParamsToString); +INSTANTIATE_TEST_SUITE_P( + IpVersions, CompositeFilterIntegrationTest, + testing::ValuesIn(CompositeFilterIntegrationTest::getValuesForCompositeFilterTest()), + CompositeFilterIntegrationTest::CompositeFilterTestParamsToString); // Verifies that if we don't match the match action the request is proxied as normal, while if the // match action is hit we apply the specified filter to the stream. TEST_P(CompositeFilterIntegrationTest, TestBasic) { prependCompositeFilter(); + if (!downstream_filter_) { + setUpstreamProtocol(Http::CodecType::HTTP2); + } initialize(); codec_client_ = makeHttpConnection(lookupPort("http")); @@ -276,6 +346,9 @@ TEST_P(CompositeFilterIntegrationTest, TestBasic) { // Verifies that if we don't match the match action the request is proxied as normal, while if the // match action is hit we apply the specified dynamic filter to the stream. TEST_P(CompositeFilterIntegrationTest, TestBasicDynamicFilter) { + if (!downstream_filter_) { + return; + } prependCompositeDynamicFilter("composite-dynamic"); initialize(); test_server_->waitForCounterGe( @@ -304,8 +377,10 @@ TEST_P(CompositeFilterIntegrationTest, TestBasicDynamicFilter) { // Verifies that if ECDS response is not sent, the missing filter config is applied that returns // 500. TEST_P(CompositeFilterIntegrationTest, TestMissingDynamicFilter) { + if (!downstream_filter_) { + return; + } prependMissingCompositeDynamicFilter("composite-dynamic-missing"); - initialize(); test_server_->waitForCounterGe( "extension_config_discovery.http_filter.missing-config.config_fail", 1); @@ -323,6 +398,9 @@ TEST_P(CompositeFilterIntegrationTest, TestPerRoute) { prependCompositeFilter(); addPerRouteResponseCodeFilter(/*filter_name=*/"composite", /*route_prefix=*/"/somepath", /*code=*/401); + if (!downstream_filter_) { + setUpstreamProtocol(Http::CodecType::HTTP2); + } initialize(); codec_client_ = makeHttpConnection(lookupPort("http")); @@ -339,6 +417,9 @@ TEST_P(CompositeFilterIntegrationTest, TestPerRouteResponseCodeConfig) { addResponseCodeFilterPerRouteConfig(/*filter_name=*/top_level_filter_name, /*route_prefix=*/"/somepath", /*code=*/406); + if (!downstream_filter_) { + setUpstreamProtocol(Http::CodecType::HTTP2); + } initialize(); codec_client_ = makeHttpConnection(lookupPort("http")); @@ -358,9 +439,13 @@ TEST_P(CompositeFilterIntegrationTest, TestPerRouteEmptyMatcher) { name: composite typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.composite.v3.Composite - )EOF"); + )EOF", + downstream_filter_); addPerRouteResponseCodeFilter(/*filter_name=*/"composite", /*route_prefix=*/"/somepath", /*code=*/402); + if (!downstream_filter_) { + setUpstreamProtocol(Http::CodecType::HTTP2); + } initialize(); codec_client_ = makeHttpConnection(lookupPort("http")); auto response = codec_client_->makeRequestWithBody(match_request_headers_, 1024); @@ -378,7 +463,8 @@ TEST_P(CompositeFilterIntegrationTest, TestPerRouteEmptyMatcherMultipleFilters) name: composite typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.composite.v3.Composite - )EOF"); + )EOF", + downstream_filter_); config_helper_.prependFilter(R"EOF( name: composite typed_config: @@ -387,12 +473,16 @@ TEST_P(CompositeFilterIntegrationTest, TestPerRouteEmptyMatcherMultipleFilters) name: composite typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.composite.v3.Composite - )EOF"); + )EOF", + downstream_filter_); addPerRouteResponseCodeFilter(/*filter_name=*/"composite", /*route_prefix=*/"/somepath", /*code=*/407, /*response_prefix=*/true); addPerRouteResponseCodeFilter(/*filter_name=*/"composite_2", /*route_prefix=*/"/somepath", /*code=*/402); + if (!downstream_filter_) { + setUpstreamProtocol(Http::CodecType::HTTP2); + } initialize(); codec_client_ = makeHttpConnection(lookupPort("http")); @@ -400,6 +490,24 @@ TEST_P(CompositeFilterIntegrationTest, TestPerRouteEmptyMatcherMultipleFilters) ASSERT_TRUE(response->waitForEndStream()); EXPECT_THAT(response->headers(), Http::HttpStatusIs("402")); } + +// Verifies the filter can be created with server factory context in downstream. +TEST_P(CompositeFilterIntegrationTest, TestCreateFilterWithServerFactoryContext) { + if (!downstream_filter_) { + return; + } + prependCompositeFilterServerFactoryContext(); + + initialize(); + codec_client_ = makeHttpConnection(lookupPort("http")); + + { + auto response = codec_client_->makeRequestWithBody(match_request_headers_, 1024); + ASSERT_TRUE(response->waitForEndStream()); + EXPECT_THAT(response->headers(), Http::HttpStatusIs("403")); + } +} + } // namespace class CompositeFilterSeverContextIntegrationTest : public HttpIntegrationTest, diff --git a/test/extensions/filters/http/composite/filter_test.cc b/test/extensions/filters/http/composite/filter_test.cc index 24ab95ac57d3..656a951fcfd5 100644 --- a/test/extensions/filters/http/composite/filter_test.cc +++ b/test/extensions/filters/http/composite/filter_test.cc @@ -318,20 +318,144 @@ TEST(ConfigTest, TestConfig) { path: "{{ test_tmpdir }}/set_response_code.yaml" type_urls: - type.googleapis.com/test.integration.filters.SetResponseCodeFilterConfig -)EOF"; + )EOF"; + + envoy::extensions::filters::http::composite::v3::ExecuteFilterAction config; + TestUtility::loadFromYaml(yaml_string, config); + + testing::NiceMock server_factory_context; + testing::NiceMock factory_context; + testing::NiceMock upstream_factory_context; + for (bool is_downstream : {false, true}) { + Envoy::Http::Matching::HttpFilterActionContext action_context{ + .is_downstream_ = is_downstream, + .stat_prefix_ = "test", + .factory_context_ = factory_context, + .upstream_factory_context_ = upstream_factory_context, + .server_factory_context_ = server_factory_context}; + ExecuteFilterActionFactory factory; + EXPECT_THROW_WITH_MESSAGE( + factory.createActionFactoryCb(config, action_context, + ProtobufMessage::getStrictValidationVisitor()), + EnvoyException, "Error: Only one of `dynamic_config` or `typed_config` can be set."); + } +} + +TEST(ConfigTest, TestDynamicConfigInUpstream) { + const std::string yaml_string = R"EOF( + dynamic_config: + name: set-response-code + config_discovery: + config_source: + resource_api_version: V3 + path_config_source: + path: "{{ test_tmpdir }}/set_response_code.yaml" + type_urls: + - type.googleapis.com/test.integration.filters.SetResponseCodeFilterConfig + )EOF"; envoy::extensions::filters::http::composite::v3::ExecuteFilterAction config; TestUtility::loadFromYaml(yaml_string, config); testing::NiceMock server_factory_context; testing::NiceMock factory_context; - Envoy::Http::Matching::HttpFilterActionContext action_context{"test", factory_context, - server_factory_context}; + testing::NiceMock upstream_factory_context; + Envoy::Http::Matching::HttpFilterActionContext action_context{ + .is_downstream_ = false, + .stat_prefix_ = "test", + .factory_context_ = factory_context, + .upstream_factory_context_ = upstream_factory_context, + .server_factory_context_ = server_factory_context}; + ExecuteFilterActionFactory factory; + EXPECT_THROW_WITH_MESSAGE( + factory.createActionFactoryCb(config, action_context, + ProtobufMessage::getStrictValidationVisitor()), + EnvoyException, + "When composite filter is in upstream, the composite action config must not be dynamic."); +} + +// Verify for dual filter in downstream without overriding +// createFilterFactoryFromProtoWithServerContext(), Envoy exception will be thrown if only +// server_factory_context is provided in action_context. +TEST(ConfigTest, TestDualFilterInDowntreamNoOverridingServerContext) { + const std::string yaml_string = R"EOF( + typed_config: + name: composite-action + typed_config: + "@type": type.googleapis.com/test.integration.filters.SetResponseCodeFilterConfigDual + code: 403 + )EOF"; + + envoy::extensions::filters::http::composite::v3::ExecuteFilterAction config; + TestUtility::loadFromYaml(yaml_string, config); + testing::NiceMock server_factory_context; + Envoy::Http::Matching::HttpFilterActionContext action_context{ + .is_downstream_ = true, + .stat_prefix_ = "test", + .factory_context_ = absl::nullopt, + .upstream_factory_context_ = absl::nullopt, + .server_factory_context_ = server_factory_context}; + ExecuteFilterActionFactory factory; + EXPECT_THROW_WITH_MESSAGE( + factory.createActionFactoryCb(config, action_context, + ProtobufMessage::getStrictValidationVisitor()), + EnvoyException, "Creating filter factory from server factory context is not supported"); +} + +// Verify for dual filter in upstream without overriding +// createFilterFactoryFromProtoWithServerContext(), Envoy exception will be thrown if only +// server_factory_context is provided in action_context. +TEST(ConfigTest, TestDualFilterInUpstreamNoOverridingServerContext) { + const std::string yaml_string = R"EOF( + typed_config: + name: composite-action + typed_config: + "@type": type.googleapis.com/test.integration.filters.SetResponseCodeFilterConfigDual + code: 403 + )EOF"; + + envoy::extensions::filters::http::composite::v3::ExecuteFilterAction config; + TestUtility::loadFromYaml(yaml_string, config); + testing::NiceMock server_factory_context; + Envoy::Http::Matching::HttpFilterActionContext action_context{ + .is_downstream_ = false, + .stat_prefix_ = "test", + .factory_context_ = absl::nullopt, + .upstream_factory_context_ = absl::nullopt, + .server_factory_context_ = server_factory_context}; + ExecuteFilterActionFactory factory; + EXPECT_THROW_WITH_MESSAGE( + factory.createActionFactoryCb(config, action_context, + ProtobufMessage::getStrictValidationVisitor()), + EnvoyException, "Failed to get filter factory creation function"); +} + +// Verify for downstream factories without overriding +// createFilterFactoryFromProtoWithServerContext(), Envoy exception will be thrown if only +// server_factory_context is provided in action_context. +TEST(ConfigTest, TestDownstreamFilterNoOverridingServerContext) { + const std::string yaml_string = R"EOF( + typed_config: + name: composite-action + typed_config: + "@type": type.googleapis.com/test.integration.filters.SetResponseCodeFilterConfigDownstream + code: 403 + )EOF"; + + envoy::extensions::filters::http::composite::v3::ExecuteFilterAction config; + TestUtility::loadFromYaml(yaml_string, config); + testing::NiceMock server_factory_context; + Envoy::Http::Matching::HttpFilterActionContext action_context{ + .is_downstream_ = true, + .stat_prefix_ = "test", + .factory_context_ = absl::nullopt, + .upstream_factory_context_ = absl::nullopt, + .server_factory_context_ = server_factory_context}; ExecuteFilterActionFactory factory; EXPECT_THROW_WITH_MESSAGE( factory.createActionFactoryCb(config, action_context, ProtobufMessage::getStrictValidationVisitor()), - EnvoyException, "Error: Only one of `dynamic_config` or `typed_config` can be set."); + EnvoyException, "Creating filter factory from server factory context is not supported"); } TEST_F(FilterTest, FilterStateShouldBeUpdatedWithTheMatchingActionForDynamicConfig) { @@ -349,10 +473,15 @@ TEST_F(FilterTest, FilterStateShouldBeUpdatedWithTheMatchingActionForDynamicConf testing::NiceMock server_factory_context; testing::NiceMock factory_context; + testing::NiceMock upstream_factory_context; envoy::extensions::filters::http::composite::v3::ExecuteFilterAction config; TestUtility::loadFromYaml(yaml_string, config); - Envoy::Http::Matching::HttpFilterActionContext action_context{"test", factory_context, - server_factory_context}; + Envoy::Http::Matching::HttpFilterActionContext action_context{ + .is_downstream_ = true, + .stat_prefix_ = "test", + .factory_context_ = factory_context, + .upstream_factory_context_ = upstream_factory_context, + .server_factory_context_ = server_factory_context}; ExecuteFilterActionFactory factory; auto action = factory.createActionFactoryCb(config, action_context, ProtobufMessage::getStrictValidationVisitor())(); @@ -375,10 +504,15 @@ TEST_F(FilterTest, FilterStateShouldBeUpdatedWithTheMatchingActionForTypedConfig testing::NiceMock server_factory_context; testing::NiceMock factory_context; + testing::NiceMock upstream_factory_context; envoy::extensions::filters::http::composite::v3::ExecuteFilterAction config; TestUtility::loadFromYaml(yaml_string, config); - Envoy::Http::Matching::HttpFilterActionContext action_context{"test", factory_context, - server_factory_context}; + Envoy::Http::Matching::HttpFilterActionContext action_context{ + .is_downstream_ = true, + .stat_prefix_ = "test", + .factory_context_ = factory_context, + .upstream_factory_context_ = upstream_factory_context, + .server_factory_context_ = server_factory_context}; ExecuteFilterActionFactory factory; auto action = factory.createActionFactoryCb(config, action_context, ProtobufMessage::getStrictValidationVisitor())(); diff --git a/test/extensions/filters/http/ext_proc/ext_proc_integration_test.cc b/test/extensions/filters/http/ext_proc/ext_proc_integration_test.cc index dce6ab4c3757..411b0352882e 100644 --- a/test/extensions/filters/http/ext_proc/ext_proc_integration_test.cc +++ b/test/extensions/filters/http/ext_proc/ext_proc_integration_test.cc @@ -832,6 +832,35 @@ TEST_P(ExtProcIntegrationTest, GetAndSetHeaders) { verifyDownstreamResponse(*response, 200); } +TEST_P(ExtProcIntegrationTest, ResponseFromExtProcServerTooLarge) { + if (std::get<1>(std::get<0>(GetParam())) != Envoy::Grpc::ClientType::EnvoyGrpc) { + GTEST_SKIP() << "max_receive_message_length is only supported on Envoy gRPC"; + } + config_helper_.setBufferLimits(1024, 1024); + proto_config_.mutable_processing_mode()->set_request_header_mode(ProcessingMode::SKIP); + proto_config_.mutable_processing_mode()->set_request_body_mode(ProcessingMode::STREAMED); + proto_config_.mutable_processing_mode()->set_response_header_mode(ProcessingMode::SKIP); + proto_config_.mutable_grpc_service() + ->mutable_envoy_grpc() + ->mutable_max_receive_message_length() + ->set_value(1024); + initializeConfig(); + HttpIntegrationTest::initialize(); + + std::string body_str = std::string(64 * 1024, 'a'); + auto response = sendDownstreamRequestWithBody("Replace this!", absl::nullopt); + processRequestBodyMessage( + *grpc_upstreams_[0], true, [&body_str](const HttpBody& body, BodyResponse& body_resp) { + EXPECT_TRUE(body.end_of_stream()); + // Send the over-limit response from ext_proc server. + auto* body_mut = body_resp.mutable_response()->mutable_body_mutation(); + body_mut->set_body(body_str); + return true; + }); + + verifyDownstreamResponse(*response, 500); +} + TEST_P(ExtProcIntegrationTest, SetHostHeaderRoutingSucceeded) { proto_config_.mutable_mutation_rules()->mutable_allow_all_routing()->set_value(true); initializeConfig(); diff --git a/test/extensions/filters/network/thrift_proxy/driver/generate_bindings.sh b/test/extensions/filters/network/thrift_proxy/driver/generate_bindings.sh index 04d23939005b..0ba2827b95f5 100755 --- a/test/extensions/filters/network/thrift_proxy/driver/generate_bindings.sh +++ b/test/extensions/filters/network/thrift_proxy/driver/generate_bindings.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Generates the thrift bindings for example.thrift. Requires that # apache-thrift's thrift generator is installed and on the path. diff --git a/test/extensions/filters/network/thrift_proxy/driver/generate_fixture.sh b/test/extensions/filters/network/thrift_proxy/driver/generate_fixture.sh index 26f995a88371..bdf2e2356908 100755 --- a/test/extensions/filters/network/thrift_proxy/driver/generate_fixture.sh +++ b/test/extensions/filters/network/thrift_proxy/driver/generate_fixture.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Generates request and response fixtures for integration tests. diff --git a/test/fuzz/fuzz_runner_launcher.sh b/test/fuzz/fuzz_runner_launcher.sh index 620ece68c151..f6c4b00c1c0c 100755 --- a/test/fuzz/fuzz_runner_launcher.sh +++ b/test/fuzz/fuzz_runner_launcher.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Launcher for the fuzz runner engine. # See https://github.com/bazelbuild/rules_fuzzing for more info. diff --git a/test/integration/admin_html/test_server_test.sh b/test/integration/admin_html/test_server_test.sh index 6e284a5bd025..05d1f05317ed 100755 --- a/test/integration/admin_html/test_server_test.sh +++ b/test/integration/admin_html/test_server_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash tmp="${TEST_TMPDIR}/test/integration/admin_html/tempfiles" export ENVOY_BIN="${TEST_SRCDIR}/envoy/test/integration/admin_html/test_server" diff --git a/test/integration/admin_html/web_test.sh b/test/integration/admin_html/web_test.sh index 943a69eef4c9..2c2d1a2589e1 100755 --- a/test/integration/admin_html/web_test.sh +++ b/test/integration/admin_html/web_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # This test is semi-automatic. It builds envoy-static with # ENVOY_ADMIN_BROWSER_TEST set, then runs the binary in a mode where diff --git a/test/integration/filters/set_response_code_filter.cc b/test/integration/filters/set_response_code_filter.cc index f5c26b3e6bb9..43d2fc08844f 100644 --- a/test/integration/filters/set_response_code_filter.cc +++ b/test/integration/filters/set_response_code_filter.cc @@ -77,23 +77,23 @@ class SetResponseCodeFilter : public Http::PassThroughFilter { }; class SetResponseCodeFilterFactory - : public Extensions::HttpFilters::Common::FactoryBase< + : public Extensions::HttpFilters::Common::DualFactoryBase< test::integration::filters::SetResponseCodeFilterConfig, test::integration::filters::SetResponseCodePerRouteFilterConfig> { public: - SetResponseCodeFilterFactory() : FactoryBase("set-response-code-filter") {} + SetResponseCodeFilterFactory() : DualFactoryBase("set-response-code-filter") {} private: - Http::FilterFactoryCb createFilterFactoryFromProtoTyped( + absl::StatusOr createFilterFactoryFromProtoTyped( const test::integration::filters::SetResponseCodeFilterConfig& proto_config, - const std::string&, Server::Configuration::FactoryContext& context) override { + const std::string&, DualInfo, Server::Configuration::ServerFactoryContext& context) override { auto filter_config = std::make_shared( - proto_config.prefix(), proto_config.code(), proto_config.body(), - context.serverFactoryContext()); + proto_config.prefix(), proto_config.code(), proto_config.body(), context); return [filter_config](Http::FilterChainFactoryCallbacks& callbacks) -> void { callbacks.addStreamFilter(std::make_shared(filter_config)); }; } + Http::FilterFactoryCb createFilterFactoryFromProtoWithServerContextTyped( const test::integration::filters::SetResponseCodeFilterConfig& proto_config, const std::string&, Server::Configuration::ServerFactoryContext& context) override { @@ -113,5 +113,95 @@ class SetResponseCodeFilterFactory } }; +using UpstreamSetResponseCodeFilterFactory = SetResponseCodeFilterFactory; REGISTER_FACTORY(SetResponseCodeFilterFactory, Server::Configuration::NamedHttpFilterConfigFactory); +REGISTER_FACTORY(UpstreamSetResponseCodeFilterFactory, + Server::Configuration::UpstreamHttpFilterConfigFactory); + +// Adding below factory to test downstream filter with method +// createFilterFactoryFromProtoWithServerContextTyped not overridden case. +class SetResponseCodeFilterFactoryDownstream + : public Extensions::HttpFilters::Common::FactoryBase< + test::integration::filters::SetResponseCodeFilterConfigDownstream, + test::integration::filters::SetResponseCodePerRouteFilterConfigDownstream> { +public: + SetResponseCodeFilterFactoryDownstream() : FactoryBase("set-response-code-filter-downstream") {} + +private: + Http::FilterFactoryCb createFilterFactoryFromProtoTyped( + const test::integration::filters::SetResponseCodeFilterConfigDownstream& proto_config, + const std::string&, Server::Configuration::FactoryContext& context) override { + auto filter_config = std::make_shared( + proto_config.prefix(), proto_config.code(), proto_config.body(), + context.serverFactoryContext()); + return [filter_config](Http::FilterChainFactoryCallbacks& callbacks) -> void { + callbacks.addStreamFilter(std::make_shared(filter_config)); + }; + } +}; + +REGISTER_FACTORY(SetResponseCodeFilterFactoryDownstream, + Server::Configuration::NamedHttpFilterConfigFactory); + +// Adding below factory to test dual filter with method +// createFilterFactoryFromProtoWithServerContextTyped not overridden case. +class SetResponseCodeFilterFactoryDual + : public Extensions::HttpFilters::Common::DualFactoryBase< + test::integration::filters::SetResponseCodeFilterConfigDual, + test::integration::filters::SetResponseCodePerRouteFilterConfigDual> { +public: + SetResponseCodeFilterFactoryDual() : DualFactoryBase("set-response-code-filter-dual") {} + +private: + absl::StatusOr createFilterFactoryFromProtoTyped( + const test::integration::filters::SetResponseCodeFilterConfigDual& proto_config, + const std::string&, DualInfo, Server::Configuration::ServerFactoryContext& context) override { + auto filter_config = std::make_shared( + proto_config.prefix(), proto_config.code(), proto_config.body(), context); + return [filter_config](Http::FilterChainFactoryCallbacks& callbacks) -> void { + callbacks.addStreamFilter(std::make_shared(filter_config)); + }; + } +}; + +using UpstreamSetResponseCodeFilterFactoryDual = SetResponseCodeFilterFactoryDual; +REGISTER_FACTORY(SetResponseCodeFilterFactoryDual, + Server::Configuration::NamedHttpFilterConfigFactory); +REGISTER_FACTORY(UpstreamSetResponseCodeFilterFactoryDual, + Server::Configuration::UpstreamHttpFilterConfigFactory); + +// Adding below dual filter factory to verify createFilterFactoryFromProtoWithServerContextTyped() +// method can be used to create filters in downstream. +class SetResponseCodeFilterFactoryServerContext + : public Extensions::HttpFilters::Common::DualFactoryBase< + test::integration::filters::SetResponseCodeFilterConfigServerContext, + test::integration::filters::SetResponseCodePerRouteFilterConfigServerContext> { +public: + SetResponseCodeFilterFactoryServerContext() + : DualFactoryBase("set-response-code-filter-server-context") {} + +private: + absl::StatusOr createFilterFactoryFromProtoTyped( + const test::integration::filters::SetResponseCodeFilterConfigServerContext&, + const std::string&, DualInfo, Server::Configuration::ServerFactoryContext&) override { + return nullptr; + } + + Http::FilterFactoryCb createFilterFactoryFromProtoWithServerContextTyped( + const test::integration::filters::SetResponseCodeFilterConfigServerContext& proto_config, + const std::string&, Server::Configuration::ServerFactoryContext& context) override { + auto filter_config = std::make_shared( + proto_config.prefix(), proto_config.code(), proto_config.body(), context); + return [filter_config](Http::FilterChainFactoryCallbacks& callbacks) -> void { + callbacks.addStreamFilter(std::make_shared(filter_config)); + }; + } +}; + +using UpstreamSetResponseCodeFilterFactoryServerContext = SetResponseCodeFilterFactoryServerContext; +REGISTER_FACTORY(SetResponseCodeFilterFactoryServerContext, + Server::Configuration::NamedHttpFilterConfigFactory); +REGISTER_FACTORY(UpstreamSetResponseCodeFilterFactoryServerContext, + Server::Configuration::UpstreamHttpFilterConfigFactory); + } // namespace Envoy diff --git a/test/integration/filters/set_response_code_filter_config.proto b/test/integration/filters/set_response_code_filter_config.proto index d9ca4298101f..4c27007d30fb 100644 --- a/test/integration/filters/set_response_code_filter_config.proto +++ b/test/integration/filters/set_response_code_filter_config.proto @@ -16,3 +16,39 @@ message SetResponseCodePerRouteFilterConfig { uint32 code = 2 [(validate.rules).uint32 = {lt: 600 gte: 200}]; string body = 3; } + +message SetResponseCodeFilterConfigDownstream { + string prefix = 1; + uint32 code = 2 [(validate.rules).uint32 = {lt: 600 gte: 200}]; + string body = 3; +} + +message SetResponseCodePerRouteFilterConfigDownstream { + string prefix = 1; + uint32 code = 2 [(validate.rules).uint32 = {lt: 600 gte: 200}]; + string body = 3; +} + +message SetResponseCodeFilterConfigDual { + string prefix = 1; + uint32 code = 2 [(validate.rules).uint32 = {lt: 600 gte: 200}]; + string body = 3; +} + +message SetResponseCodePerRouteFilterConfigDual { + string prefix = 1; + uint32 code = 2 [(validate.rules).uint32 = {lt: 600 gte: 200}]; + string body = 3; +} + +message SetResponseCodeFilterConfigServerContext { + string prefix = 1; + uint32 code = 2 [(validate.rules).uint32 = {lt: 600 gte: 200}]; + string body = 3; +} + +message SetResponseCodePerRouteFilterConfigServerContext { + string prefix = 1; + uint32 code = 2 [(validate.rules).uint32 = {lt: 600 gte: 200}]; + string body = 3; +} diff --git a/test/integration/hotrestart_test.sh b/test/integration/hotrestart_test.sh index 2725cd471096..035382a15b44 100755 --- a/test/integration/hotrestart_test.sh +++ b/test/integration/hotrestart_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # In order to get core dumps that can be debugged, uncomment the following line and then run # the test using --spawn_strategy=local. (There may be a better way of doing this but this worked diff --git a/test/integration/run_envoy_test.sh b/test/integration/run_envoy_test.sh index ae4825c6248f..8fb8658c04e5 100755 --- a/test/integration/run_envoy_test.sh +++ b/test/integration/run_envoy_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash export ENVOY_BIN="${TEST_SRCDIR}/envoy/test/integration/hotrestart_small_main" diff --git a/test/integration/sds_dynamic_key_rotation_setup.sh b/test/integration/sds_dynamic_key_rotation_setup.sh index a43e2bd82d2b..906f28bd4482 100755 --- a/test/integration/sds_dynamic_key_rotation_setup.sh +++ b/test/integration/sds_dynamic_key_rotation_setup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/test/integration/test_utility.sh b/test/integration/test_utility.sh index 592b61ad2e47..b67342a3e372 100644 --- a/test/integration/test_utility.sh +++ b/test/integration/test_utility.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Helper script for bash integration tests, intended to be source'd from the # _test.sh. diff --git a/test/mocks/upstream/cluster_manager.h b/test/mocks/upstream/cluster_manager.h index 1f67e8a85d09..ab2e04bbec6f 100644 --- a/test/mocks/upstream/cluster_manager.h +++ b/test/mocks/upstream/cluster_manager.h @@ -35,6 +35,8 @@ class MockClusterManager : public ClusterManager { void initializeThreadLocalClusters(const std::vector& cluster_names); // Upstream::ClusterManager + MOCK_METHOD(absl::Status, initialize, (const envoy::config::bootstrap::v3::Bootstrap& bootstrap)); + MOCK_METHOD(bool, initialized, ()); MOCK_METHOD(bool, addOrUpdateCluster, (const envoy::config::cluster::v3::Cluster& cluster, const std::string& version_info)); diff --git a/test/per_file_coverage.sh b/test/per_file_coverage.sh index 6368776d4fc1..7b386d7bfe12 100755 --- a/test/per_file_coverage.sh +++ b/test/per_file_coverage.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # directory:coverage_percent # for existing directories with low coverage. diff --git a/test/run_envoy_bazel_coverage.sh b/test/run_envoy_bazel_coverage.sh index feee13a07f11..8bcfd9c39acc 100755 --- a/test/run_envoy_bazel_coverage.sh +++ b/test/run_envoy_bazel_coverage.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e -o pipefail diff --git a/test/server/overload_manager_impl_test.cc b/test/server/overload_manager_impl_test.cc index 2ede9fd94c3b..3ff164d1898b 100644 --- a/test/server/overload_manager_impl_test.cc +++ b/test/server/overload_manager_impl_test.cc @@ -1002,6 +1002,50 @@ TEST_F(OverloadManagerLoadShedPointImplTest, PointUsesTriggerToDetermineWhetherT EXPECT_EQ(0, scale_percent.value()); } +TEST_F(OverloadManagerLoadShedPointImplTest, TriggerLoadShedCunterTest) { + setDispatcherExpectation(); + const std::string config = R"EOF( + resource_monitors: + - name: envoy.resource_monitors.fake_resource1 + loadshed_points: + - name: "test_point" + triggers: + - name: "envoy.resource_monitors.fake_resource1" + scaled: + scaling_threshold: 0.8 + saturation_threshold: 0.9 + )EOF"; + + auto manager{createOverloadManager(config)}; + manager->start(); + + LoadShedPoint* point = manager->getLoadShedPoint("test_point"); + ASSERT_NE(point, nullptr); + + Stats::Counter& shed_load_count = stats_.counter("overload.test_point.shed_load_count"); + + EXPECT_EQ(0, shed_load_count.value()); + EXPECT_FALSE(point->shouldShedLoad()); + + factory1_.monitor_->setPressure(0.65); + timer_cb_(); + EXPECT_EQ(0, shed_load_count.value()); + EXPECT_FALSE(point->shouldShedLoad()); + + factory1_.monitor_->setPressure(0.95); + timer_cb_(); + EXPECT_TRUE(point->shouldShedLoad()); + EXPECT_EQ(1, shed_load_count.value()); + + factory1_.monitor_->setPressure(0.85); + timer_cb_(); + if (point->shouldShedLoad()) { + EXPECT_EQ(2, shed_load_count.value()); + } else { + EXPECT_EQ(1, shed_load_count.value()); + } +} + TEST_F(OverloadManagerLoadShedPointImplTest, PointWithMultipleTriggers) { setDispatcherExpectation(); const std::string config = R"EOF( diff --git a/test/tools/router_check/test/route_tests.sh b/test/tools/router_check/test/route_tests.sh index 487285a752b4..c7eb2bee4019 100755 --- a/test/tools/router_check/test/route_tests.sh +++ b/test/tools/router_check/test/route_tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/tools/bazel-test-docker.sh b/tools/bazel-test-docker.sh index f51f508c672e..e6575a5fe81c 100755 --- a/tools/bazel-test-docker.sh +++ b/tools/bazel-test-docker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run a single Bazel test target under a privileged docker. Usage: # diff --git a/tools/check_repositories.sh b/tools/check_repositories.sh index 8930821652ca..af03d497e059 100755 --- a/tools/check_repositories.sh +++ b/tools/check_repositories.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eu diff --git a/tools/code/check_test.sh b/tools/code/check_test.sh index 55d920792061..b4d1284dfaac 100755 --- a/tools/code/check_test.sh +++ b/tools/code/check_test.sh @@ -1,5 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e if [[ -s "$1" ]]; then cat "$1" diff --git a/tools/code_format/check_format_test.sh b/tools/code_format/check_format_test.sh index 5958606dd77f..2d843c3c9214 100755 --- a/tools/code_format/check_format_test.sh +++ b/tools/code_format/check_format_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash tools="$(dirname "$(dirname "$(realpath "$0")")")" root=$(realpath "$tools/..") diff --git a/tools/code_format/check_format_test_helper.sh b/tools/code_format/check_format_test_helper.sh index d1f484d3a0cd..7868efbf99cd 100755 --- a/tools/code_format/check_format_test_helper.sh +++ b/tools/code_format/check_format_test_helper.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash tools="$(dirname "$(dirname "$(realpath "$0")")")" root=$(realpath "$tools/..") diff --git a/tools/code_format/config.yaml b/tools/code_format/config.yaml index 8e156ef94711..672b665f2e20 100644 --- a/tools/code_format/config.yaml +++ b/tools/code_format/config.yaml @@ -113,7 +113,6 @@ paths: - source/common/formatter/stream_info_formatter.h - source/common/formatter/stream_info_formatter.cc - source/common/formatter/substitution_formatter.h - - source/common/formatter/substitution_format_utility.cc - source/common/formatter/substitution_format_string.h - source/common/stats/tag_extractor_impl.cc - source/common/http/http2/codec_impl.cc diff --git a/tools/dependency/version.sh b/tools/dependency/version.sh index 2309c93d82f0..f2a6340c55a4 100755 --- a/tools/dependency/version.sh +++ b/tools/dependency/version.sh @@ -1,5 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e set -o pipefail JQ="$1" diff --git a/tools/docker_wrapper.sh b/tools/docker_wrapper.sh index 8b2f77fb0846..68d94c441c01 100755 --- a/tools/docker_wrapper.sh +++ b/tools/docker_wrapper.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Wraps a test invocation in docker. diff --git a/tools/git/last_github_commit.sh b/tools/git/last_github_commit.sh index 2ca2fb0fda29..f3577eb65135 100755 --- a/tools/git/last_github_commit.sh +++ b/tools/git/last_github_commit.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Looking back from HEAD, find the first commit that was merged onto main by GitHub. This is # likely the last non-local change on a given branch. There may be some exceptions for this diff --git a/tools/git/modified_since_last_github_commit.sh b/tools/git/modified_since_last_github_commit.sh index bdfc2dd35449..5e8c76179b51 100755 --- a/tools/git/modified_since_last_github_commit.sh +++ b/tools/git/modified_since_last_github_commit.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash BASE="$(dirname "$0")" declare -r BASE diff --git a/tools/gsutil/vendor_util.sh b/tools/gsutil/vendor_util.sh index 6f709291ac0e..ceded21a483d 100755 --- a/tools/gsutil/vendor_util.sh +++ b/tools/gsutil/vendor_util.sh @@ -1,5 +1,6 @@ -#!/bin/bash -eu +#!/usr/bin/env bash +set -eu set -o pipefail # REQUIRES DOCKER! diff --git a/tools/local_fix_format.sh b/tools/local_fix_format.sh index 832d80ae8b0d..39dfa4d1933c 100755 --- a/tools/local_fix_format.sh +++ b/tools/local_fix_format.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Runs the Envoy format fixers on the current changes. By default, this runs on # changes that are not yet committed. You can also specify: diff --git a/tools/path_fix.sh b/tools/path_fix.sh index 122948708717..b6e019e3020d 100755 --- a/tools/path_fix.sh +++ b/tools/path_fix.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script can be used to run bazel commands. It will attempt to translate paths in compiler # error messages to real system paths (vs. bazel symbolic links) which may be necessary for some # IDEs to properly associate error messages to files. diff --git a/tools/proto_format/proto_format.sh b/tools/proto_format/proto_format.sh index b60286ff98e2..57ac3f721b77 100755 --- a/tools/proto_format/proto_format.sh +++ b/tools/proto_format/proto_format.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Reformat API protos to canonical proto style using protoxform. diff --git a/tools/sha/replace.sh b/tools/sha/replace.sh index 12bb78918dc0..ab830ae37bf8 100755 --- a/tools/sha/replace.sh +++ b/tools/sha/replace.sh @@ -1,5 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e set -o pipefail # This tool is for replacing shas in the repo, altho it could be diff --git a/tools/spelling/check_spelling_pedantic_test.sh b/tools/spelling/check_spelling_pedantic_test.sh index 900784ed999c..36d8cba965ad 100755 --- a/tools/spelling/check_spelling_pedantic_test.sh +++ b/tools/spelling/check_spelling_pedantic_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash tools=$(dirname "$(dirname "$(realpath "$0")")") root=$(realpath "$tools/..") diff --git a/tools/update_crates.sh b/tools/update_crates.sh index a56cd3c4c2f1..cd4d6fc2d91d 100755 --- a/tools/update_crates.sh +++ b/tools/update_crates.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e