Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
6521aa0
debug: improving symbolization further (#3728)
alyssawilk Jun 26, 2018
56a047b
thrift: filter integration tests (#3679)
zuercher Jun 26, 2018
0f631e1
test-utillity: Remove test-utility wrapper for Buffer::toString(). (#…
jmarantz Jun 27, 2018
6460533
admin: add json serialized proto for /clusters (#3478)
mrice32 Jun 27, 2018
9025369
thrift: fix bad merge related to TestUtility::bufferToString (#3742)
zuercher Jun 27, 2018
5244597
authz_filter: extended ext_authz to support v2alpha api (#3162)
Jun 27, 2018
9e7a3ab
rbac: add metadata support to rbac filter (#3638)
yangminzhu Jun 27, 2018
4e0b252
change log level to debug (#3738)
ramaraochavali Jun 27, 2018
4f344cf
Skeleton for HdsCluster
markatou Jun 27, 2018
e050f5e
include vector (#3746)
danielhochman Jun 28, 2018
299591b
Tell tar to follow symlinks. (#3745)
tschroed Jun 28, 2018
9c27339
support for hystrix dashboard through an admin endpoint, using sink (…
trabetti Jun 28, 2018
18cdf0f
ci: updating EXPECTED_CXX_VERSION (#3751)
alyssawilk Jun 28, 2018
ab86abc
config: health checker timeout and interval should be greater than 0 …
dio Jun 28, 2018
4865c9c
rbac: add some debug logging. (#3744)
yangminzhu Jun 28, 2018
6d58cb8
move hystrix entry to keep the section alphabetically sorted (#3752)
trabetti Jun 28, 2018
93d96b5
Remove deprecated SAN. (#3727)
shakti-das Jun 28, 2018
4b871c0
Fixes #3756 by creating a new api_proto_library_internal build rule t…
mju Jun 29, 2018
f69baf8
change unofficial Chinese doc with ServiceMesher (#3767)
rootsongjc Jun 30, 2018
52de772
http: changing mutate[request|response] to special case all upgrade h…
alyssawilk Jul 2, 2018
b686053
test: fixing most tests for v2-config-only true (#3743)
alyssawilk Jul 2, 2018
e341004
Incremental XDS proposal. (#3470)
Jul 2, 2018
9365720
access log: add response flag filter (#3536)
junr03 Jul 2, 2018
31abe6e
test: use type-specific constructor when creating empty PortMap. (#3777)
PiotrSikora Jul 3, 2018
090676d
util: ignore unknown fields in parsing jsons (#3778)
kyessenov Jul 3, 2018
2805b46
thrift: split transport/protocol code into interface and implementati…
zuercher Jul 3, 2018
c563b39
test: tweaks to uds_integration_test (--runs_per_test) (#3784)
alyssawilk Jul 3, 2018
2c3c3e7
lua: add requestInfo():protocol() API (#3760)
dio Jul 3, 2018
07b13c0
config: backoff strategy implementation (#3758)
ramaraochavali Jul 4, 2018
3b05bff
Add requestedServerName() to Network::connection (#3782)
vadimeisenbergibm Jul 4, 2018
a5da078
health check: structured active healthcheck logging (#3176)
Jul 5, 2018
fe94528
lua: add connection():ssl() API (#3761)
dio Jul 6, 2018
b79d5e1
rbac: not permission/principal matcher (#3801)
rodaine Jul 6, 2018
0f01a2a
authz_bugfix: headers need to be copied (#3759)
Jul 7, 2018
75909a7
lc trie: templated LcTrie<T>. (#3780)
PiotrSikora Jul 7, 2018
7253d5f
config: flipping v2-config-only to disable v1 support by default (#3807)
alyssawilk Jul 9, 2018
37ad8fc
http: strip additional invalid h/2 response headers (#3797)
snowp Jul 9, 2018
8875eba
http: better handling of HEAD requests (#3775)
alyssawilk Jul 9, 2018
866597f
format: run clang-format on protos again (#3811)
mattklein123 Jul 9, 2018
4b4fd6a
Basic HdsCluster, and healthchecker initialization
markatou Jul 9, 2018
24dfa19
ssl: introduce `serialNumberPeerCertificate()` (#3779)
talnordan Jul 9, 2018
fd57604
thrift: transport and protocol write code (#3789)
zuercher Jul 9, 2018
74928c7
api: remove support for cluster_names field in ApiConfigSource protos…
ambuc Jul 9, 2018
5e1eb02
router: Remove the HeaderMatcher value and regex fields. (#3796)
kavyako Jul 9, 2018
cd95109
Add new issue label "no stalebot" to be ignored by stalebot. (#3821)
ggreenway Jul 9, 2018
2a45375
Auto-merge the version-history file. (#3820)
ggreenway Jul 9, 2018
00bb039
cors: allow using regexes to match origins (#3769)
codesuki Jul 10, 2018
2705764
network: fixing a bug in detecting closed connections (#3813)
alyssawilk Jul 10, 2018
80be024
authz_fix: keep the previous behaviour of adding encoding header (#3805)
Jul 10, 2018
c3d2f37
common/tcp: generic TCP connection pool for extensions (#3747)
zuercher Jul 10, 2018
b9db466
thrift: replace numeric limit macros with std::numeric_limits (#3822)
zuercher Jul 10, 2018
9333f23
Revert "stats: envoy prometheus endpoint fails promlint due to format…
JonathanO Jul 10, 2018
03cfb87
healthchecks: Add interval_jitter_percent healthcheck option (#3816)
julia-stripe Jul 10, 2018
eab54b5
Add hard-coded /hot_restart_version test (#3832)
ambuc Jul 10, 2018
55e7456
Update ApiConfigSource docs with grpc_services only for GRPC configs …
ambuc Jul 10, 2018
1c39216
Endpoint reposnds to healthcheck request
markatou Jul 10, 2018
ce83509
test: deflaking a test, improving debugability (#3829)
alyssawilk Jul 10, 2018
810ec2e
Support mutable metadata for endpoints (#3814)
rgs1 Jul 10, 2018
df7a291
format: run buildifier on .bzl files. (#3824)
PiotrSikora Jul 11, 2018
c46a946
Server -> Envoy -> Single Endpoint healthcheck
markatou Jul 11, 2018
a49f8b7
Naming changes
markatou Jul 11, 2018
b1f870a
common: jittered backoff implementation (#3791)
ramaraochavali Jul 11, 2018
f22d552
test: add test for consistency of RawStatData internal memory represe…
ambuc Jul 11, 2018
6881200
logging: Requiring details for RELEASE_ASSERT (#3842)
alyssawilk Jul 11, 2018
2ba32f2
fix master build (#3844)
lizan Jul 11, 2018
6a57863
common: minor doc updates (#3845)
ramaraochavali Jul 12, 2018
e0977b1
Removing EDS dependency from hds test
markatou Jul 12, 2018
95c3e13
http: new style WebSockets, where headers and data are processed by t…
alyssawilk Jul 12, 2018
336bce9
test: deflaking header_integration_test (#3849)
alyssawilk Jul 12, 2018
9de80f7
upstream: introduce PriorityStateManager, refactor EDS (#3783)
dio Jul 12, 2018
37f66d2
lc trie: add exclusive flag. (#3825)
PiotrSikora Jul 12, 2018
c2e3ada
config: making v2-config-only a boolean flag (#3847)
alyssawilk Jul 12, 2018
119c4c8
Addressing comments
markatou Jul 12, 2018
218d112
proxy_protocol: add support for HAProxy Proxy Protocol v2 (binary) (#…
donbowman Jul 12, 2018
e718500
Ensure subsets are updated when metadata changes (#3840)
rgs1 Jul 12, 2018
a182041
test: fixing yet more flakes (#3850)
alyssawilk Jul 12, 2018
0a0914e
upstream: allow subset_lb to be configured to respect locality weight…
snowp Jul 13, 2018
0cf947f
grpc-json: handle google.api.HttpBody when building HTTP response (#3…
dio Jul 13, 2018
230228b
api: added csharp namespace override to cluster and listener packages…
skwasiborski Jul 13, 2018
c92a301
Refactor Stats::RawStatData into a StatsOptions struct (#3629)
ambuc Jul 13, 2018
14af459
Addressing comments, adding a response message
markatou Jul 13, 2018
01d2e16
listener: filter chain selection based on destination IP/port. (#3851)
PiotrSikora Jul 13, 2018
7caa887
fuzz: server config validation fuzz test. (#3770)
anirudhmurali Jul 15, 2018
9a685a0
jwt_authn: fix comments (#3862)
talnordan Jul 16, 2018
e435d18
cors: set access-control-expose-headers on actual CORS request (#3852)
stanley-cheung Jul 16, 2018
45fe83e
http: per-stream idle timeout. (#3841)
htuch Jul 16, 2018
606a22a
Process more messages and reply to server every interval
markatou Jul 16, 2018
cf12ea5
upstream: fix PriorityStateManager indexing (#3856)
akonradi Jul 16, 2018
05647d6
Added capability to the hdsdelegate's message and cleaned up code a bit
markatou Jul 16, 2018
5f8b25e
test: deflaking ratelimit_integration_test (#3866)
alyssawilk Jul 16, 2018
b3c5fe6
Minor changes
markatou Jul 16, 2018
d69dd92
Added a todo
markatou Jul 16, 2018
445f365
Use shared_ptr for SSL context objects (#3754)
qiwzhang Jul 16, 2018
27be177
lua filter: fix memory leak due to circular runtime reference (#3855)
mattklein123 Jul 16, 2018
1645fa5
websocket: deprecating old style websocket (#3867)
alyssawilk Jul 17, 2018
a0b22ef
http/2: fix spurious limit of 100 concurrent streams. (#3658)
PiotrSikora Jul 17, 2018
4aad3f8
Addressing some comments
markatou Jul 17, 2018
03d02e5
Fixing format
markatou Jul 17, 2018
c99fff2
No magic numbers
markatou Jul 17, 2018
8fa8401
build: document missing dependency when building nghttp2 from sources…
PiotrSikora Jul 18, 2018
1940195
add python protobuf package (#3859)
nzoschke Jul 18, 2018
2a68458
coverage: rename NOT_REACHED/NOT_IMPLEMENTED to exclude them from cod…
zuercher Jul 18, 2018
17efc83
Avoid extra `predicate()` calls (#3869)
rgs1 Jul 18, 2018
8e7b0b5
Addressed comments
markatou Jul 18, 2018
a7cf6df
Add string conversion necessary for google import. (#3885)
mrice32 Jul 18, 2018
f9ce8f7
Addressing comments and an attempt at a unit test
markatou Jul 18, 2018
27c99de
load_stats: fix race condition. (#3868)
htuch Jul 18, 2018
1aa2430
lc trie: fix memory leak. (#3890)
PiotrSikora Jul 18, 2018
a0b6243
Move well known names from ALL_CAPS to CamelCase. (#3893)
mrice32 Jul 18, 2018
3a56d21
coverage: remove deprecated NOT_IMPLEMENTED (#3889)
zuercher Jul 19, 2018
0e71582
add resource monitor framework (#3848)
eziskind Jul 19, 2018
0f68948
authz: fix RBAC filter config PB docs (#3895)
talnordan Jul 19, 2018
a8fa0c6
http/2: use hpack_table_size to control both encoder and decoder. (#3…
PiotrSikora Jul 19, 2018
b14ce1d
syscall: latch errno deeper in the buffer implementation (#3880)
venilnoronha Jul 19, 2018
982ebd2
load_stats: fix for Google import. (#3900)
htuch Jul 19, 2018
b202f89
Remove the deprecated redis_health_check field (#3896)
dio Jul 19, 2018
8ed7c15
api: ensure HeaderValue keys are non-empty. (#3901)
htuch Jul 19, 2018
20296c5
http: ensure the per-stream idle timer is disabled at stream end. (#3…
htuch Jul 20, 2018
b8e019f
Update gauges when a subset LB is destroyed (#3917)
rgs1 Jul 20, 2018
598f5c9
listener: fix ipv6 error (#3912)
ramaraochavali Jul 20, 2018
3cc6e3c
fuzz: fuzzer for HeaderMapImpl. (#3921)
htuch Jul 22, 2018
a5d9885
util: Add test for checking the format of proto files. (#3923)
jmarantz Jul 23, 2018
783fda9
http1: fix crash when upstream sends extra CR/LF between responses (#…
mattklein123 Jul 23, 2018
569d70a
test: fixing a downstream tsan failure (#3926)
alyssawilk Jul 23, 2018
a5478ee
alts: add gRPC TSI frame protector (#3873)
lizan Jul 23, 2018
391150a
coverage: coverage runs for a single test target. (#3922)
htuch Jul 23, 2018
672083c
http: global connection manager per-stream idle timeouts. (#3879)
htuch Jul 23, 2018
3a5d126
lua: add requestInfo():dynamicMetadata() API (#3800)
dio Jul 23, 2018
c4b6aec
jwt_authn docs: fix Protobuf YAML examples (#3924)
talnordan Jul 23, 2018
e021e4d
Add integration tests for static secrets (#3910)
qiwzhang Jul 23, 2018
2d7b9df
Added a unit test, and the class HdsInfoFactory to help with testing
markatou Jul 23, 2018
7c11e92
tcp/conn_pool: improve interface for callers (#3903)
zuercher Jul 23, 2018
445e746
docs: adding flaky test instructions (#3931)
alyssawilk Jul 23, 2018
0a43ae8
Update network utility getoriginaldst for IPv6 (#3933)
cmluciano Jul 24, 2018
eefd06d
Add new field to access log (#3907)
rgs1 Jul 24, 2018
054513e
Addressing comments
markatou Jul 24, 2018
8b3aae8
health_check: remove deprecated endpoint field (#3891)
mrice32 Jul 24, 2018
b32eabf
upstream: implement Cluster's load_assignment field (#3864)
dio Jul 24, 2018
e89c9d6
build: Initial bazel build file changes for Windows (#3884)
sesmith177 Jul 24, 2018
b9fc350
Moving ClusterInfoFactory to a more usual location
markatou Jul 24, 2018
a03c343
Fix envoy-filter-example build (#3947)
sesmith177 Jul 24, 2018
1f445bd
build: external deps build on Windows (#3892)
sesmith177 Jul 24, 2018
0621763
listener: deprecate sni_domains. (#3948)
PiotrSikora Jul 25, 2018
1ef23d4
tls: update BoringSSL to 372daf70 (3440). (#3946)
PiotrSikora Jul 25, 2018
ec0179a
router: add response/request header options at route level (#3838)
derekargueta Jul 25, 2018
8459237
fuzz: fixes oss-fuzz: 8363 (#3905)
anirudhmurali Jul 25, 2018
f3b1100
websocket: fixing websocket to consistently not send connection: clos…
alyssawilk Jul 25, 2018
c27ed1f
Addressing comments
markatou Jul 25, 2018
3ee3aa3
Add support for drop category policy and reporting (#3894)
vishalpowar Jul 25, 2018
9b64f4b
build: BUILD file changes necessary for #3892 (#3909)
sesmith177 Jul 26, 2018
5beff99
Fix run_envoy_docker.sh 'do_ci.sh ' does not work behind proxy (#3956)
249043822 Jul 26, 2018
72a964c
thrift_proxy: simple thrift router (#3863)
zuercher Jul 26, 2018
4868061
thirdpary: explicit libdir path (#3962)
vbatts Jul 26, 2018
42109e5
health check: allow request header formatting for HTTP health check r…
dio Jul 26, 2018
0e2c795
fuzz: fixes oss-fuzz: 9204 (#3935)
anirudhmurali Jul 27, 2018
1dfde38
thrift_proxy: move protobuf to api/config hierarchy (#3963)
zuercher Jul 27, 2018
280baee
rds: split subscription out from RdsRouteConfigProviderImpl (#3960)
lizan Jul 27, 2018
bcad173
Polishing
markatou Jul 27, 2018
324e628
syscall: refactor address APIs for deeper errno latching (#3897)
venilnoronha Jul 27, 2018
8babc5e
Added a unit test for HdsDelegate::sendResponse
markatou Jul 27, 2018
f4b0a52
Added a TODO
markatou Jul 27, 2018
9d62fe8
Merge branch 'master' into hds_cluster
markatou Jul 27, 2018
b6c737f
Merge remote-tracking branch 'upstream/master' into hds_cluster
markatou Jul 27, 2018
f28dc53
Remove deprecated handling of mutating admin requests from GET. (#3975)
jmarantz Jul 28, 2018
6b65dbe
Change drop_percentage to FractionalPercent (#3974)
vishalpowar Jul 28, 2018
8b9fd9a
Refactor setSocketOption for better errno latching (#3915)
venilnoronha Jul 28, 2018
08fadcc
http: fix segfault when idle timer fires before request headers recei…
htuch Jul 28, 2018
2563fe1
Merge remote-tracking branch 'upstream/master' into hds_cluster
markatou Jul 30, 2018
01268da
Fixing merging
markatou Jul 30, 2018
6a820f7
Merge branch 'hds_cluster' of ssh://github.com/markatou/envoy into hd…
markatou Jul 30, 2018
ed131cf
docs: minor typo and grammar fixups (#3984)
nicktrav Jul 30, 2018
dc03a9a
docs: fix grammar errors (#3983)
kakengloh Jul 30, 2018
46c63e6
Addressing failing tests
markatou Jul 30, 2018
7d61b00
fuzz: fixes oss-fuzz: 9621 (#3988)
anirudhmurali Jul 30, 2018
f882e74
syscall: use Api::SysCallResult in buffer impl (#3976)
venilnoronha Jul 30, 2018
028387a
tcp_proxy: convert TCP proxy to use TCP connection pool (#3938)
zuercher Jul 30, 2018
f0ca754
Fix prometheus typo. (#3999)
moderation Jul 31, 2018
83b9e2d
Add overload manager for Envoy (#3954)
eziskind Jul 31, 2018
b27068b
listener: add socket api in os sys calls for additional tests (#3968)
ramaraochavali Jul 31, 2018
eb5ea98
fuzz: fixes oss-fuzz: 9599, 9600 (#3979)
anirudhmurali Jul 31, 2018
62441f9
Add option for merging cluster updates (#3941)
rgs1 Jul 31, 2018
2012c3e
rds: make RouteConfigProvider unique_ptr (#3967)
lizan Jul 31, 2018
b96da53
Addressing comments
markatou Jul 31, 2018
d0f10fa
HeapStatData with a distinct allocation mechanism for RawStatData (#3…
jmarantz Jul 31, 2018
6a8b843
test: Add timeouts to methods that could wait forever in test/integra…
mkbehr Jul 31, 2018
315f561
Merge remote-tracking branch 'upstream/master' into hds_cluster
markatou Aug 1, 2018
bb0a9c6
Addressing comments
markatou Aug 1, 2018
85f0ba7
Addressing comments
markatou Aug 2, 2018
2a0ab6f
Adding TODOs and removing a couple empty lines
markatou Aug 3, 2018
79f1dce
Addressing comments
markatou Aug 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/envoy/upstream/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ envoy_cc_library(
hdrs = ["health_check_host_monitor.h"],
)

envoy_cc_library(
name = "health_discovery_service_lib",
hdrs = ["health_discovery_service.h"],
deps = [
"//include/envoy/upstream:upstream_interface",
],
)

envoy_cc_library(
name = "host_description_interface",
hdrs = ["host_description.h"],
Expand Down
25 changes: 25 additions & 0 deletions include/envoy/upstream/health_discovery_service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "common/upstream/upstream_impl.h"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this in cluster_manager.h or upstream.h; there should be nothing HDS specific in the interface (renamd createHdsClusterInfo below to createClusterInfo.


namespace Envoy {
namespace Upstream {

/**
* Factory for unit testing Upstream::HdsDelegate

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not just for HDS.. it's just a general ClusterInfo factory..

*/

class ClusterInfoFactory {
public:
virtual ~ClusterInfoFactory() {}
/**
* @return ClusterInfoConstSharedPtr
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing, please elaborate in comment on @params and what it does.

virtual ClusterInfoConstSharedPtr
createHdsClusterInfo(Runtime::Loader& runtime, const envoy::api::v2::Cluster& cluster,
const envoy::api::v2::core::BindConfig& bind_config, Stats::Store& stats,
Ssl::ContextManager& ssl_context_manager,
Secret::SecretManager& secret_manager, bool added_via_api) PURE;
};

} // namespace Upstream
} // namespace Envoy
8 changes: 8 additions & 0 deletions source/common/upstream/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,18 @@ envoy_cc_library(
srcs = ["health_discovery_service.cc"],
hdrs = ["health_discovery_service.h"],
deps = [
":health_checker_lib",
":upstream_includes",
"//include/envoy/event:dispatcher_interface",
"//include/envoy/runtime:runtime_interface",
"//include/envoy/ssl:context_manager_interface",
"//include/envoy/stats:stats_macros",
"//include/envoy/upstream:cluster_manager_interface",
"//include/envoy/upstream:health_discovery_service_lib",
"//include/envoy/upstream:upstream_interface",
"//source/common/common:minimal_logger_lib",
"//source/common/grpc:async_client_lib",
"//source/common/network:resolver_lib",
"@envoy_api//envoy/service/discovery/v2:hds_cc",
],
)
Expand Down
198 changes: 183 additions & 15 deletions source/common/upstream/health_discovery_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,30 @@ namespace Envoy {
namespace Upstream {

HdsDelegate::HdsDelegate(const envoy::api::v2::core::Node& node, Stats::Scope& scope,
Grpc::AsyncClientPtr async_client, Event::Dispatcher& dispatcher)
Grpc::AsyncClientPtr async_client, Event::Dispatcher& dispatcher,
Runtime::Loader& runtime, Envoy::Stats::Store& stats,
Ssl::ContextManager& ssl_context_manager,
Secret::SecretManager& secret_manager, Runtime::RandomGenerator& random,
ClusterInfoFactory& info_factory)
: stats_{ALL_HDS_STATS(POOL_COUNTER_PREFIX(scope, "hds_delegate."))},
async_client_(std::move(async_client)),
service_method_(*Protobuf::DescriptorPool::generated_pool()->FindMethodByName(
"envoy.service.discovery.v2.HealthDiscoveryService.StreamHealthCheck")) {
"envoy.service.discovery.v2.HealthDiscoveryService.StreamHealthCheck")),
runtime_(runtime), store_stats(stats), ssl_context_manager_(ssl_context_manager),
secret_manager_(secret_manager), random_(random), dispatcher_(dispatcher),
info_factory_(info_factory) {
health_check_request_.mutable_node()->MergeFrom(node);
retry_timer_ = dispatcher.createTimer([this]() -> void { establishNewStream(); });
response_timer_ = dispatcher.createTimer([this]() -> void { sendHealthCheckRequest(); });
server_response_timer_ = dispatcher.createTimer([this]() -> void { sendResponse(); });
establishNewStream();
}

void HdsDelegate::setRetryTimer() {
retry_timer_->enableTimer(std::chrono::milliseconds(RETRY_DELAY_MS));
retry_timer_->enableTimer(std::chrono::milliseconds(RetryDelayMilliseconds));
}

void HdsDelegate::setServerResponseTimer() {
server_response_timer_->enableTimer(std::chrono::milliseconds(server_response_ms_));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: prefer not to add unnecessary extra whitespace.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

void HdsDelegate::establishNewStream() {
Expand All @@ -30,22 +41,48 @@ void HdsDelegate::establishNewStream() {
return;
}

sendHealthCheckRequest();
}

void HdsDelegate::sendHealthCheckRequest() {
ENVOY_LOG(debug, "Sending HealthCheckRequest");
// TODO(lilika): Add support for other types of healthchecks
health_check_request_.mutable_capability()->add_health_check_protocol(
envoy::service::discovery::v2::Capability::HTTP);
ENVOY_LOG(debug, "Sending HealthCheckRequest {} ", health_check_request_.DebugString());
stream_->sendMessage(health_check_request_, false);
stats_.responses_.inc();
}

// TODO(lilika) : Use jittered backoff as in https://github.com/envoyproxy/envoy/pull/3791
void HdsDelegate::handleFailure() {
ENVOY_LOG(warn, "Load reporter stats stream/connection failure, will retry in {} ms.",
RETRY_DELAY_MS);
ENVOY_LOG(warn, "HdsDelegate stream/connection failure, will retry in {} ms.",
RetryDelayMilliseconds);
stats_.errors_.inc();
setRetryTimer();
}

// TODO(lilika): Add support for the same endpoint in different clusters/ports
void HdsDelegate::sendResponse() {
envoy::service::discovery::v2::HealthCheckRequestOrEndpointHealthResponse response;
for (uint32_t i = 0; i < hds_clusters_.size(); i++) {
for (const auto& hosts : hds_clusters_[i]->prioritySet().hostSetsPerPriority()) {
for (const auto& host : hosts->hosts()) {
auto* endpoint = response.mutable_endpoint_health_response()->add_endpoints_health();
endpoint->mutable_endpoint()->mutable_address()->mutable_socket_address()->set_address(
host->address()->ip()->addressAsString());
endpoint->mutable_endpoint()->mutable_address()->mutable_socket_address()->set_port_value(
host->address()->ip()->port());
// TODO(lilika): Add support for more granular options of envoy::api::v2::core::HealthStatus
if (host->healthy()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a TODO to add support for the more granular notions of health status in envoy::api::v2::core::HealthStatus?

endpoint->set_health_status(envoy::api::v2::core::HealthStatus::HEALTHY);
} else {
endpoint->set_health_status(envoy::api::v2::core::HealthStatus::UNHEALTHY);
}
}
}
}
ENVOY_LOG(debug, "Sending EndpointHealthResponse to server {}", response.DebugString());
stream_->sendMessage(response, false);
stats_.responses_.inc();
setServerResponseTimer();
}

void HdsDelegate::onCreateInitialMetadata(Http::HeaderMap& metadata) {
UNREFERENCED_PARAMETER(metadata);
}
Expand All @@ -54,12 +91,71 @@ void HdsDelegate::onReceiveInitialMetadata(Http::HeaderMapPtr&& metadata) {
UNREFERENCED_PARAMETER(metadata);
}

void HdsDelegate::processMessage(
std::unique_ptr<envoy::service::discovery::v2::HealthCheckSpecifier>&& message) {
ENVOY_LOG(debug, "New health check response message {} ", message->DebugString());
ASSERT(message);
for (int i = 0; i < message->health_check_size(); i++) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be for(const auto& health_check: message->health_check())?

// Create HdsCluster config
ENVOY_LOG(debug, "Creating HdsCluster config");
envoy::api::v2::core::BindConfig bind_config;

clusters_config_.emplace_back();
envoy::api::v2::Cluster& cluster_config = clusters_config_.back();

cluster_config.set_name(message->health_check(i).cluster_name());
cluster_config.mutable_connect_timeout()->set_seconds(ClusterTimeoutSeconds);
cluster_config.mutable_per_connection_buffer_limit_bytes()->set_value(
ClusterConnectionBufferLimitBytes);

// Add endpoints to cluster
for (int j = 0; j < message->health_check(i).endpoints_size(); j++) {
const auto& endpoints = message->health_check(i).endpoints(j);
for (int k = 0; k < endpoints.endpoints_size(); k++) {
cluster_config.add_hosts()->MergeFrom(endpoints.endpoints(k).address());
}
}

// TODO(lilika): Add support for optional per-endpoint health checks

// Add healthcheckers to cluster
auto health_checkers = message->health_check(i);
for (int j = 0; j < health_checkers.health_checks_size(); j++) {
cluster_config.add_health_checks()->MergeFrom(health_checkers.health_checks(j));
}

ENVOY_LOG(debug, "New HdsCluster config {} ", cluster_config.DebugString());

// Create HdsCluster
hds_clusters_.emplace_back(new HdsCluster(runtime_, cluster_config, bind_config, store_stats,
ssl_context_manager_, secret_manager_, false,
info_factory_));

for (int j = 0; j < message->health_check(i).health_checks_size(); j++) {
// Creating HealthCheckers
health_checkers_.push_back(Upstream::HealthCheckerFactory::create(
cluster_config.health_checks(j), *hds_clusters_[i], runtime_, random_, dispatcher_));
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method looks right to me now, thanks.


// TODO(lilika): Add support for subsequent HealthCheckSpecifier messages that
// might modify the HdsClusters
void HdsDelegate::onReceiveMessage(
std::unique_ptr<envoy::service::discovery::v2::HealthCheckSpecifier>&& message) {
ENVOY_LOG(debug, "New health check response ", message->DebugString());
stats_.requests_.inc();
stream_->sendMessage(health_check_request_, false);
stats_.responses_.inc();
ENVOY_LOG(debug, "New health check response message {} ", message->DebugString());

// Process the HealthCheckSpecifier message
processMessage(std::move(message));

// Initializing HealthCheckers
for (auto& health_checker : health_checkers_) {
health_checker->start();
}

server_response_ms_ = PROTOBUF_GET_MS_REQUIRED(*message, interval);
setServerResponseTimer();
}

void HdsDelegate::onReceiveTrailingMetadata(Http::HeaderMapPtr&& metadata) {
Expand All @@ -68,10 +164,82 @@ void HdsDelegate::onReceiveTrailingMetadata(Http::HeaderMapPtr&& metadata) {

void HdsDelegate::onRemoteClose(Grpc::Status::GrpcStatus status, const std::string& message) {
ENVOY_LOG(warn, "gRPC config stream closed: {}, {}", status, message);
response_timer_->disableTimer();
server_response_timer_->disableTimer();
stream_ = nullptr;
handleFailure();
}

HdsCluster::HdsCluster(Runtime::Loader& runtime, const envoy::api::v2::Cluster& cluster,
const envoy::api::v2::core::BindConfig& bind_config, Stats::Store& stats,
Ssl::ContextManager& ssl_context_manager,
Secret::SecretManager& secret_manager, bool added_via_api,
ClusterInfoFactory& info_factory)
: runtime_(runtime), cluster_(cluster), bind_config_(bind_config), stats_(stats),
ssl_context_manager_(ssl_context_manager), secret_manager_(secret_manager),
added_via_api_(added_via_api), initial_hosts_(new HostVector()) {
ENVOY_LOG(debug, "Creating an HdsCluster");
priority_set_.getOrCreateHostSet(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to maintain priority levels or localities, so no need for a priority set. You just want a single HostSetImpl for all the hosts in the cluster AFAICT.


info_ = info_factory.createHdsClusterInfo(runtime_, cluster_, bind_config_, stats_,
ssl_context_manager_, secret_manager_, added_via_api_);

for (const auto& host : cluster.hosts()) {
initial_hosts_->emplace_back(HostSharedPtr{new HostImpl(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/initial_hosts_/hosts_/ i.e. this is the main data structure you need to maintain in HdsCluster as per above comment.

info_, "", resolveProtoAddress2(host), envoy::api::v2::core::Metadata::default_instance(),
1, envoy::api::v2::core::Locality().default_instance(),
envoy::api::v2::endpoint::Endpoint::HealthCheckConfig().default_instance())});
}
initialize([] {});
}

ClusterSharedPtr HdsCluster::create() { NOT_IMPLEMENTED; }

HostVectorConstSharedPtr HdsCluster::createHealthyHostList(const HostVector& hosts) {
HostVectorSharedPtr healthy_list(new HostVector());
for (const auto& host : hosts) {
if (host->healthy()) {
healthy_list->emplace_back(host);
}
}
return healthy_list;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be an empty nop returning nullptr?

}

ClusterInfoConstSharedPtr RealClusterInfoFactory::createHdsClusterInfo(
Runtime::Loader& runtime, const envoy::api::v2::Cluster& cluster,
const envoy::api::v2::core::BindConfig& bind_config, Stats::Store& stats,
Ssl::ContextManager& ssl_context_manager, Secret::SecretManager& secret_manager,
bool added_via_api) {

return std::make_unique<ClusterInfoImpl>(cluster, bind_config, runtime, stats,
ssl_context_manager, secret_manager, added_via_api);
}

HostsPerLocalityConstSharedPtr HdsCluster::createHealthyHostLists(const HostsPerLocality& hosts) {
return hosts.filter([](const Host& host) { return host.healthy(); });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be an empty nop returning nullptr?

}

void HdsCluster::initialize(std::function<void()> callback) {
ASSERT(initialization_complete_callback_ == nullptr);
initialization_complete_callback_ = callback;
for (const auto& host : *initial_hosts_) {
host->healthFlagSet(Host::HealthFlag::FAILED_ACTIVE_HC);
}

auto& first_host_set = priority_set_.getOrCreateHostSet(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the second half of this method.

auto healthy = createHealthyHostList(*initial_hosts_);
ENVOY_LOG(debug, "About to update the priority set.");
first_host_set.updateHosts(initial_hosts_, healthy, HostsPerLocalityImpl::empty(),
HostsPerLocalityImpl::empty(), {}, *initial_hosts_, {});
initial_hosts_ = nullptr;
ENVOY_LOG(debug, "Updated the priority set.");
}

const Network::Address::InstanceConstSharedPtr
HdsCluster::resolveProtoAddress2(const envoy::api::v2::core::Address& address) {
return Network::Address::resolveProtoAddress(address);
}

void HdsCluster::setOutlierDetector(const Outlier::DetectorSharedPtr&) { NOT_IMPLEMENTED; }

} // namespace Upstream
} // namespace Envoy
Loading