Skip to content

Commit 519add8

Browse files
yuval-ksoloio-bulldozer[bot]
authored andcommitted
update version of upstream envoy (#13)
* update version of upstream envoy * udpate build container * add envoy_api_dependencies * update do_ci with upstream envoy changes * udpate coverage build * envoy_gloo_cc_test for visibility * c_str -> getStringView * compile fix * sendlocalreply * fix test * use TestUtility::loadFromYaml * compile fix * compile fix * compile fix * compiler fix * fix query string
1 parent 9c4a5ed commit 519add8

File tree

29 files changed

+257
-128
lines changed

29 files changed

+257
-128
lines changed

WORKSPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ load("//bazel:repositories.bzl", "envoy_gloo_dependencies")
44

55
envoy_gloo_dependencies()
66

7+
load("@envoy//bazel:api_repositories.bzl", "envoy_api_dependencies")
8+
envoy_api_dependencies()
9+
710
load("@envoy//bazel:repositories.bzl", "GO_VERSION", "envoy_dependencies")
811
load("@envoy//bazel:cc_configure.bzl", "cc_configure")
912

bazel/envoy_test.bzl

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
# Copied from @envoy/bazel/envoy_test.bzl and uses public visibility for tests
3+
# So we can target them to use our coverage.
4+
5+
load(
6+
"@envoy//bazel:envoy_build_system.bzl",
7+
"envoy_cc_test_library",
8+
)
9+
10+
load(
11+
"@envoy//bazel:envoy_internal.bzl",
12+
"envoy_copts",
13+
"envoy_select_force_libcpp",
14+
"envoy_linkstatic",
15+
"tcmalloc_external_dep",
16+
)
17+
18+
# Compute the test linkopts based on various options.
19+
def _envoy_test_linkopts():
20+
return select({
21+
"@envoy//bazel:apple": [
22+
# See note here: https://luajit.org/install.html
23+
"-pagezero_size 10000",
24+
"-image_base 100000000",
25+
],
26+
"@envoy//bazel:windows_x86_64": [
27+
"-DEFAULTLIB:advapi32.lib",
28+
"-DEFAULTLIB:ws2_32.lib",
29+
"-WX",
30+
],
31+
32+
# TODO(mattklein123): It's not great that we universally link against the following libs.
33+
# In particular, -latomic and -lrt are not needed on all platforms. Make this more granular.
34+
"//conditions:default": ["-pthread", "-lrt", "-ldl"],
35+
}) + envoy_select_force_libcpp(["-lc++fs"], ["-lstdc++fs", "-latomic"])
36+
37+
# Envoy C++ test targets should be specified with this function.
38+
def envoy_gloo_cc_test(
39+
name,
40+
srcs = [],
41+
data = [],
42+
# List of pairs (Bazel shell script target, shell script args)
43+
repository = "",
44+
external_deps = [],
45+
deps = [],
46+
tags = [],
47+
args = [],
48+
copts = [],
49+
shard_count = None,
50+
coverage = True,
51+
local = False,
52+
size = "medium"):
53+
test_lib_tags = []
54+
if coverage:
55+
test_lib_tags.append("coverage_test_lib")
56+
envoy_cc_test_library(
57+
name = name + "_lib_internal_only",
58+
srcs = srcs,
59+
data = data,
60+
external_deps = external_deps,
61+
deps = deps,
62+
repository = repository,
63+
tags = test_lib_tags,
64+
copts = copts,
65+
)
66+
native.cc_test(
67+
name = name,
68+
copts = envoy_copts(repository, test = True) + copts,
69+
linkopts = _envoy_test_linkopts(),
70+
linkstatic = envoy_linkstatic(),
71+
malloc = tcmalloc_external_dep(repository),
72+
deps = [
73+
":" + name + "_lib_internal_only",
74+
repository + "//test:main",
75+
],
76+
# from https://github.com/google/googletest/blob/6e1970e2376c14bf658eb88f655a054030353f9f/googlemock/src/gmock.cc#L51
77+
# 2 - by default, mocks act as StrictMocks.
78+
args = args + ["--gmock_default_mock_behavior=2"],
79+
tags = tags + ["coverage_test"],
80+
local = local,
81+
shard_count = shard_count,
82+
size = size,
83+
)

bazel/repository_locations.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
REPOSITORY_LOCATIONS = dict(
22
envoy = dict(
3-
commit = "7ed6d2187df94c4cb96f7dccb8643bf764af2ccb",
3+
commit = "8d1ad35aa724962f64f7535531e408c9a93d364c",
44
remote = "https://github.com/envoyproxy/envoy",
55
),
66
inja = dict(

ci/do_ci.sh

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ function setup_gcc_toolchain() {
4848
}
4949

5050
function setup_clang_toolchain() {
51-
export PATH=/usr/lib/llvm-7/bin:$PATH
51+
export PATH=/usr/lib/llvm-8/bin:$PATH
5252
export CC=clang
5353
export CXX=clang++
54-
export ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-7/bin/llvm-symbolizer
54+
export ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-8/bin/llvm-symbolizer
5555
echo "$CC/$CXX toolchain configured"
5656
}
5757

@@ -65,20 +65,6 @@ function cleanup() {
6565
cleanup
6666
trap cleanup EXIT
6767

68-
69-
# link prebuilt stuff
70-
71-
ln -sf /thirdparty "${ENVOY_CIDIR}"/prebuilt
72-
ln -sf /thirdparty_build "${ENVOY_CIDIR}"/prebuilt
73-
74-
# Replace the existing Bazel output cache with a copy of the image's prebuilt deps.
75-
if [[ -d /bazel-prebuilt-output && ! -d "${TEST_TMPDIR}/_bazel_${USER}" ]]; then
76-
BAZEL_OUTPUT_BASE="$(bazel info output_base)"
77-
mkdir -p "${TEST_TMPDIR}/_bazel_${USER}/install"
78-
rsync -a /bazel-prebuilt-root/install/* "${TEST_TMPDIR}/_bazel_${USER}/install/"
79-
rsync -a /bazel-prebuilt-output "${BAZEL_OUTPUT_BASE}"
80-
fi
81-
8268
set -e
8369

8470
# try compiling with clang as google cloud doesn't seem to like gcc.

cloudbuild.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
steps:
2-
- name: 'envoyproxy/envoy-build:698009170e362f9ca0594f2b1927fbbee199bf98'
2+
- name: 'envoyproxy/envoy-build:cfc514546bc0284536893cca5fa43d7128edcd35'
33
args: ['ci/do_ci.sh', 'test']
44
volumes:
55
- name: 'vol-build'
@@ -8,7 +8,7 @@ steps:
88
- 'COMMIT_SHA=$COMMIT_SHA'
99
timeout: 900s
1010

11-
- name: 'envoyproxy/envoy-build:698009170e362f9ca0594f2b1927fbbee199bf98'
11+
- name: 'envoyproxy/envoy-build:cfc514546bc0284536893cca5fa43d7128edcd35'
1212
args: ['ci/do_ci.sh', 'build']
1313
volumes:
1414
- name: 'vol-build'

source/extensions/filters/http/aws_lambda/aws_authenticator.cc

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ AwsAuthenticator::prepareHeaders(const HeaderList &headers_to_sign) {
9191

9292
canonical_headers_stream << ':';
9393
if (headerEntry != nullptr) {
94-
canonical_headers_stream << headerEntry->value().c_str();
94+
canonical_headers_stream << headerEntry->value().getStringView();
9595
// TODO: add warning if null
9696
}
9797
canonical_headers_stream << '\n';
@@ -119,25 +119,13 @@ std::string AwsAuthenticator::getBodyHexSha() {
119119

120120
void AwsAuthenticator::fetchUrl() {
121121
const Http::HeaderString &canonical_url = request_headers_->Path()->value();
122-
url_len_ = canonical_url.size();
123-
url_start_ = canonical_url.c_str();
124-
const char *query_string_start =
122+
url_base_ = canonical_url.getStringView();
123+
query_string_ =
125124
Http::Utility::findQueryStringStart(canonical_url);
126-
// bug in: findQueryStringStart - query_string_start will never be null as
127-
// implied in config_impl.cc, but rather it is the end iterator of the string.
128-
if (query_string_start != nullptr) {
129-
url_len_ = query_string_start - url_start_;
130-
if (url_len_ < canonical_url.size()) {
131-
// we now know that query_string_start != std::end
132-
133-
// +1 to skip the question mark
134-
// These should be sorted alphabetically, but I will leave that to the
135-
// caller (which is internal, hence it's ok)
136-
query_string_len_ = canonical_url.size() - url_len_ - 1;
137-
query_string_start_ = query_string_start + 1;
138-
} else {
139-
query_string_start = nullptr;
140-
}
125+
if (query_string_.length() != 0) {
126+
url_base_.remove_suffix(query_string_.length());
127+
// remove the question mark
128+
query_string_.remove_prefix(1);
141129
}
142130
}
143131

@@ -150,10 +138,10 @@ std::string AwsAuthenticator::computeCanonicalRequestHash(
150138

151139
canonicalRequestHash.update(request_method);
152140
canonicalRequestHash.update('\n');
153-
canonicalRequestHash.update(url_start_, url_len_);
141+
canonicalRequestHash.update(url_base_);
154142
canonicalRequestHash.update('\n');
155-
if (query_string_start_ != nullptr) {
156-
canonicalRequestHash.update(query_string_start_, query_string_len_);
143+
if (query_string_.length() != 0) {
144+
canonicalRequestHash.update(query_string_);
157145
}
158146
canonicalRequestHash.update('\n');
159147
canonicalRequestHash.update(canonical_headers);
@@ -279,6 +267,10 @@ void AwsAuthenticator::Sha256::update(const std::string &data) {
279267
update(data.c_str(), data.size());
280268
}
281269

270+
void AwsAuthenticator::Sha256::update(const absl::string_view& data) {
271+
update(data.data(), data.size());
272+
}
273+
282274
void AwsAuthenticator::Sha256::update(const uint8_t *bytes, size_t size) {
283275
SHA256_Update(&context_, bytes, size);
284276
}

source/extensions/filters/http/aws_lambda/aws_authenticator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class AwsAuthenticator {
7777
Sha256();
7878
void update(const Buffer::Instance &data);
7979
void update(const std::string &data);
80+
void update(const absl::string_view& data);
81+
8082
void update(char c);
8183
void update(const uint8_t *bytes, size_t size);
8284
void update(const char *chars, size_t size);
@@ -119,10 +121,8 @@ class AwsAuthenticator {
119121
std::string first_key_;
120122
const std::string *service_{};
121123
const std::string *method_{};
122-
const char *query_string_start_{};
123-
size_t query_string_len_{};
124-
const char *url_start_{};
125-
size_t url_len_{};
124+
absl::string_view query_string_{};
125+
absl::string_view url_base_{};
126126

127127
Http::HeaderMap *request_headers_{};
128128
};

source/extensions/filters/http/aws_lambda/aws_lambda_filter.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ namespace Extensions {
2323
namespace HttpFilters {
2424
namespace AwsLambda {
2525

26+
struct RcDetailsValues {
27+
// The jwt_authn filter rejected the request
28+
const std::string FunctionNotFound = "aws_lambda_function_not_fou8nd";
29+
};
30+
typedef ConstSingleton<RcDetailsValues> RcDetails;
31+
2632
class AWSLambdaHeaderValues {
2733
public:
2834
const Http::LowerCaseString InvocationType{"x-amz-invocation-type"};
@@ -78,7 +84,7 @@ AWSLambdaFilter::decodeHeaders(Http::HeaderMap &headers, bool end_stream) {
7884
if (!function_on_route_) {
7985
decoder_callbacks_->sendLocalReply(Http::Code::NotFound,
8086
"no function present for AWS upstream",
81-
nullptr, absl::nullopt);
87+
nullptr, absl::nullopt, RcDetails::get().FunctionNotFound);
8288
return Http::FilterHeadersStatus::StopIteration;
8389
}
8490

source/extensions/filters/http/nats/streaming/nats_streaming_filter.cc

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ namespace HttpFilters {
2121
namespace Nats {
2222
namespace Streaming {
2323

24+
struct RcDetailsValues {
25+
// The jwt_authn filter rejected the request
26+
const std::string PayloadTooLarge = "nats_payload_too_big";
27+
const std::string Completion = "nats_completion";
28+
};
29+
typedef ConstSingleton<RcDetailsValues> RcDetails;
30+
2431
NatsStreamingFilter::NatsStreamingFilter(
2532
NatsStreamingFilterConfigSharedPtr config,
2633
Envoy::Nats::Streaming::ClientPtr nats_streaming_client)
@@ -52,10 +59,10 @@ NatsStreamingFilter::decodeHeaders(Envoy::Http::HeaderMap &headers,
5259
auto mutable_headers = payload_.mutable_headers();
5360
headers.iterate(
5461
[](const Envoy::Http::HeaderEntry &e, void *ctx) {
55-
Envoy::Protobuf::Map<Envoy::ProtobufTypes::String,
56-
Envoy::ProtobufTypes::String> *mutable_headers =
57-
static_cast<Envoy::Protobuf::Map<Envoy::ProtobufTypes::String,
58-
Envoy::ProtobufTypes::String> *>(
62+
Envoy::Protobuf::Map<std::string,
63+
std::string> *mutable_headers =
64+
static_cast<Envoy::Protobuf::Map<std::string,
65+
std::string> *>(
5966
ctx);
6067
(*mutable_headers)[std::string(e.key().getStringView())] =
6168
std::string(e.value().getStringView());
@@ -84,7 +91,7 @@ NatsStreamingFilter::decodeData(Envoy::Buffer::Instance &data,
8491

8592
decoder_callbacks_->sendLocalReply(Http::Code::PayloadTooLarge,
8693
"nats streaming paylaod too large",
87-
nullptr, absl::nullopt);
94+
nullptr, absl::nullopt, RcDetails::get().PayloadTooLarge);
8895
return Http::FilterDataStatus::StopIterationNoBuffer;
8996
}
9097

@@ -171,7 +178,7 @@ void NatsStreamingFilter::onCompletion(Http::Code response_code,
171178
in_flight_request_ = nullptr;
172179

173180
decoder_callbacks_->sendLocalReply(response_code, body_text, nullptr,
174-
absl::nullopt);
181+
absl::nullopt, RcDetails::get().Completion);
175182
}
176183

177184
void NatsStreamingFilter::onCompletion(Http::Code response_code,

source/extensions/filters/http/transformation/body_header_transformer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void BodyHeaderTransformer::transform(Http::HeaderMap &header_map,
2323
void *context) -> Http::HeaderMap::Iterate {
2424
json *headers_ptr = static_cast<json *>(context);
2525
json &headers = *headers_ptr;
26-
headers[header.key().c_str()] = header.value().c_str();
26+
headers[std::string(header.key().getStringView())] = std::string(header.value().getStringView());
2727
return Http::HeaderMap::Iterate::Continue;
2828
},
2929
&headers);

0 commit comments

Comments
 (0)