Skip to content

Commit

Permalink
Merge pull request #2 from envoyproxy/main
Browse files Browse the repository at this point in the history
sync to latest
  • Loading branch information
dubious90 authored Feb 16, 2021
2 parents 2ab3284 + c89cf75 commit e01ff2b
Show file tree
Hide file tree
Showing 31 changed files with 1,082 additions and 52 deletions.
52 changes: 38 additions & 14 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# The following .bazelrc content is forked from the main Envoy repository. This is necessary since
# this needs to be available before we can access the Envoy repository contents via Bazel.

build:clang-asan --test_timeout=900
build:clang-tsan --test_timeout=900
# See https://github.com/envoyproxy/nighthawk/issues/405
build:macos --copt -UDEBUG

# The following .bazelrc content is forked from the main Envoy repository. # unique
# This is necessary since this needs to be available before we can access # unique
# the Envoy repository contents via Bazel. # unique
# unique
build:clang-asan --test_timeout=900 # unique
build:clang-tsan --test_timeout=900 # unique
# See https://github.com/envoyproxy/nighthawk/issues/405 # unique
build:macos --copt -UDEBUG # unique
# unique
# Envoy specific Bazel build/test options.

# Bazel doesn't need more than 200MB of memory for local build based on memory profiling:
Expand Down Expand Up @@ -60,10 +61,10 @@ build:asan --config=sanitizer
# ASAN install its signal handler, disable ours so the stacktrace will be printed by ASAN
build:asan --define signal_trace=disabled
build:asan --define ENVOY_CONFIG_ASAN=1
# The following two lines were manually edited due to #593.
# Flag undefined was dropped from both the lines to allow CI/ASAN to pass.
build:asan --copt -fsanitize=address
build:asan --linkopt -fsanitize=address
# The following two lines were manually edited due to #593. # unique
# Flag undefined was dropped from both the lines to allow CI/ASAN to pass. # unique
build:asan --copt -fsanitize=address # unique
build:asan --linkopt -fsanitize=address # unique
# vptr and function sanitizer are enabled in clang-asan if it is set up via bazel/setup_clang.sh.
build:asan --copt -fno-sanitize=vptr,function
build:asan --linkopt -fno-sanitize=vptr,function
Expand Down Expand Up @@ -287,19 +288,42 @@ build:remote-ci --remote_cache=grpcs://remotebuildexecution.googleapis.com
build:remote-ci --remote_executor=grpcs://remotebuildexecution.googleapis.com

# Fuzz builds

# Shared fuzzing configuration.
build:fuzzing --define=ENVOY_CONFIG_ASAN=1
build:fuzzing --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
build:fuzzing --config=libc++

# Fuzzing without ASAN. This is useful for profiling fuzzers without any ASAN artifacts.
build:plain-fuzzer --config=fuzzing
build:plain-fuzzer --define=FUZZING_ENGINE=libfuzzer
build:plain-fuzzer --define ENVOY_CONFIG_ASAN=1
# The fuzzing rules provide their own instrumentation, but it is currently
# disabled due to bazelbuild/bazel#12888. Instead, we provide instrumentation at
# the top level through these options.
build:plain-fuzzer --copt=-fsanitize=fuzzer-no-link
build:plain-fuzzer --linkopt=-fsanitize=fuzzer-no-link
build:plain-fuzzer --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION

build:asan-fuzzer --config=plain-fuzzer
build:asan-fuzzer --config=asan
build:asan-fuzzer --copt=-fno-omit-frame-pointer
# Remove UBSAN halt_on_error to avoid crashing on protobuf errors.
build:asan-fuzzer --test_env=UBSAN_OPTIONS=print_stacktrace=1

build:oss-fuzz --config=fuzzing
build:oss-fuzz --define=FUZZING_ENGINE=oss-fuzz
build:oss-fuzz --@rules_fuzzing//fuzzing:cc_engine_instrumentation=oss-fuzz
build:oss-fuzz --@rules_fuzzing//fuzzing:cc_engine_sanitizer=none
build:oss-fuzz --dynamic_mode=off
build:oss-fuzz --strip=never
build:oss-fuzz --copt=-fno-sanitize=vptr
build:oss-fuzz --linkopt=-fno-sanitize=vptr
build:oss-fuzz --define=tcmalloc=disabled
build:oss-fuzz --define=signal_trace=disabled
build:oss-fuzz --copt=-D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
build:oss-fuzz --define=force_libcpp=enabled
build:oss-fuzz --linkopt=-lc++
build:oss-fuzz --linkopt=-pthread

# Compile database generation config
build:compdb --build_tag_filters=-nocompdb

Expand Down
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ jobs:
resource_class: xlarge
steps:
- checkout
- run: ci/do_ci.sh test_gcc
- run:
command: ci/do_ci.sh test_gcc
no_output_timeout: 30m
coverage:
docker:
- image: *envoy-build-image
Expand Down
9 changes: 9 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ envoy_package()
filegroup(
name = "nighthawk",
srcs = [
":nighthawk_adaptive_load_client",
":nighthawk_client",
":nighthawk_output_transform",
":nighthawk_service",
":nighthawk_test_server",
],
)

envoy_cc_binary(
name = "nighthawk_adaptive_load_client",
repository = "@envoy",
deps = [
"//source/exe:adaptive_load_client_entry_lib",
],
)

envoy_cc_binary(
name = "nighthawk_client",
repository = "@envoy",
Expand Down
80 changes: 62 additions & 18 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,75 @@ This document aims to assist [maintainers](OWNERS.md).

## Envoy domain expertise

As a guideline, concepts in Nighthawk that are derived from Envoy
require someone with Envoy domain expertise in review. Notable examples
are the way Nighthawk internally computes cluster configuration, its
connection pool derivations, the `StreamDecoder` class, as well as anything related to the Nighthawk test server.
As a guideline, concepts in Nighthawk that are derived from Envoy require
someone with Envoy domain expertise in review. Notable examples are the way
Nighthawk internally computes cluster configuration, its connection pool
derivations, the `StreamDecoder` class, as well as anything related to the
Nighthawk test server.

See [OWNERS.md](OWNERS.md) to find maintainers with expertise of
Envoy internals.
See [OWNERS.md](OWNERS.md) to find maintainers with expertise of Envoy
internals.

## Pre-merge checklist

- Does the PR have breaking changes? Then that should be explicitly mentioned in the [version history](docs/root/version_history.md).
- New features should be added to the [version history](docs/root/version_history.md).
- Does the PR have breaking changes? Then that should be explicitly mentioned in
the [version history](docs/root/version_history.md).
- New features should be added to the
[version history](docs/root/version_history.md).
- Breaking changes to the [protobuf APIs](api/) are not allowed.
- When merging, clean up the commit message so we get a nice history. By default,
github will compile a message from all the commits that are squashed.
The PR title and description should be a good starting point for the final commit message.
(If it is not, it may be worth asking the PR author to update the description).
- When merging, clean up the commit message so we get a nice history. By
default, github will compile a message from all the commits that are squashed.
The PR title and description should be a good starting point for the final
commit message. (If it is not, it may be worth asking the PR author to update
the description).
- Make sure that the DCO signoff is included in the final commit message.
- As a convention, it is appropriate to exclude content in the PR description that occurs after the signoff.
- As a convention, it is appropriate to exclude content in the PR description
that occurs after the signoff.

## Updates to the Envoy dependency

We try to [regularly synchronize our Envoy dependency](https://github.com/envoyproxy/nighthawk/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aclosed+%22update+envoy%22+) with the latest revision. Nighthawk reuses large parts of Envoy's build system and CI infrastructure. When we update, that looks like:
We aim to
[synchronize our Envoy dependency](https://github.com/envoyproxy/nighthawk/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aclosed+%22update+envoy%22+)
with the latest revision weekly. Nighthawk reuses large parts of Envoy's build
system and codebase, so keeping Nighthawk up to date with Envoy's changes is an
important maintenance task. When performing the update, follow this procedure:

- A change to [repositories.bzl](bazel/repositories.bzl) to update the commit and SHA.
- A sync of [.bazelrc](.bazelrc) with [Envoy's version](https://github.com/envoyproxy/envoy/blob/main/.bazelrc) to update our build configurations.
- A sync of the build image sha used in the [ci configuration](.circleci/config.yml) with [Envoy's version](https://github.com/envoyproxy/envoy/blob/main/.circleci/config.yml) to sync our CI testing environment.
- Sometimes the dependency update comes with changes that break our build. We include any changes required to Nighthawk to fix that.
1. Create a fork of Nighthawk, or fetch upstream and merge changes into your
fork if you already have one.
1. Create a new branch from `main`, e.g. `envoy-update`.
1. Edit [bazel/repositories.bzl](bazel/repositories.bzl).
1. Update `ENVOY_COMMIT` to the latest Envoy's commit from
[this page](https://github.com/envoyproxy/envoy/commits/main). (Clicking on the
short commit id opens a page that contains the fully expanded commit id).
1. Set `ENVOY_SHA` to an empty string initially, we will get the correct
sha256 after the first bazel execution.
Example content of `bazel/repositories.bzl` after the edits:
```
ENVOY_COMMIT = "9753819331d1547c4b8294546a6461a3777958f5"  # Jan 24th, 2021
ENVOY_SHA = ""
```
1. Run `ci/do_ci.sh build`, notice the sha256 value at the top of the output,
example:
```
INFO: SHA256 (https://github.com/envoyproxy/envoy/archive/9753819331d1547c4b8294546a6461a3777958f5.tar.gz) = f4d26c7e78c0a478d959ea8bc877f260d4658a8b44e294e3a400f20ad44d41a3
```
1. Update `ENVOY_SHA` in [bazel/repositories.bzl](bazel/repositories.bzl) to
this value.
1. Sync (copy) [.bazelrc](.bazelrc) from
[Envoy's version](https://github.com/envoyproxy/envoy/blob/main/.bazelrc) to
update our build configurations. Be sure to retain our local modifications,
all lines that are unique to Nighthawk are marked with comment `# unique`.
1. Sync (copy) [.bazelversion](.bazelversion) from
[Envoy's version](https://github.com/envoyproxy/envoy/blob/main/.bazelversion)
to ensure we are using the same build system version.
1. Run `ci/do_ci.sh test`. Sometimes the dependency update comes with changes
that break our build. Include any changes required to Nighthawk to fix that
in the same PR.
1. Create a PR with a title like `Update Envoy to 9753819 (Jan 24th 2021)`,
describe all performed changes in the PR's descriotion.
1. If the PR ends up modifying any c++ files, execute `ci/do_ci.sh fix_format`
to reformat the files and avoid a CI failure.
1. If the PR ends up modifying any CLI arguments, execute
`tools/update_cli_readme_documentation.sh --mode fix` to regenerate the
portion of our documentation that captures the CLI help output. This will
prevent a CI failure.
2 changes: 1 addition & 1 deletion api/adaptive_load/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ api_cc_py_proto_library(
],
visibility = ["//visibility:public"],
deps = [
"//api/client:base",
"@envoy_api//envoy/config/core/v3:pkg",
"@nighthawk//api/client:base",
],
)
4 changes: 2 additions & 2 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

ENVOY_COMMIT = "f6679d51cc7b2f0b5e05c883a035ad87d011f454" # Feb 1st, 2021
ENVOY_SHA = "77a765b6f1063925ac53d09335dd23b546b4254a392755bddf5d81b4d299cd5f"
ENVOY_COMMIT = "cfe0391ce24f7d11b3b125078ab77f6f4142e4ac" # Feb 5th, 2021
ENVOY_SHA = "5c9fbd5b95837ef409d85b6408bbb616452c164be5016c62e1c5055d3eeee268"

HDR_HISTOGRAM_C_VERSION = "0.11.2" # October 12th, 2020
HDR_HISTOGRAM_C_SHA = "637f28b5f64de2e268131e4e34e6eef0b91cf5ff99167db447d9b2825eae6bad"
Expand Down
2 changes: 1 addition & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function do_clang_tidy() {

function do_unit_test_coverage() {
export TEST_TARGETS="//test/... -//test:python_test"
export COVERAGE_THRESHOLD=94.0
export COVERAGE_THRESHOLD=94.3
echo "bazel coverage build with tests ${TEST_TARGETS}"
test/run_nighthawk_bazel_coverage.sh ${TEST_TARGETS}
exit 0
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/Dockerfile-nighthawk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM frolvlad/alpine-glibc
FROM frolvlad/alpine-glibc:alpine-3.13_glibc-2.32

ADD nighthawk_client /usr/local/bin/nighthawk_client
ADD nighthawk_test_server /usr/local/bin/nighthawk_test_server
Expand Down
4 changes: 2 additions & 2 deletions ci/docker/Dockerfile-nighthawk-benchmark
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM frolvlad/alpine-glibc
FROM frolvlad/alpine-glibc:alpine-3.13_glibc-2.32

CMD ["./benchmarks" "--help"]
ENV RUNFILES_DIR=/usr/local/bin/benchmarks/benchmarks.runfiles
Expand All @@ -8,7 +8,7 @@ WORKDIR /usr/local/bin/benchmarks

COPY benchmarks /usr/local/bin/benchmarks/

RUN apk add --no-cache docker=20.10.2-r0 openrc=0.42.1-r19 python3>=3.8.5
RUN apk add --no-cache docker=20.10.3-r0 openrc=0.42.1-r19 python3=3.8.7-r0
RUN rc-update add docker boot

RUN if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python; fi && \
Expand Down
1 change: 1 addition & 0 deletions include/nighthawk/common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ envoy_basic_cc_library(
"@envoy//include/envoy/upstream:cluster_manager_interface_with_external_headers",
"@envoy//source/common/common:minimal_logger_lib",
"@envoy//source/common/common:non_copyable_with_external_headers",
"@envoy//source/common/common:statusor_lib_with_external_headers",
"@envoy//source/common/event:dispatcher_lib_with_external_headers",
"@envoy//source/common/network:utility_lib_with_external_headers",
],
Expand Down
18 changes: 18 additions & 0 deletions include/nighthawk/common/statistic.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "api/client/output.pb.h"

#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"

namespace Nighthawk {
Expand Down Expand Up @@ -115,6 +116,23 @@ class Statistic : Envoy::NonCopyable {
* @param id The id that should be set for the Statistic instance.
*/
virtual void setId(absl::string_view id) PURE;

/**
* Build a string representation of this Statistic instance.
*
* @return absl::StatusOr<std::unique_ptr<std::istream>> Status or a stream that will yield
* a serialized representation of this Statistic instance.
*/
virtual absl::StatusOr<std::unique_ptr<std::istream>> serializeNative() const PURE;

/**
* Reconstruct this Statistic instance using the serialization delivered by the input stream.
*
* @param input_stream Stream that will deliver a serialized representation.
* @return absl::Status Status indicating success or failure. Upon success the statistic
* instance this was called for will now represent what the stream contained.
*/
virtual absl::Status deserializeNative(std::istream& input_stream) PURE;
};

} // namespace Nighthawk
29 changes: 29 additions & 0 deletions source/adaptive_load/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,35 @@ envoy_cc_library(
],
)

envoy_cc_library(
name = "adaptive_load_client_main",
srcs = [
"adaptive_load_client_main.cc",
],
hdrs = [
"adaptive_load_client_main.h",
],
repository = "@envoy",
visibility = ["//visibility:public"],
deps = [
":adaptive_load_controller_impl",
":config_validator_impl",
":input_variable_setter_impl",
":metrics_evaluator_impl",
":metrics_plugin_impl",
":scoring_function_impl",
":session_spec_proto_helper_impl",
":step_controller_impl",
"//api/client:base_cc_proto",
"//api/client:grpc_service_lib",
"//source/common:nighthawk_common_lib",
"@envoy//source/common/common:assert_lib_with_external_headers",
"@envoy//source/common/common:minimal_logger_lib_with_external_headers",
"@envoy//source/common/event:real_time_system_lib_with_external_headers",
"@envoy//source/common/grpc:google_grpc_utils_lib_with_external_headers",
],
)

envoy_cc_library(
name = "config_validator_impl",
srcs = [
Expand Down
Loading

0 comments on commit e01ff2b

Please sign in to comment.