-
Notifications
You must be signed in to change notification settings - Fork 5.5k
implement rds api #464
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
implement rds api #464
Changes from 2 commits
b3c48b3
6ad8955
c8ec260
d2f8aba
77b9d36
1765042
acf3a58
6063d35
133dc1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| .. _config_http_conn_man_rds: | ||
|
|
||
| Route discovery service | ||
| ======================= | ||
|
|
||
| The route discovery service (RDS) API is an optional API that Envoy will call to dynamically fetch | ||
| route tables. Each :ref:`HTTP connection manager filter <config_http_conn_man>` can independently | ||
|
Member
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. s/route tables/HTTP route entries/ for clarity ?
Member
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. Or even better: dynamically fetch configurations for virtual hosts and routes within the virtual host. |
||
| fetch its own route table via the API. | ||
|
|
||
| .. code-block:: json | ||
|
|
||
| { | ||
| "cluster": "{...}", | ||
| "route_config_name": "...", | ||
| "refresh_interval_ms": "..." | ||
| } | ||
|
|
||
| cluster | ||
| *(required, string)* The name of an upstream :ref:`cluster <config_cluster_manager_cluster>` that | ||
| hosts the route discovery service. The cluster must run a REST service that implements the | ||
| :ref:`RDS HTTP API <config_http_conn_man_rds_api>`. | ||
|
|
||
| route_config_name | ||
| *(required, string)* The name of the route table. This name will be passed to the | ||
| :ref:`RDS HTTP API <config_http_conn_man_rds_api>` so that different route tables can be used by | ||
|
Contributor
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. What does it mean to be used by independent filters?
Member
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. I think you meant independent listeners? |
||
| independent filters. | ||
|
|
||
| refresh_interval_ms | ||
| *(optional, integer)* The delay, in milliseconds, between fetches to the RDS API. Envoy will add | ||
| an additional random jitter to the delay that is between zero and *refresh_interval_ms* | ||
| milliseconds. Thus the longest possible refresh delay is 2 \* *refresh_interval_ms*. Default | ||
| value is 30000ms (30 seconds). | ||
|
|
||
| .. _config_http_conn_man_rds_api: | ||
|
|
||
| REST API | ||
| -------- | ||
|
|
||
| .. http:get:: /v1/routes/(string: route_config_name)/(string: service_cluster)/(string: service_node) | ||
|
|
||
| Asks the discovery service to return the route table for a particular `route_config_name`, | ||
| `service_cluster`, and `service_node`. `route_config_name` corresponds to the RDS configuration | ||
| parameter above. `service_cluster` corresponds to the :option:`--service-cluster` CLI option. | ||
| `service_node` corresponds to the :option:`--service-node` CLI option. Responses are a single JSON | ||
| object that contains a route table as defined in the :ref:`route table documentation | ||
| <config_http_conn_man_route_table>`. | ||
|
|
||
| A new route table will be gracefully swapped in such that existing requests are not effected. | ||
|
|
||
| .. attention:: | ||
|
|
||
| Route tables that are loaded via RDS are *not* checked to see if referenced clusters are known | ||
| to the :ref:`cluster manager <config_cluster_manager>`. The RDS API has been designed to work | ||
| alongside the :ref:`CDS API <config_cluster_manager_cds>` such that Envoy assumes eventually | ||
| consistent updates. If a route references an unknown cluster a 404 response will be returned by | ||
| the router filter. | ||
|
|
||
| Statistics | ||
| ---------- | ||
|
|
||
| RDS has a statistics tree rooted at *http.<stat_prefix>.rds.* with the following statistics: | ||
|
|
||
| .. csv-table:: | ||
| :header: Name, Type, Description | ||
| :widths: 1, 1, 2 | ||
|
|
||
| config_reload, Counter, Total API fetches that resulted in a config reload due to a different config | ||
| update_attempt, Counter, Total API fetches attempted | ||
| update_success, Counter, Total API fetches completed successfully | ||
| update_failure, Counter, Total API fetches that failed (either network or schema errors) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/router/router.h" | ||
|
|
||
| namespace Router { | ||
|
|
||
| /** | ||
| * A provider for constant route configurations. | ||
| */ | ||
| class RouteConfigProvider { | ||
| public: | ||
| virtual ~RouteConfigProvider() {} | ||
|
|
||
| /** | ||
| * @return Router::ConfigPtr a route configuration for use during a single request. The returned | ||
| * config may be different on a subsequent call so a new config should be acquired for | ||
|
Contributor
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. comma before so |
||
| * each request flow. | ||
| */ | ||
| virtual Router::ConfigPtr config() PURE; | ||
| }; | ||
|
|
||
| typedef std::unique_ptr<RouteConfigProvider> RouteConfigProviderPtr; | ||
|
|
||
| } // Router | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,23 @@ const std::string Json::Schema::CLIENT_SSL_NETWORK_FILTER_SCHEMA(R"EOF( | |
| } | ||
| )EOF"); | ||
|
|
||
| const std::string Json::Schema::RDS_CONFIGURATION_SCHEMA(R"EOF( | ||
| { | ||
| "$schema": "http://json-schema.org/schema#", | ||
| "properties" : { | ||
| "cluster" : {"type": "string"}, | ||
| "route_config_name" : {"type": "string"}, | ||
| "refresh_interval_ms" : { | ||
| "type" : "integer", | ||
| "minimum" : 0, | ||
| "exclusiveMinimum" : true | ||
| } | ||
| }, | ||
| "required" : ["cluster", "route_config_name"], | ||
| "additionalProperties" : false | ||
| } | ||
| )EOF"); | ||
|
|
||
| const std::string Json::Schema::HTTP_CONN_NETWORK_FILTER_SCHEMA(R"EOF( | ||
| { | ||
| "$schema": "http://json-schema.org/schema#", | ||
|
|
@@ -201,6 +218,7 @@ const std::string Json::Schema::HTTP_CONN_NETWORK_FILTER_SCHEMA(R"EOF( | |
| "enum" : ["http1", "http2", "auto"] | ||
| }, | ||
| "stat_prefix" : {"type" : "string"}, | ||
| "rds" : {"type": "object"}, | ||
| "route_config" : {"type": "object"}, | ||
| "filters" : { | ||
| "type" : "array", | ||
|
|
@@ -242,7 +260,7 @@ const std::string Json::Schema::HTTP_CONN_NETWORK_FILTER_SCHEMA(R"EOF( | |
| "use_remote_address" : {"type" : "boolean"}, | ||
| "generate_request_id" : {"type" : "boolean"} | ||
| }, | ||
| "required" : ["codec_type", "stat_prefix", "route_config", "filters"], | ||
| "required" : ["codec_type", "stat_prefix", "filters"], | ||
|
Contributor
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. I think you should keep route_config. At line 222, it only checks for an object, so empty will pass. And the documentation above makes it seem like it should always be there.
Member
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. @ccaraman if that line in the documentation is removed, it aligns well with the rest of the checks in rds_impl.cc. WDYT?
Member
Author
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. It's not required anymore. I'm fixing the docs. |
||
| "additionalProperties" : false | ||
| } | ||
| )EOF"); | ||
|
|
||
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.
I would remove this line. It sounds like if you use rds, you still need a dummy empty route_config block