Skip to content
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

config: making v2-config-only a boolean flag #3847

Merged
merged 3 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 DEPRECATED.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A logged warning is expected for each deprecated item that is in deprecation win
Prior to 1.8.0, Envoy can use either proto to send client requests to a ratelimit server with the use of the
`use_data_plane_proto` boolean flag in the [ratelimit configuration](https://github.com/envoyproxy/envoy/blob/master/api/envoy/config/ratelimit/v2/rls.proto).
However, when using the deprecated client a warning is logged.
* Use of the --v2-config-only flag.

## Version 1.7.0

Expand Down
7 changes: 2 additions & 5 deletions docs/root/configuration/overview/v2_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ flag, i.e.:

.. code-block:: console

./envoy -c <path to config>.{json,yaml,pb,pb_text} --v2-config-only
./envoy -c <path to config>.{json,yaml,pb,pb_text}

where the extension reflects the underlying v2 config representation. The
:option:`--v2-config-only` flag is not strictly required as Envoy will attempt
to autodetect the config file version, but this option provides an enhanced
debug experience when configuration parsing fails.
where the extension reflects the underlying v2 config representation.

The :ref:`Bootstrap <envoy_api_msg_config.bootstrap.v2.Bootstrap>` message is the root of the
configuration. A key concept in the :ref:`Bootstrap <envoy_api_msg_config.bootstrap.v2.Bootstrap>`
Expand Down
2 changes: 1 addition & 1 deletion docs/root/intro/version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Version history
to filter based on the presence of Envoy response flags.
* admin: added :http:get:`/hystrix_event_stream` as an endpoint for monitoring envoy's statistics
through `Hystrix dashboard <https://github.com/Netflix-Skunkworks/hystrix-dashboard/wiki>`_.
* config: v1 disabled by default. v1 support remains available until October via flipping --v2-config-only=false.
* config: v1 disabled by default. v1 support remains available until October via setting :option:`--allow-deprecated-v1-api`.
* health check: added support for :ref:`custom health check <envoy_api_field_core.HealthCheck.custom_health_check>`.
* health check: added support for :ref:`specifying jitter as a percentage <envoy_api_field_core.HealthCheck.interval_jitter_percent>`.
* health_check: added support for :ref:`health check event logging <arch_overview_health_check_logging>`.
Expand Down
11 changes: 8 additions & 3 deletions docs/root/operations/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ following are the command line options that Envoy supports.
*(optional)* The path to the v1 or v2 :ref:`JSON/YAML/proto3 configuration
file <config>`. If this flag is missing, :option:`--config-yaml` is required.
This will be parsed as a :ref:`v2 bootstrap configuration file
<config_overview_v2_bootstrap>` and on failure, subject to
:option:`--v2-config-only`, will be considered as a :ref:`v1 JSON
<config_overview_v2_bootstrap>`. On failure, if :option:`--allow-deprecated-v1-api`,
is set, it will be considered as a :ref:`v1 JSON
configuration file <config_overview_v1>`. For v2 configuration files, valid
extensions are ``.json``, ``.yaml``, ``.pb`` and ``.pb_text``, which indicate
JSON, YAML, `binary proto3
Expand All @@ -34,9 +34,14 @@ following are the command line options that Envoy supports.

.. option:: --v2-config-only

*(deprecated)* This flag used to allow opting into only using a
:ref:`v2 bootstrap configuration file <config_overview_v2_bootstrap>`. This is now set by default.

.. option:: --allow-deprecated-v1-api

*(optional)* This flag determines whether the configuration file should only
be parsed as a :ref:`v2 bootstrap configuration file
<config_overview_v2_bootstrap>`. If false (default), when a v2 bootstrap
<config_overview_v2_bootstrap>`. If specified when a v2 bootstrap
config parse fails, a second attempt to parse the config as a :ref:`v1 JSON
configuration file <config_overview_v1>` will be made.

Expand Down
10 changes: 8 additions & 2 deletions source/server/options_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ OptionsImpl::OptionsImpl(int argc, const char* const* argv,
TCLAP::ValueArg<std::string> config_yaml(
"", "config-yaml", "Inline YAML configuration, merges with the contents of --config-path",
false, "", "string", cmd);
TCLAP::SwitchArg v2_config_only("", "v2-config-only", "parse config as v2 only", cmd, true);

// Deprecated and unused.
TCLAP::SwitchArg v2_config_only("", "v2-config-only", "deprecated", cmd, true);

TCLAP::SwitchArg allow_v1_config("", "allow-deprecated-v1-api", "allow use of legacy v1 config",
cmd, false);

TCLAP::ValueArg<std::string> admin_address_path("", "admin-address-path", "Admin address path",
false, "", "string", cmd);
TCLAP::ValueArg<std::string> local_address_ip_version("", "local-address-ip-version",
Expand Down Expand Up @@ -177,7 +183,7 @@ OptionsImpl::OptionsImpl(int argc, const char* const* argv,
concurrency_ = concurrency.getValue();
config_path_ = config_path.getValue();
config_yaml_ = config_yaml.getValue();
v2_config_only_ = v2_config_only.getValue();
v2_config_only_ = !allow_v1_config.getValue();
admin_address_path_ = admin_address_path.getValue();
log_path_ = log_path.getValue();
restart_epoch_ = restart_epoch.getValue();
Expand Down
23 changes: 22 additions & 1 deletion test/server/options_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,27 @@ TEST(OptionsImplTest, InvalidCommandLine) {
"Couldn't find match for argument");
}

TEST(OptionsImplTest, v1Allowed) {
std::unique_ptr<OptionsImpl> options = createOptionsImpl(
"envoy --mode validate --concurrency 2 -c hello --admin-address-path path --restart-epoch 1 "
"--local-address-ip-version v6 -l info --service-cluster cluster --service-node node "
"--service-zone zone --file-flush-interval-msec 9000 --drain-time-s 60 --log-format [%v] "
"--parent-shutdown-time-s 90 --log-path /foo/bar --allow-deprecated-v1-api "
"--disable-hot-restart");
EXPECT_EQ(Server::Mode::Validate, options->mode());
EXPECT_FALSE(options->v2ConfigOnly());
}

TEST(OptionsImplTest, v1Disallowed) {
std::unique_ptr<OptionsImpl> options = createOptionsImpl(
"envoy --mode validate --concurrency 2 -c hello --admin-address-path path --restart-epoch 1 "
"--local-address-ip-version v6 -l info --service-cluster cluster --service-node node "
"--service-zone zone --file-flush-interval-msec 9000 --drain-time-s 60 --log-format [%v] "
"--parent-shutdown-time-s 90 --log-path /foo/bar --disable-hot-restart");
EXPECT_EQ(Server::Mode::Validate, options->mode());
EXPECT_TRUE(options->v2ConfigOnly());
}

TEST(OptionsImplTest, All) {
std::unique_ptr<OptionsImpl> options = createOptionsImpl(
"envoy --mode validate --concurrency 2 -c hello --admin-address-path path --restart-epoch 1 "
Expand All @@ -69,7 +90,7 @@ TEST(OptionsImplTest, All) {
EXPECT_EQ(Server::Mode::Validate, options->mode());
EXPECT_EQ(2U, options->concurrency());
EXPECT_EQ("hello", options->configPath());
EXPECT_FALSE(options->v2ConfigOnly());
EXPECT_TRUE(options->v2ConfigOnly());
EXPECT_EQ("path", options->adminAddressPath());
EXPECT_EQ(Network::Address::IpVersion::v6, options->localAddressIpVersion());
EXPECT_EQ(1U, options->restartEpoch());
Expand Down