From abd06be1f7c377d1c5de44b3723b490eb803231a Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Thu, 12 Jul 2018 09:24:11 -0400 Subject: [PATCH 1/3] Making v2-config-only a boolean flag Signed-off-by: Alyssa Wilk --- .../configuration/overview/v2_overview.rst | 7 ++---- docs/root/intro/version_history.rst | 2 +- docs/root/operations/cli.rst | 4 ++-- source/server/options_impl.cc | 4 +++- test/server/options_impl_test.cc | 22 ++++++++++++++++++- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/docs/root/configuration/overview/v2_overview.rst b/docs/root/configuration/overview/v2_overview.rst index f67e2ceb46292..feb1032a4d4a1 100644 --- a/docs/root/configuration/overview/v2_overview.rst +++ b/docs/root/configuration/overview/v2_overview.rst @@ -37,12 +37,9 @@ flag, i.e.: .. code-block:: console - ./envoy -c .{json,yaml,pb,pb_text} --v2-config-only + ./envoy -c .{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 ` message is the root of the configuration. A key concept in the :ref:`Bootstrap ` diff --git a/docs/root/intro/version_history.rst b/docs/root/intro/version_history.rst index 580daf97e4878..aefd7b5b9ffb4 100644 --- a/docs/root/intro/version_history.rst +++ b/docs/root/intro/version_history.rst @@ -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 `_. -* 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 --v2-config-only 0. * health check: added support for :ref:`custom health check `. * health check: added support for :ref:`specifying jitter as a percentage `. * health_check: added support for :ref:`health check event logging `. diff --git a/docs/root/operations/cli.rst b/docs/root/operations/cli.rst index e50e99462e32a..f6a2671132251 100644 --- a/docs/root/operations/cli.rst +++ b/docs/root/operations/cli.rst @@ -32,11 +32,11 @@ following are the command line options that Envoy supports. ./envoy -c bootstrap.yaml --config-yaml "node: {id: 'node1'}" -.. option:: --v2-config-only +.. option:: --v2-config-only *(optional)* This flag determines whether the configuration file should only be parsed as a :ref:`v2 bootstrap configuration file - `. If false (default), when a v2 bootstrap + `. If false when a v2 bootstrap config parse fails, a second attempt to parse the config as a :ref:`v1 JSON configuration file ` will be made. diff --git a/source/server/options_impl.cc b/source/server/options_impl.cc index 8d47f18cb9ca8..4a855343f84ee 100644 --- a/source/server/options_impl.cc +++ b/source/server/options_impl.cc @@ -57,7 +57,9 @@ OptionsImpl::OptionsImpl(int argc, const char* const* argv, TCLAP::ValueArg 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); + + TCLAP::ValueArg v2_config_only("", "v2-config-only", "parse config as v2 only", false, + false, "bool", cmd); TCLAP::ValueArg admin_address_path("", "admin-address-path", "Admin address path", false, "", "string", cmd); TCLAP::ValueArg local_address_ip_version("", "local-address-ip-version", diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index 9a9def19817e8..c92aae1303c40 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -60,12 +60,32 @@ TEST(OptionsImplTest, InvalidCommandLine) { "Couldn't find match for argument"); } +TEST(OptionsImplTest, v2True) { + std::unique_ptr 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 --v2-config-only 1 --disable-hot-restart"); + EXPECT_EQ(Server::Mode::Validate, options->mode()); + EXPECT_TRUE(options->v2ConfigOnly()); +} + +TEST(OptionsImplTest, v2False) { + std::unique_ptr 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 --v2-config-only 0 --disable-hot-restart"); + EXPECT_EQ(Server::Mode::Validate, options->mode()); + EXPECT_FALSE(options->v2ConfigOnly()); +} + TEST(OptionsImplTest, All) { std::unique_ptr 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 --v2-config-only --disable-hot-restart"); + "--parent-shutdown-time-s 90 --log-path /foo/bar --v2-config-only 0 --disable-hot-restart"); EXPECT_EQ(Server::Mode::Validate, options->mode()); EXPECT_EQ(2U, options->concurrency()); EXPECT_EQ("hello", options->configPath()); From 7f71af96886ae8aab51c30eb6ed3b272b476ab56 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Thu, 12 Jul 2018 12:58:27 -0400 Subject: [PATCH 2/3] --allow-deprecated-v1-api Signed-off-by: Alyssa Wilk --- DEPRECATED.md | 1 + docs/root/intro/version_history.rst | 2 +- docs/root/operations/cli.rst | 14 +++++++++----- source/server/options_impl.cc | 10 +++++++--- test/server/options_impl_test.cc | 17 +++++++++-------- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/DEPRECATED.md b/DEPRECATED.md index ace294b0ff313..389c0ecd95104 100644 --- a/DEPRECATED.md +++ b/DEPRECATED.md @@ -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 diff --git a/docs/root/intro/version_history.rst b/docs/root/intro/version_history.rst index aefd7b5b9ffb4..5b6c7dc9a36f6 100644 --- a/docs/root/intro/version_history.rst +++ b/docs/root/intro/version_history.rst @@ -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 `_. -* config: v1 disabled by default. v1 support remains available until October via setting --v2-config-only 0. +* config: v1 disabled by default. v1 support remains available until October via setting --allow-deprecated-v1-api. * health check: added support for :ref:`custom health check `. * health check: added support for :ref:`specifying jitter as a percentage `. * health_check: added support for :ref:`health check event logging `. diff --git a/docs/root/operations/cli.rst b/docs/root/operations/cli.rst index f6a2671132251..e687d49512111 100644 --- a/docs/root/operations/cli.rst +++ b/docs/root/operations/cli.rst @@ -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 `. If this flag is missing, :option:`--config-yaml` is required. This will be parsed as a :ref:`v2 bootstrap configuration file - ` and on failure, subject to - :option:`--v2-config-only`, will be considered as a :ref:`v1 JSON + `. On failure, if :option:`--allow-deprecated-v1-api`, + is set, it will be considered as a :ref:`v1 JSON configuration file `. For v2 configuration files, valid extensions are ``.json``, ``.yaml``, ``.pb`` and ``.pb_text``, which indicate JSON, YAML, `binary proto3 @@ -32,14 +32,18 @@ following are the command line options that Envoy supports. ./envoy -c bootstrap.yaml --config-yaml "node: {id: 'node1'}" -.. option:: --v2-config-only +.. option:: --v2-config-only + + *(deprecated)* This flag used to allow opting into only using a + :ref:`v2 bootstrap configuration file `. 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 - `. If false when a 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 ` will be made. - .. option:: --mode *(optional)* One of the operating modes for Envoy: diff --git a/source/server/options_impl.cc b/source/server/options_impl.cc index 4a855343f84ee..e661557815457 100644 --- a/source/server/options_impl.cc +++ b/source/server/options_impl.cc @@ -58,8 +58,12 @@ OptionsImpl::OptionsImpl(int argc, const char* const* argv, "", "config-yaml", "Inline YAML configuration, merges with the contents of --config-path", false, "", "string", cmd); - TCLAP::ValueArg v2_config_only("", "v2-config-only", "parse config as v2 only", false, - false, "bool", cmd); + // 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 admin_address_path("", "admin-address-path", "Admin address path", false, "", "string", cmd); TCLAP::ValueArg local_address_ip_version("", "local-address-ip-version", @@ -179,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(); diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index c92aae1303c40..c6077699e41ce 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -60,24 +60,25 @@ TEST(OptionsImplTest, InvalidCommandLine) { "Couldn't find match for argument"); } -TEST(OptionsImplTest, v2True) { +TEST(OptionsImplTest, v1Allowed) { std::unique_ptr 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 --v2-config-only 1 --disable-hot-restart"); + "--parent-shutdown-time-s 90 --log-path /foo/bar --allow-deprecated-v1-api " + "--disable-hot-restart"); EXPECT_EQ(Server::Mode::Validate, options->mode()); - EXPECT_TRUE(options->v2ConfigOnly()); + EXPECT_FALSE(options->v2ConfigOnly()); } -TEST(OptionsImplTest, v2False) { +TEST(OptionsImplTest, v1Disallowed) { std::unique_ptr 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 --v2-config-only 0 --disable-hot-restart"); + "--parent-shutdown-time-s 90 --log-path /foo/bar --disable-hot-restart"); EXPECT_EQ(Server::Mode::Validate, options->mode()); - EXPECT_FALSE(options->v2ConfigOnly()); + EXPECT_TRUE(options->v2ConfigOnly()); } TEST(OptionsImplTest, All) { @@ -85,11 +86,11 @@ TEST(OptionsImplTest, All) { "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 --v2-config-only 0 --disable-hot-restart"); + "--parent-shutdown-time-s 90 --log-path /foo/bar --v2-config-only --disable-hot-restart"); 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()); From dfe6e7d7c232166f4da103c98e1e9e3d226aee3e Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Thu, 12 Jul 2018 13:07:16 -0400 Subject: [PATCH 3/3] cleanup Signed-off-by: Alyssa Wilk --- docs/root/intro/version_history.rst | 2 +- docs/root/operations/cli.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/root/intro/version_history.rst b/docs/root/intro/version_history.rst index 5b6c7dc9a36f6..68bb3340bcf0a 100644 --- a/docs/root/intro/version_history.rst +++ b/docs/root/intro/version_history.rst @@ -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 `_. -* config: v1 disabled by default. v1 support remains available until October via setting --allow-deprecated-v1-api. +* 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 `. * health check: added support for :ref:`specifying jitter as a percentage `. * health_check: added support for :ref:`health check event logging `. diff --git a/docs/root/operations/cli.rst b/docs/root/operations/cli.rst index e687d49512111..c6081452c6770 100644 --- a/docs/root/operations/cli.rst +++ b/docs/root/operations/cli.rst @@ -44,6 +44,7 @@ following are the command line options that Envoy supports. `. If specified when a v2 bootstrap config parse fails, a second attempt to parse the config as a :ref:`v1 JSON configuration file ` will be made. + .. option:: --mode *(optional)* One of the operating modes for Envoy: