Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
6dcb8de
Add cluster factory interface and implementation for the existing clu…
HenryYYang Feb 18, 2019
1ac5471
Add configurable factory
HenryYYang Feb 20, 2019
b4253c2
Fix format issues
HenryYYang Feb 20, 2019
3e056bb
make cluster type oneof
HenryYYang Feb 21, 2019
f5420ee
Fix format error.
HenryYYang Feb 21, 2019
d3a9004
Add integration tests
HenryYYang Feb 27, 2019
759e505
Updated comments and docs.
HenryYYang Feb 27, 2019
789316a
Merge branch 'master' into add-cluster-extension
HenryYYang Feb 28, 2019
e7b1625
Merge remote-tracking branch 'origin' into add-cluster-extension
HenryYYang Feb 28, 2019
ef1f54a
remove TestBase from new tests
HenryYYang Feb 28, 2019
cb3e0eb
Merge branch 'add-cluster-extension' of github.com:HenryYYang/envoy i…
HenryYYang Feb 28, 2019
35b2c86
fix formatting
HenryYYang Feb 28, 2019
b3c41e2
fix formatting
HenryYYang Feb 28, 2019
a5e19da
fix formatting
HenryYYang Feb 28, 2019
5311662
fix clang tidy
HenryYYang Feb 28, 2019
6634824
fix typo
HenryYYang Feb 28, 2019
587b1d0
fix clang-tidy
HenryYYang Feb 28, 2019
ff123bf
Merge branch 'master' of github.com:envoyproxy/envoy into add-cluster…
HenryYYang Feb 28, 2019
d16d0b9
delete deprecated api
HenryYYang Mar 1, 2019
b82e014
Fix PR feedbacks
HenryYYang Mar 2, 2019
0cf38a8
Fix PR feedbacks
HenryYYang Mar 4, 2019
506f51b
Merge branch 'master' into add-cluster-extension
HenryYYang Mar 4, 2019
f75d362
Remove TestBase
HenryYYang Mar 5, 2019
d51e41a
Fix PR feedbacks
HenryYYang Mar 5, 2019
6ccc257
Fix missing import
HenryYYang Mar 5, 2019
0cb3806
Fix duplicate registration
HenryYYang Mar 6, 2019
1716d48
Split implementation and registration of custom static cluster out of…
HenryYYang Mar 6, 2019
735524d
fix format
HenryYYang Mar 6, 2019
b06aca8
remove CUSTOM_CLUSTER_CONFIG
HenryYYang Mar 7, 2019
0a53ccb
Kick CI
HenryYYang Mar 8, 2019
661875e
Merge branch 'master' into add-redis-cluster
HenryYYang Mar 8, 2019
72acffa
Add redis cluster
HenryYYang Mar 26, 2019
fe83017
Add redis cluster test
HenryYYang Mar 31, 2019
b25de9f
Support ipv6
HenryYYang Mar 31, 2019
e95f67e
add version history
HenryYYang Apr 1, 2019
f51b36a
Merge branch 'master' into add-redis-cluster
HenryYYang Apr 1, 2019
c186184
Kick CI
HenryYYang Apr 3, 2019
a30136b
Merge branch 'master' into add-redis-cluster
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 5, 2019
8027e1e
docs
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 8, 2019
e42cac4
Merge branch 'master' into add-redis-cluster
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 8, 2019
dabacd1
make docs work zomg
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 8, 2019
9a8c5ff
fix compile error
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 10, 2019
d2c4606
mitch comments
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 10, 2019
96bbf69
fix issue
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 10, 2019
6738ca9
extra protection on cancels
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 10, 2019
385a6a5
Revert "extra protection on cancels"
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 11, 2019
ae24a89
respond to mitch and matt comments
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 11, 2019
e20db9a
fix spelling
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 11, 2019
354d635
Merge branch 'master' into add-redis-cluster
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 11, 2019
6535c6e
Merge branch 'master' into add-redis-cluster
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 12, 2019
1bb84fb
Update docs per matt comments, put a function in an anonymous namespace
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 12, 2019
d0d73bb
add test for cluster factory exception pass and fail cases
FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg Apr 15, 2019
098ccd2
Add integration test
HenryYYang Apr 25, 2019
7a2eb43
Merge branch 'add-redis-cluster' of github.com:HenryYYang/envoy into …
HenryYYang Apr 25, 2019
c35d0b5
Merge branch 'master' into add-redis-cluster
HenryYYang Apr 25, 2019
97f16fe
Fix merge issues
HenryYYang Apr 26, 2019
169fe5d
Fix clang_tidy errors
HenryYYang Apr 26, 2019
71209e2
Add more robust error checking.
HenryYYang Apr 29, 2019
dab3be9
Add more test for cluster slots response
HenryYYang May 2, 2019
3f1bc38
delete twemproxy from dictionary
HenryYYang May 2, 2019
569b693
Small refactor of the RedisCluster class
HenryYYang May 2, 2019
152e1ab
Merge branch 'master' into add-redis-cluster
HenryYYang May 2, 2019
f746acf
Fix code review feedbacks
HenryYYang May 2, 2019
db280e3
Fix code review feedback.
HenryYYang May 3, 2019
710c915
Fix redis cluster test
HenryYYang May 3, 2019
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
1 change: 1 addition & 0 deletions api/docs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ proto_library(
"//envoy/config/accesslog/v2:als",
"//envoy/config/accesslog/v2:file",
"//envoy/config/bootstrap/v2:bootstrap",
"//envoy/config/cluster/redis:redis_cluster",
"//envoy/config/common/tap/v2alpha:common",
"//envoy/config/filter/accesslog/v2:accesslog",
"//envoy/config/filter/dubbo/router/v2alpha1:router",
Expand Down
8 changes: 8 additions & 0 deletions api/envoy/config/cluster/redis/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_library_internal")

licenses(["notice"]) # Apache 2

api_proto_library_internal(
name = "redis_cluster",
srcs = ["redis_cluster.proto"],
)
54 changes: 54 additions & 0 deletions api/envoy/config/cluster/redis/redis_cluster.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
syntax = "proto3";

package envoy.config.cluster.redis;

option java_outer_classname = "RedisClusterProto";
option java_multiple_files = true;
option java_package = "io.envoyproxy.envoy.config.cluster.redis";
option go_package = "v2";

import "google/protobuf/duration.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

// [#protodoc-title: Redis Cluster Configuration]
// This cluster adds support for `Redis Cluster <https://redis.io/topics/cluster-spec>`_, as part
// of :ref:`Envoy's support for Redis Cluster <arch_overview_redis>`.
//
// Redis Cluster is an extension of Redis which supports sharding and high availability (where a
// shard that loses its master fails over to a replica, and designates it as the new master).
// However, as there is no unified frontend or proxy service in front of Redis Cluster, the client
// (in this case Envoy) must locally maintain the state of the Redis Cluster, specifically the
// topology. A random node in the cluster is queried for the topology using the `CLUSTER SLOTS
// command <https://redis.io/commands/cluster-slots>`_. This result is then stored locally, and
// updated at user-configured intervals.
//
// Example:
//
// .. code-block:: yaml
//
// name: name
// connect_timeout: 0.25s
// dns_lookup_family: V4_ONLY
// hosts:
// - socket_address:
// address: foo.bar.com
// port_value: 22120
// cluster_type:
// name: envoy.clusters.redis
// typed_config:
// "@type": type.googleapis.com/google.protobuf.Struct
// value:
// cluster_refresh_rate: 30s
// cluster_refresh_timeout: 0.5s

message RedisClusterConfig {
// Interval between successive topology refresh requests. If not set, this defaults to 5s.
google.protobuf.Duration cluster_refresh_rate = 1
[(validate.rules).duration.gt = {}, (gogoproto.stdduration) = true];

// Timeout for topology refresh request. If not set, this defaults to 3s.
google.protobuf.Duration cluster_refresh_timeout = 2
[(validate.rules).duration.gt = {}, (gogoproto.stdduration) = true];
}
1 change: 1 addition & 0 deletions docs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ PROTO_RST="
/envoy/config/accesslog/v2/als/envoy/config/accesslog/v2/als.proto.rst
/envoy/config/accesslog/v2/file/envoy/config/accesslog/v2/file.proto.rst
/envoy/config/bootstrap/v2/bootstrap/envoy/config/bootstrap/v2/bootstrap.proto.rst
/envoy/config/cluster/redis/redis_cluster/envoy/config/cluster/redis/redis_cluster.proto.rst
/envoy/config/common/tap/v2alpha/common/envoy/config/common/tap/v2alpha/common.proto.rst
/envoy/config/ratelimit/v2/rls/envoy/config/ratelimit/v2/rls.proto.rst
/envoy/config/metrics/v2/metrics_service/envoy/config/metrics/v2/metrics_service.proto.rst
Expand Down
8 changes: 8 additions & 0 deletions docs/root/api-v2/config/cluster/cluster.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Cluster
=======

.. toctree::
:glob:
:maxdepth: 1

redis/*
1 change: 1 addition & 0 deletions docs/root/api-v2/config/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Extensions
transport_socket/transport_socket
resource_monitor/resource_monitor
common/common
cluster/cluster
22 changes: 22 additions & 0 deletions docs/root/intro/arch_overview/redis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ If passive healthchecking is desired, also configure
For the purposes of passive healthchecking, connect timeouts, command timeouts, and connection
close map to 5xx. All other responses from Redis are counted as a success.

Redis Cluster Support (Experimental)
----------------------------------------

Envoy currently offers experimental support for `Redis Cluster <https://redis.io/topics/cluster-spec>`_.

When using Envoy as a sidecar proxy for a Redis Cluster, the service can use a non-cluster Redis client
implemented in any language to connect to the proxy as if it's a single node Redis instance.
The Envoy proxy will keep track of the cluster topology and send commands to the correct Redis node in the
cluster according to the `spec <https://redis.io/topics/cluster-spec>`_. Advance features such as reading
from replicas can also be added to the Envoy proxy instead of updating redis clients in each language.

Envoy proxy tracks the topology of the cluster by sending periodic
`cluster slots <https://redis.io/commands/cluster-slots>`_ commands to a random node in the cluster, and maintains the
following information:

* List of known nodes.
* The masters for each shard.
* Nodes entering or leaving the cluster.

For topology configuration details, see the Redis Cluster
:ref:`v2 API reference <envoy_api_msg_config.cluster.redis.RedisClusterConfig>`.

Supported commands
------------------

Expand Down
1 change: 1 addition & 0 deletions docs/root/intro/version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Version history
* hot restart: stats are no longer shared between hot restart parent/child via shared memory, but rather by RPC. Hot restart version incremented to 11.
* http: mitigated a race condition with the :ref:`delayed_close_timeout<envoy_api_field_config.filter.network.http_connection_manager.v2.HttpConnectionManager.delayed_close_timeout>` where it could trigger while actively flushing a pending write buffer for a downstream connection.
* jwt_authn: make filter's parsing of JWT more flexible, allowing syntax like ``jwt=eyJhbGciOiJS...ZFnFIw,extra=7,realm=123``
* redis: add support for Redis cluster custom cluster type.
* redis: added :ref:`prefix routing <envoy_api_field_config.filter.network.redis_proxy.v2.RedisProxy.prefix_routes>` to enable routing commands based on their key's prefix to different upstream.
* redis: add support for zpopmax and zpopmin commands.
* redis: added
Expand Down
14 changes: 1 addition & 13 deletions source/common/upstream/logical_dns_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,7 @@ LogicalDnsCluster::LogicalDnsCluster(
}
}

switch (cluster.dns_lookup_family()) {
case envoy::api::v2::Cluster::V6_ONLY:
dns_lookup_family_ = Network::DnsLookupFamily::V6Only;
break;
case envoy::api::v2::Cluster::V4_ONLY:
dns_lookup_family_ = Network::DnsLookupFamily::V4Only;
break;
case envoy::api::v2::Cluster::AUTO:
dns_lookup_family_ = Network::DnsLookupFamily::Auto;
break;
default:
NOT_REACHED_GCOVR_EXCL_LINE;
}
dns_lookup_family_ = getDnsLookupFamilyFromCluster(cluster);

const envoy::api::v2::core::SocketAddress& socket_address =
lbEndpoint().endpoint().address().socket_address();
Expand Down
28 changes: 14 additions & 14 deletions source/common/upstream/upstream_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1288,20 +1288,7 @@ StrictDnsClusterImpl::StrictDnsClusterImpl(
local_info_(factory_context.localInfo()), dns_resolver_(dns_resolver),
dns_refresh_rate_ms_(
std::chrono::milliseconds(PROTOBUF_GET_MS_OR_DEFAULT(cluster, dns_refresh_rate, 5000))) {
switch (cluster.dns_lookup_family()) {
case envoy::api::v2::Cluster::V6_ONLY:
dns_lookup_family_ = Network::DnsLookupFamily::V6Only;
break;
case envoy::api::v2::Cluster::V4_ONLY:
dns_lookup_family_ = Network::DnsLookupFamily::V4Only;
break;
case envoy::api::v2::Cluster::AUTO:
dns_lookup_family_ = Network::DnsLookupFamily::Auto;
break;
default:
NOT_REACHED_GCOVR_EXCL_LINE;
}

dns_lookup_family_ = getDnsLookupFamilyFromCluster(cluster);
const envoy::api::v2::ClusterLoadAssignment load_assignment(
cluster.has_load_assignment() ? cluster.load_assignment()
: Config::Utility::translateClusterHosts(cluster.hosts()));
Expand All @@ -1320,6 +1307,19 @@ StrictDnsClusterImpl::StrictDnsClusterImpl(
load_assignment.policy(), overprovisioning_factor, kDefaultOverProvisioningFactor);
}

Network::DnsLookupFamily getDnsLookupFamilyFromCluster(const envoy::api::v2::Cluster& cluster) {
switch (cluster.dns_lookup_family()) {
case envoy::api::v2::Cluster::V6_ONLY:
return Network::DnsLookupFamily::V6Only;
case envoy::api::v2::Cluster::V4_ONLY:
return Network::DnsLookupFamily::V4Only;
case envoy::api::v2::Cluster::AUTO:
return Network::DnsLookupFamily::Auto;
default:
NOT_REACHED_GCOVR_EXCL_LINE;
}
}

void StrictDnsClusterImpl::startPreInit() {
for (const ResolveTargetPtr& target : resolve_targets_) {
target->startResolve();
Expand Down
5 changes: 5 additions & 0 deletions source/common/upstream/upstream_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,11 @@ class BaseDynamicClusterImpl : public ClusterImplBase {
HostMap& updated_hosts, const HostMap& all_hosts);
};

/**
* Utility function to get Dns from cluster.
*/
Network::DnsLookupFamily getDnsLookupFamilyFromCluster(const envoy::api::v2::Cluster& cluster);

/**
* Implementation of Upstream::Cluster that does periodic DNS resolution and updates the host
* member set if the DNS members change.
Expand Down
40 changes: 40 additions & 0 deletions source/extensions/clusters/redis/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
licenses(["notice"]) # Apache 2

load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_package",
)

envoy_package()

envoy_cc_library(
name = "redis_cluster",
srcs = [
"redis_cluster.cc",
"redis_cluster.h",
],
deps = [
"//include/envoy/api:api_interface",
"//include/envoy/http:codec_interface",
"//include/envoy/upstream:cluster_factory_interface",
"//include/envoy/upstream:cluster_manager_interface",
"//include/envoy/upstream:upstream_interface",
"//source/common/config:metadata_lib",
"//source/common/event:dispatcher_lib",
"//source/common/json:config_schemas_lib",
"//source/common/json:json_loader_lib",
"//source/common/network:utility_lib",
"//source/common/singleton:manager_impl_lib",
"//source/common/upstream:cluster_factory_lib",
"//source/common/upstream:upstream_includes",
"//source/common/upstream:upstream_lib",
"//source/extensions/clusters:well_known_names",
"//source/extensions/filters/network/common/redis:client_interface",
"//source/extensions/filters/network/common/redis:client_lib",
"//source/extensions/filters/network/common/redis:codec_interface",
"//source/extensions/transport_sockets/raw_buffer:config",
"//source/server:transport_socket_config_lib",
"@envoy_api//envoy/config/cluster/redis:redis_cluster_cc",
],
)
Loading