Support api config source without cluster names #3030
Support api config source without cluster names #3030htuch merged 10 commits intoenvoyproxy:masterfrom
Conversation
…yproxy#2999)" (envoyproxy#3018)" This reverts commit fdcbe10. Signed-off-by: James Buckland <jbuckland@google.com>
Signed-off-by: James Buckland <jbuckland@google.com>
source/common/config/utility.cc
Outdated
| } | ||
| } else { | ||
| if (api_config_source.grpc_services().size() != 0) { | ||
| ENVOY_LOG_MISC(warn, "envoy::api::v2::core::ConfigSource, if not of type gRPC, must not have " |
There was a problem hiding this comment.
This should still throw, non-gRPC services should never have been configured this way.
There was a problem hiding this comment.
I'll roll this case and its test back to throwing an error.
| if (is_grpc) { | ||
| // Some ApiConfigSources of type GRPC won't have a cluster name, such as if | ||
| // they've been configured with google_grpc. | ||
| if (api_config_source.grpc_services()[0].has_envoy_grpc()) { |
There was a problem hiding this comment.
You'll need to deal with the case where cluster_names.size() == 1 here and there are no gRPC services.
There was a problem hiding this comment.
I think this case gets caught when we call Utility::checkApiConfigSourceNames(api_config_source) at the top of this function.
Signed-off-by: James Buckland <jbuckland@google.com>
Signed-off-by: James Buckland <jbuckland@google.com>
htuch
left a comment
There was a problem hiding this comment.
Looks good, but just one missing test case and related implementation issue.
source/common/config/utility.cc
Outdated
| if (is_grpc) { | ||
| if (api_config_source.cluster_names().size() != 0) { | ||
| ENVOY_LOG_MISC( | ||
| warn, "envoy::api::v2::core::ConfigSource::GRPC must not have a cluster name specified"); |
There was a problem hiding this comment.
Change this to "Setting a cluster name for API config source type envoy::api::v2::core::ConfigSource::GRPC is deprecated".
source/common/config/utility.cc
Outdated
| ENVOY_LOG_MISC( | ||
| warn, "envoy::api::v2::core::ConfigSource::GRPC must not have a cluster name specified"); | ||
| } | ||
| if (api_config_source.grpc_services().size() != 1) { |
There was a problem hiding this comment.
Shouldn't this be an else if (how come the tests didn't catch this?).
There was a problem hiding this comment.
I think this shouldn't be an else if. The first block checks for non-zero cluster_names, which would be bad because setting a cluster name for a gRPC is deprecated. This second block independently checks for non-singleton grpc_services, which are unsupported.
There was a problem hiding this comment.
You'll need to change the check to > 1 then, to support when grpc_services.size() == 0 and they are using deprecated cluster_names.
There was a problem hiding this comment.
Oh, nice catch. We're sort of overloading !=1 here to catch both empty grpc_services (deprecated) and >1 grpc_services (not supported).
test/common/config/utility_test.cc
Outdated
| // clusters. | ||
| api_config_source->add_grpc_services(); | ||
| } | ||
| api_config_source->add_cluster_names("foo_cluster"); |
There was a problem hiding this comment.
You'll probably want another standalone test for the case where cluster_names.size() != 0 for gRPC but grpc_services.size() == 0.
… REST and gRPC APIs Signed-off-by: James Buckland <jbuckland@google.com>
Signed-off-by: James Buckland <jbuckland@google.com>
Signed-off-by: James Buckland <jbuckland@google.com>
| ENVOY_LOG_MISC(warn, "Setting a cluster name for API config source type " | ||
| "envoy::api::v2::core::ConfigSource::GRPC is deprecated"); | ||
| } | ||
| if (api_config_source.cluster_names().size() > 1) { |
There was a problem hiding this comment.
I think this one can be dropped, the above warning is sufficient, unless this makes testing easier somehow.
Signed-off-by: James Buckland <jbuckland@google.com>
Signed-off-by: James Buckland <jbuckland@google.com>
|
LGTM. One last thing, can you update DEPRECATED.md, since 1.7.0 is when we do the real removal? |
Signed-off-by: James Buckland <jbuckland@google.com>
This reverts commit b8e2eee. Signed-off-by: Matt Klein <mklein@lyft.com>
…yproxy#3030)"" This reverts commit f0a7c4e. Signed-off-by: James Buckland <jbuckland@google.com>
This reverts #3018, which reverted #2999. Therefore this PR is similar to #2999, except that
77b292c allows REST/gRPC config mismatch errors to warn instead of throwing an error. Hopefully this solves the issue for users who were unable to roll forward their binaries while keeping the same config.
Changelist for #2999:
To support the deprecation of cluster_names in the api_config_source (#2860), I
Risk Level: Low
Testing: bazel test test/... all passed.
Fixed #2680
Fixed #2902
Signed-off-by: James Buckland jbuckland@google.com