-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: VHDS: on-demand updates #6552
Closed
Closed
Changes from 14 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
f66b55a
Base implementation of VHDS
0e6c97e
additional formatting fixes
b447f33
More formatting fixes
2da973f
more formatting fixes
21bb7af
Fixing test failures
2a6c77f
wrapped update details into a dedicated class
dbafd58
fixing build failures
200aa3d
Fixing build failures
68d7c52
Added more vhds tests
e692f0e
Fixed formatting errors
38da6ab
fixes based on the PR feedback
9a14662
fixed a spelling mistake
33f795b
moved out VhdsSubscription class into its own file
7a40f59
VHDS: Filter-based on-demand RDS updates
78acd5c
Merged changes from master
96a6c90
Fixes after merging latest changes
fe73bbd
Reponded to feedback
374de2c
Moved on-demand filter to extensions/filters/http/on_demand dir
1c8c52f
Merge branch 'master' into vhds-on-demand
c5e314a
fix to build kafka extension under python3
28e6ad3
Merge branch 'master' into vhds-on-demand
bd11db6
Post-merge fixes
bf63b6d
Renamed requestRouteConfigUpdate to requestVirtualHostsUpdate, update…
bbc38b4
Added comments re: stream restart after route config update
01eca26
Fixing build issues
72896bb
Fixing build issues
2592cce
Fixing build issues
e5d9d94
Fixed formatting issues
7bab936
Fixing build issues
852c51b
Fixing build issues
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include "envoy/api/v2/rds.pb.h" | ||
|
||
namespace Envoy { | ||
namespace Router { | ||
|
||
struct LastConfigInfo { | ||
uint64_t last_config_hash_; | ||
std::string last_config_version_; | ||
}; | ||
|
||
class RouteConfigUpdateInfo { | ||
public: | ||
virtual ~RouteConfigUpdateInfo() = default; | ||
|
||
virtual absl::optional<LastConfigInfo> configInfo() const PURE; | ||
virtual envoy::api::v2::RouteConfiguration& routeConfiguration() PURE; | ||
virtual SystemTime lastUpdated() const PURE; | ||
}; | ||
|
||
} // namespace Router | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,6 +397,7 @@ void ConnectionManagerImpl::chargeTracingStats(const Tracing::Reason& tracing_re | |
|
||
ConnectionManagerImpl::ActiveStream::ActiveStream(ConnectionManagerImpl& connection_manager) | ||
: connection_manager_(connection_manager), | ||
route_config_provider_(connection_manager.config_.routeConfigProvider()), | ||
snapped_route_config_(connection_manager.config_.routeConfigProvider().config()), | ||
stream_id_(connection_manager.random_generator_.random()), | ||
request_response_timespan_(new Stats::Timespan( | ||
|
@@ -1064,6 +1065,7 @@ void ConnectionManagerImpl::ActiveStream::refreshCachedRoute() { | |
Router::RouteConstSharedPtr route; | ||
if (request_headers_ != nullptr) { | ||
route = snapped_route_config_->route(*request_headers_, stream_id_); | ||
// route = route_config_provider_.config()->route(*request_headers_, stream_id_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? |
||
} | ||
stream_info_.route_entry_ = route ? route->routeEntry() : nullptr; | ||
cached_route_ = std::move(route); | ||
|
@@ -1076,6 +1078,12 @@ void ConnectionManagerImpl::ActiveStream::refreshCachedRoute() { | |
} | ||
} | ||
|
||
bool ConnectionManagerImpl::ActiveStream::requestRouteConfigUpdate(std::function<void()> cb) { | ||
// TODO check for an empty header? | ||
auto host_header = Http::LowerCaseString(request_headers_->Host()->value().c_str()).get(); | ||
return route_config_provider_.requestConfigUpdate(host_header, cb); | ||
} | ||
|
||
void ConnectionManagerImpl::ActiveStream::sendLocalReply( | ||
bool is_grpc_request, Code code, absl::string_view body, | ||
const std::function<void(HeaderMap& headers)>& modify_headers, bool is_head_request, | ||
|
@@ -1710,13 +1718,18 @@ Upstream::ClusterInfoConstSharedPtr ConnectionManagerImpl::ActiveStreamFilterBas | |
} | ||
|
||
Router::RouteConstSharedPtr ConnectionManagerImpl::ActiveStreamFilterBase::route() { | ||
if (!parent_.cached_route_.has_value()) { | ||
if (!parent_.cached_route_.has_value() || parent_.cached_route_.value() == nullptr) { | ||
parent_.refreshCachedRoute(); | ||
} | ||
|
||
return parent_.cached_route_.value(); | ||
} | ||
|
||
bool ConnectionManagerImpl::ActiveStreamFilterBase::requestRouteConfigUpdate( | ||
std::function<void()> cb) { | ||
return parent_.requestRouteConfigUpdate(cb); | ||
} | ||
|
||
void ConnectionManagerImpl::ActiveStreamFilterBase::clearRouteCache() { | ||
parent_.cached_route_ = absl::optional<Router::RouteConstSharedPtr>(); | ||
parent_.cached_cluster_info_ = absl::optional<Upstream::ClusterInfoConstSharedPtr>(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "common/router/on_demand_update.h" | ||
dmitri-d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#include "common/common/assert.h" | ||
#include "common/common/enum_to_int.h" | ||
#include "common/http/codes.h" | ||
|
||
#include "extensions/filters/http/well_known_names.h" | ||
|
||
namespace Envoy { | ||
namespace Router { | ||
|
||
void OnDemandRouteUpdate::requestRouteConfigUpdate() { | ||
if (callbacks_->route() != nullptr) { | ||
filter_return_ = FilterReturn::ContinueDecoding; | ||
} else { | ||
auto configUpdateScheduled = | ||
dmitri-d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
callbacks_->requestRouteConfigUpdate([this]() -> void { onComplete(); }); | ||
filter_return_ = | ||
configUpdateScheduled ? FilterReturn::StopDecoding : FilterReturn::ContinueDecoding; | ||
} | ||
} | ||
|
||
Http::FilterHeadersStatus OnDemandRouteUpdate::decodeHeaders(Http::HeaderMap&, bool) { | ||
requestRouteConfigUpdate(); | ||
return filter_return_ == FilterReturn::StopDecoding ? Http::FilterHeadersStatus::StopIteration | ||
: Http::FilterHeadersStatus::Continue; | ||
} | ||
|
||
Http::FilterDataStatus OnDemandRouteUpdate::decodeData(Buffer::Instance&, bool) { | ||
return filter_return_ == FilterReturn::StopDecoding | ||
? Http::FilterDataStatus::StopIterationAndWatermark | ||
: Http::FilterDataStatus::Continue; | ||
} | ||
|
||
Http::FilterTrailersStatus OnDemandRouteUpdate::decodeTrailers(Http::HeaderMap&) { | ||
return filter_return_ == FilterReturn::StopDecoding ? Http::FilterTrailersStatus::StopIteration | ||
dmitri-d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
: Http::FilterTrailersStatus::Continue; | ||
} | ||
|
||
void OnDemandRouteUpdate::setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks& callbacks) { | ||
callbacks_ = &callbacks; | ||
} | ||
|
||
void OnDemandRouteUpdate::onComplete() { | ||
filter_return_ = FilterReturn::ContinueDecoding; | ||
|
||
if (!callbacks_->decodingBuffer() && // Redirects with body not yet supported. | ||
dmitri-d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
callbacks_->recreateStream()) { | ||
// cluster_->stats().upstream_internal_redirect_succeeded_total_.inc(); | ||
return; | ||
} | ||
|
||
// recreating stream failed, continue the filter-chain | ||
callbacks_->continueDecoding(); | ||
} | ||
|
||
} // namespace Router | ||
} // namespace Envoy |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add Doxygen docs for this?