Skip to content

ratelimit: add support for data-plane-api proto#3675

Merged
junr03 merged 8 commits intomasterfrom
legacy-ratelimit-client
Jun 22, 2018
Merged

ratelimit: add support for data-plane-api proto#3675
junr03 merged 8 commits intomasterfrom
legacy-ratelimit-client

Conversation

@junr03
Copy link
Member

@junr03 junr03 commented Jun 19, 2018

ratelimit: add support for data-plane-api proto

Description:
added support for api/envoy/service/ratelimit/v2/rls.proto. 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. Support for the legacy proto is deprecated and will be removed at the start of the 1.8.0 release cycle.

Risk Level: Medium
This PR modifies the Ratelimit client code to internally use the data-plane-api proto. The data-plane-api proto is binary compatible with the proto defined in source/common/ratelimit/ratelimit.proto (legacy proto). In order to support servers using the legacy proto, Envoy selectively uses the legacy method string or the data-plane-api method string based on the user configurable use_data_plane_proto flag.

Testing:
Update unit and integration tests, parameterized to test both protos. Additionally, I performed a smoke test at Lyft against Lyft's ratelimit service v1.1.1.

Docs Changes:
added documentation.

Release Notes:
added the release notes.

Deprecated:
The use of the legacy proto is deprecated, and using the legacy proto will log a warning log entry.

Fixes #1034

Jose Nino added 2 commits June 19, 2018 14:36
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
client_->cancel();
}

TEST(RateLimitGrpcFactoryTest, Create) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about explicitly testing the factory to make sure the correct Impl is being created (rather than the implicit testing done above), but I don't have a good sense on how to accomplish that other than type checking. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I think the implicit testing is probably fine as long as we cover both cases for now.

// :repo:`api/envoy/service/ratelimit/v2/rls.proto` or the legacy
// client :repo:`source/common/ratelimit/ratelimit.proto` when
// making requests to the rate limit service.
bool use_data_plane_proto = 3;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should invert this so that data_plane_api is default? use_legacy_proto? I would also deprecate this right away and explain what the user is supposed to do.

Copy link
Member Author

@junr03 junr03 Jun 19, 2018

Choose a reason for hiding this comment

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

I was struggling to decide the correct direction here. My main objection to having use_legacy_proto is that current configuration (absence of the field) would turn on using the data-plane-api proto by default; meaning that this commit would be breaking.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. OK I guess that's OK as long as we deprecate it right away and are clear what the default will become.

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly. Ok, I will deprecate the field and add more documentation. Also after this lands, I am going to write and email on the mailing lists that has all of the context from here, and from ratelimit as well.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

nice. thanks for fixing this. a few comments.


ClientPtr GrpcFactoryImpl::create(const absl::optional<std::chrono::milliseconds>& timeout) {
return std::make_unique<GrpcClientImpl>(async_client_factory_->create(), timeout);
// TODO(junr03): remove support for the lyft proto after 1.7.0.
Copy link
Member

Choose a reason for hiding this comment

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

nit: add deprecated in comment for easy searching

};

class RateLimitGrpcClientTest : public testing::Test {
// TODO(junr03): remove the boolean parameter after 1.7.0.
Copy link
Member

Choose a reason for hiding this comment

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

same, add deprecated

client_->cancel();
}

TEST(RateLimitGrpcFactoryTest, Create) {
Copy link
Member

Choose a reason for hiding this comment

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

I think the implicit testing is probably fine as long as we cover both cases for now.

namespace Envoy {
namespace {

// TODO(junr03): go back to having only one GrpcClientIntegrationParamTest after 1.7.0.
Copy link
Member

Choose a reason for hiding this comment

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

deprecated comment (same elsewhere)

Signed-off-by: Jose Nino <jnino@lyft.com>
@junr03
Copy link
Member Author

junr03 commented Jun 20, 2018

@mattklein123 updated with your comments

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM, one question

async_client_factory_->create(), timeout,
"envoy.service.ratelimit.v2.RateLimitService.ShouldRateLimit");
}
ENVOY_LOG_MISC(warn, "legacy rate limit client is deprecated, update your service to support "
Copy link
Member

Choose a reason for hiding this comment

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

When does this run? Only on startup? Or on every request?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point. I moved to the GrpcFactoryImpl constructor which is called only once in the server code

new RateLimit::GrpcFactoryImpl(bootstrap.rate_limit_service(),

Signed-off-by: Jose Nino <jnino@lyft.com>
async_client_factory_ = async_client_manager.factoryForGrpcService(grpc_service, scope, false);

// TODO(junr03): legacy rate limit is deprecated. Remove this warning after 1.7.0.
ENVOY_LOG_MISC(warn, "legacy rate limit client is deprecated, update your service to support "
Copy link
Member

Choose a reason for hiding this comment

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

This should only print in the legacy case. You have it printing in all cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mattklein123 yeah, total brain fart. Will fix when I merge master after the release and fix all the deprecation stuff.

Jose Nino added 4 commits June 21, 2018 14:58
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
@junr03
Copy link
Member Author

junr03 commented Jun 21, 2018

@mattklein123 ok fixed my brain fart with the logging, and the release cycle numbers. I think I tagged everything appropriately for the release cycle. The use of the legacy client is deprecated now, and when we tag 1.8.0 we can remove the support.

After this merges I will send an email to the mailing lists.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Nice!

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