-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Merged
Merged
implement rds api #464
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b3c48b3
implement rds api
mattklein123 6ad8955
fix
mattklein123 c8ec260
Merge branch 'master' into rds
mattklein123 d2f8aba
comments
mattklein123 77b9d36
config: rename refresh_interval_ms -> refresh_delay_ms
mattklein123 1765042
comment
mattklein123 acf3a58
Merge remote-tracking branch 'origin/master' into rds
mattklein123 6063d35
comment
mattklein123 133dc1c
comment
mattklein123 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 hidden or 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 hidden or 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 hidden or 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,81 @@ | ||
| .. _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 | ||
| :ref:`route configurations <config_http_conn_man_route_table>`. A route configuration includes both | ||
| HTTP header modifications, virtual hosts, and the individual route entries contained within each | ||
| virtual host. Each :ref:`HTTP connection manager filter <config_http_conn_man>` can independently | ||
| fetch its own route configuration via the API. | ||
|
|
||
| .. code-block:: json | ||
|
|
||
| { | ||
| "cluster": "...", | ||
| "route_config_name": "...", | ||
| "refresh_delay_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>`. NOTE: This is the *name* of a cluster defined | ||
| in the :ref:`cluster manager <config_cluster_manager>` configuration, not the full definition of | ||
| a cluster as in the case of SDS and CDS. | ||
|
|
||
| route_config_name | ||
| *(required, string)* The name of the route configuration. This name will be passed to the | ||
| :ref:`RDS HTTP API <config_http_conn_man_rds_api>`. This allows an Envoy configuration with | ||
| multiple HTTP listeners (and associated HTTP connection manager filters) to use different route | ||
| configurations. | ||
|
|
||
| refresh_delay_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_delay_ms* | ||
| milliseconds. Thus the longest possible refresh delay is 2 \* *refresh_delay_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 route discovery service to return the route configuration 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 configuration as defined in the :ref:`route configuration | ||
| documentation <config_http_conn_man_route_table>`. | ||
|
|
||
| A new route configuration will be gracefully swapped in such that existing requests are not | ||
| affected. This means that when a request starts, it sees a consistent snapshot of the route | ||
| configuration that does not change for the duration of the request. Thus, if an update changes a | ||
| timeout for example, only new requests will use the updated timeout value. | ||
|
|
||
| As a performance optimization, Envoy hashes the route configuration it receives from the RDS API and | ||
| will only perform a full reload if the hash value changes. | ||
|
|
||
| .. attention:: | ||
|
|
||
| Route configurations 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) |
This file contains hidden or 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 hidden or 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,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 | ||
| * each request flow. | ||
| */ | ||
| virtual Router::ConfigPtr config() PURE; | ||
| }; | ||
|
|
||
| typedef std::unique_ptr<RouteConfigProvider> RouteConfigProviderPtr; | ||
|
|
||
| } // Router |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
I just realized that CLIENT_SSL_NETWORK_FILTER_SCHEMA doesn't have
refresh_delay_ms. Can you please add that?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.
fixed