Skip to content

Commit

Permalink
Upgrade envoy to v1.23.0. (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuoyang2016 authored Jul 25, 2022
1 parent 6526c23 commit 1562b0b
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 116 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ bin/
*.pyc
node_modules/
src/go/proto/
# IDE
.clwb/
.ijwb/

# C++ coverage
generated/
Expand Down
12 changes: 10 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# 3) Check if envoy_build_config/extensions_build_config.bzl is up-to-date.
# Try to match it with the one in source/extensions and comment out unneeded extensions.

ENVOY_SHA1 = "dcd329a2e95b54f754b17aceca3f72724294b502" # v1.22.0 2022-04-19
ENVOY_SHA1 = "ce49c7f65668a22b80d1e83c35d170741bb8d46a" # v1.23.0 2022-07-15

ENVOY_SHA256 = "ed455b6a8b7058a243e42df608317d9d1864c1ec618705cc52d747357b3433ed"
ENVOY_SHA256 = "33975319b86087ad1bd22162c0bc8cf573b6be4aae9c53897dee148e955eb27c"

http_archive(
name = "envoy",
Expand Down Expand Up @@ -80,6 +80,14 @@ load("@envoy//bazel:repositories_extra.bzl", "envoy_dependencies_extra")

envoy_dependencies_extra()

load("@envoy//bazel:python_dependencies.bzl", "envoy_python_dependencies")

envoy_python_dependencies()

load("@base_pip3//:requirements.bzl", "install_deps")

install_deps()

load("@envoy//bazel:dependency_imports.bzl", "envoy_dependency_imports")

envoy_dependency_imports()
Expand Down
2 changes: 1 addition & 1 deletion src/envoy/http/backend_auth/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ FilterHeadersStatus Filter::decodeHeaders(RequestHeaderMap& headers, bool) {

const auto* per_route =
::Envoy::Http::Utility::resolveMostSpecificPerFilterConfig<
PerRouteFilterConfig>(kFilterName, route);
PerRouteFilterConfig>(decoder_callbacks_);
if (per_route == nullptr) {
ENVOY_LOG(debug, "no per-route config");
config_->stats().allowed_by_auth_not_required_.inc();
Expand Down
9 changes: 4 additions & 5 deletions src/envoy/http/backend_auth/filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ class BackendAuthFilterTest : public ::testing::Test {
auto per_route = std::make_shared<PerRouteFilterConfig>(per_route_cfg);
EXPECT_CALL(mock_decoder_callbacks_, route())
.WillRepeatedly(Return(mock_route_));
EXPECT_CALL(*mock_route_, mostSpecificPerFilterConfig(kFilterName))
.WillRepeatedly(
Invoke([per_route](const std::string&)
-> const Envoy::Router::RouteSpecificFilterConfig* {
EXPECT_CALL(mock_decoder_callbacks_, mostSpecificPerFilterConfig())
.WillRepeatedly(Invoke(
[per_route]() -> const Envoy::Router::RouteSpecificFilterConfig* {
return per_route.get();
}));
}
Expand Down Expand Up @@ -102,7 +101,7 @@ TEST_F(BackendAuthFilterTest, NotPerRouteConfigAllowed) {
{":path", "/books/1"}};
EXPECT_CALL(mock_decoder_callbacks_, route())
.WillRepeatedly(Return(mock_route_));
EXPECT_CALL(*mock_route_, mostSpecificPerFilterConfig(kFilterName))
EXPECT_CALL(mock_decoder_callbacks_, mostSpecificPerFilterConfig())
.WillRepeatedly(Return(nullptr));

Envoy::Http::FilterHeadersStatus status =
Expand Down
2 changes: 1 addition & 1 deletion src/envoy/http/path_rewrite/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ FilterHeadersStatus Filter::decodeHeaders(RequestHeaderMap& headers, bool) {

const auto* per_route =
::Envoy::Http::Utility::resolveMostSpecificPerFilterConfig<
PerRouteFilterConfig>(kFilterName, route);
PerRouteFilterConfig>(decoder_callbacks_);
if (per_route == nullptr) {
ENVOY_LOG(debug,
"no per-route config, request is passed through unmodified");
Expand Down
6 changes: 3 additions & 3 deletions src/envoy/http/path_rewrite/filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ TEST_F(FilterTest, NotPerRouteConfigNotChanged) {
{":path", "/books/1"}};
EXPECT_CALL(mock_decoder_callbacks_, route())
.WillRepeatedly(Return(mock_route_));
EXPECT_CALL(*mock_route_, mostSpecificPerFilterConfig(kFilterName))
EXPECT_CALL(mock_decoder_callbacks_, mostSpecificPerFilterConfig())
.WillRepeatedly(Return(nullptr));

Envoy::Http::FilterHeadersStatus status =
Expand All @@ -171,7 +171,7 @@ TEST_F(FilterTest, RejectedByMismatchUrlTemplate) {
{":path", "/books/1"}};
EXPECT_CALL(mock_decoder_callbacks_, route())
.WillRepeatedly(Return(mock_route_));
EXPECT_CALL(*mock_route_, mostSpecificPerFilterConfig(kFilterName))
EXPECT_CALL(mock_decoder_callbacks_, mostSpecificPerFilterConfig())
.WillRepeatedly(Return(per_route_config_.get()));

// Mismatch
Expand Down Expand Up @@ -210,7 +210,7 @@ TEST_F(FilterTest, PathUpdated) {
{":path", "/books/1"}};
EXPECT_CALL(mock_decoder_callbacks_, route())
.WillRepeatedly(Return(mock_route_));
EXPECT_CALL(*mock_route_, mostSpecificPerFilterConfig(kFilterName))
EXPECT_CALL(mock_decoder_callbacks_, mostSpecificPerFilterConfig())
.WillRepeatedly(Return(per_route_config_.get()));

// path rewrite ok
Expand Down
8 changes: 4 additions & 4 deletions src/envoy/http/service_control/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ Envoy::Http::FilterHeadersStatus ServiceControlFilter::decodeHeaders(
return Envoy::Http::FilterHeadersStatus::Continue;
}

handler_ =
factory_.createHandler(headers, decoder_callbacks_->streamInfo(), stats_);
handler_ = factory_.createHandler(headers, decoder_callbacks_, stats_);
handler_->fillFilterState(*decoder_callbacks_->streamInfo().filterState());
state_ = Calling;
stopped_ = false;
Expand Down Expand Up @@ -144,11 +143,12 @@ void ServiceControlFilter::log(
const Envoy::Http::RequestHeaderMap* request_headers,
const Envoy::Http::ResponseHeaderMap* response_headers,
const Envoy::Http::ResponseTrailerMap* response_trailers,
const Envoy::StreamInfo::StreamInfo& stream_info) {
const Envoy::StreamInfo::StreamInfo&) {
ENVOY_LOG(debug, "Called ServiceControl Filter : {}", __func__);
if (!handler_) {
if (!request_headers) return;
handler_ = factory_.createHandler(*request_headers, stream_info, stats_);
handler_ =
factory_.createHandler(*request_headers, decoder_callbacks_, stats_);
}

Envoy::Tracing::Span& parent_span = decoder_callbacks_->activeSpan();
Expand Down
2 changes: 1 addition & 1 deletion src/envoy/http/service_control/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ServiceControlHandlerFactory {

virtual ServiceControlHandlerPtr createHandler(
const Envoy::Http::RequestHeaderMap& headers,
const Envoy::StreamInfo::StreamInfo& stream_info,
Envoy::Http::StreamDecoderFilterCallbacks* decoder_callbacks,
ServiceControlFilterStats& filter_stats) const PURE;
};

Expand Down
22 changes: 8 additions & 14 deletions src/envoy/http/service_control/handler_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ constexpr char JwtPayloadAudiencePath[] = "aud";

ServiceControlHandlerImpl::ServiceControlHandlerImpl(
const Envoy::Http::RequestHeaderMap& headers,
const Envoy::StreamInfo::StreamInfo& stream_info, const std::string& uuid,
const FilterConfigParser& cfg_parser, Envoy::TimeSource& time_source,
ServiceControlFilterStats& filter_stats)
Envoy::Http::StreamDecoderFilterCallbacks* decoder_callbacks,
const std::string& uuid, const FilterConfigParser& cfg_parser,
Envoy::TimeSource& time_source, ServiceControlFilterStats& filter_stats)
: cfg_parser_(cfg_parser),
stream_info_(stream_info),
stream_info_(decoder_callbacks->streamInfo()),
decoder_callbacks_(decoder_callbacks),
time_source_(time_source),
uuid_(uuid),
request_header_size_(headers.byteSize()),
Expand All @@ -82,7 +83,7 @@ ServiceControlHandlerImpl::ServiceControlHandlerImpl(
http_method_ = std::string(utils::readHeaderEntry(headers.Method()));
path_ = std::string(utils::readHeaderEntry(headers.Path()));

const auto operation = getOperationFromPerRoute(stream_info_);
const auto operation = getOperationFromPerRoute();
if (!operation.empty()) {
require_ctx_ = cfg_parser_.find_requirement(operation);
if (!require_ctx_) {
Expand All @@ -107,17 +108,10 @@ ServiceControlHandlerImpl::ServiceControlHandlerImpl(

ServiceControlHandlerImpl::~ServiceControlHandlerImpl() {}

absl::string_view ServiceControlHandlerImpl::getOperationFromPerRoute(
const Envoy::StreamInfo::StreamInfo& stream_info) {
if (stream_info_.route() == nullptr ||
stream_info_.route()->routeEntry() == nullptr) {
ENVOY_LOG(debug, "No route entry");
return Envoy::EMPTY_STRING;
}

absl::string_view ServiceControlHandlerImpl::getOperationFromPerRoute() {
const auto* per_route =
::Envoy::Http::Utility::resolveMostSpecificPerFilterConfig<
PerRouteFilterConfig>(kFilterName, stream_info.route());
PerRouteFilterConfig>(decoder_callbacks_);
if (per_route == nullptr) {
ENVOY_LOG(debug, "no per-route config");
return Envoy::EMPTY_STRING;
Expand Down
21 changes: 11 additions & 10 deletions src/envoy/http/service_control/handler_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "envoy/buffer/buffer.h"
#include "envoy/common/random_generator.h"
#include "envoy/common/time.h"
#include "envoy/http/filter.h"
#include "envoy/http/header_map.h"
#include "envoy/http/query_params.h"
#include "envoy/runtime/runtime.h"
Expand All @@ -42,12 +43,11 @@ class ServiceControlHandlerImpl
: public Envoy::Logger::Loggable<Envoy::Logger::Id::filter>,
public ServiceControlHandler {
public:
ServiceControlHandlerImpl(const Envoy::Http::RequestHeaderMap& headers,
const Envoy::StreamInfo::StreamInfo& stream_info,
const std::string& uuid,
const FilterConfigParser& cfg_parser,
Envoy::TimeSource& timeSource,
ServiceControlFilterStats& filter_stats);
ServiceControlHandlerImpl(
const Envoy::Http::RequestHeaderMap& headers,
Envoy::Http::StreamDecoderFilterCallbacks* decoder_callbacks,
const std::string& uuid, const FilterConfigParser& cfg_parser,
Envoy::TimeSource& timeSource, ServiceControlFilterStats& filter_stats);
~ServiceControlHandlerImpl() override;

void callCheck(Envoy::Http::RequestHeaderMap& headers,
Expand All @@ -64,8 +64,7 @@ class ServiceControlHandlerImpl
void onDestroy() override;

private:
absl::string_view getOperationFromPerRoute(
const Envoy::StreamInfo::StreamInfo& stream_info);
absl::string_view getOperationFromPerRoute();

void callQuota();

Expand Down Expand Up @@ -106,6 +105,8 @@ class ServiceControlHandlerImpl
// The metadata for the request
const Envoy::StreamInfo::StreamInfo& stream_info_;

Envoy::Http::StreamDecoderFilterCallbacks* decoder_callbacks_;

// timeSource
Envoy::TimeSource& time_source_;

Expand Down Expand Up @@ -152,10 +153,10 @@ class ServiceControlHandlerFactoryImpl : public ServiceControlHandlerFactory {

ServiceControlHandlerPtr createHandler(
const Envoy::Http::RequestHeaderMap& headers,
const Envoy::StreamInfo::StreamInfo& stream_info,
Envoy::Http::StreamDecoderFilterCallbacks* decoder_callbacks,
ServiceControlFilterStats& filter_stats) const override {
return std::make_unique<ServiceControlHandlerImpl>(
headers, stream_info, random_.uuid(), cfg_parser_, time_source_,
headers, decoder_callbacks, random_.uuid(), cfg_parser_, time_source_,
filter_stats);
}

Expand Down
Loading

0 comments on commit 1562b0b

Please sign in to comment.