Skip to content

Support api config source without cluster names #3030

Merged
htuch merged 10 commits intoenvoyproxy:masterfrom
ambuc:fix-support_api_config_source
Apr 11, 2018
Merged

Support api config source without cluster names #3030
htuch merged 10 commits intoenvoyproxy:masterfrom
ambuc:fix-support_api_config_source

Conversation

@ambuc
Copy link
Copy Markdown
Contributor

@ambuc ambuc commented Apr 9, 2018

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

  • added a more verbose error in utility.cc for GRPC api_config_sources with any named clusters
  • hunted down places in tests where api_config_source.cluster_names()[0] was implicitly used (assuming that API would be GRPC and would have cluster names).
  • renamed factoryForApiConfigSource to factoryForGrpcApiConfigSource, as it already implicitly returns a Grpc::AsyncClientFactoryPtr, and gave a more verbose error for when the user passes a config with cluster_names set.
  • separated out checkApiConfigSourceSubscriptionBackingCluster into checkApiConfigSourceNames, which does the gRPC services v. cluster names validation, and - checkApiConfigSourceSubscriptionBackingCluster, which actually validates the cluster name against the clusters map.
  • more completely covered the tests for the branching cases for non-gRPC API configs which happened to have grpc services defined.

Risk Level: Low

Testing: bazel test test/... all passed.

Fixed #2680
Fixed #2902

Signed-off-by: James Buckland jbuckland@google.com

ambuc added 2 commits April 9, 2018 10:08
…yproxy#2999)" (envoyproxy#3018)"

This reverts commit fdcbe10.

Signed-off-by: James Buckland <jbuckland@google.com>
Signed-off-by: James Buckland <jbuckland@google.com>
}
} 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 "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still throw, non-gRPC services should never have been configured this way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to deal with the case where cluster_names.size() == 1 here and there are no gRPC services.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this case gets caught when we call Utility::checkApiConfigSourceNames(api_config_source) at the top of this function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a34526e.

ambuc added 2 commits April 9, 2018 13:46
Signed-off-by: James Buckland <jbuckland@google.com>
Signed-off-by: James Buckland <jbuckland@google.com>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but just one missing test case and related implementation issue.

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");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to "Setting a cluster name for API config source type envoy::api::v2::core::ConfigSource::GRPC is deprecated".

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be an else if (how come the tests didn't catch this?).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to change the check to > 1 then, to support when grpc_services.size() == 0 and they are using deprecated cluster_names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nice catch. We're sort of overloading !=1 here to catch both empty grpc_services (deprecated) and >1 grpc_services (not supported).

// clusters.
api_config_source->add_grpc_services();
}
api_config_source->add_cluster_names("foo_cluster");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll probably want another standalone test for the case where cluster_names.size() != 0 for gRPC but grpc_services.size() == 0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworked this in d62249f.

@htuch htuch self-assigned this Apr 9, 2018
ambuc added 3 commits April 10, 2018 09:28
… 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>
htuch
htuch previously approved these changes Apr 11, 2018
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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@htuch
Copy link
Copy Markdown
Member

htuch commented Apr 11, 2018

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>
@htuch htuch merged commit b8e2eee into envoyproxy:master Apr 11, 2018
mattklein123 added a commit that referenced this pull request Apr 12, 2018
This reverts commit b8e2eee.

Signed-off-by: Matt Klein <mklein@lyft.com>
@ambuc ambuc deleted the fix-support_api_config_source branch April 12, 2018 17:38
mattklein123 added a commit that referenced this pull request Apr 12, 2018
This reverts commit b8e2eee.

Signed-off-by: Matt Klein <mklein@lyft.com>
ambuc added a commit to ambuc/envoy that referenced this pull request Apr 12, 2018
…yproxy#3030)""

This reverts commit f0a7c4e.

Signed-off-by: James Buckland <jbuckland@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants