Skip to content

access_log: add extension filter to allow runtime filter registration.#7435

Merged
mattklein123 merged 27 commits intoenvoyproxy:masterfrom
efimki:envoy_accesslog_extension
Jul 31, 2019
Merged

access_log: add extension filter to allow runtime filter registration.#7435
mattklein123 merged 27 commits intoenvoyproxy:masterfrom
efimki:envoy_accesslog_extension

Conversation

@efimki
Copy link
Copy Markdown
Member

@efimki efimki commented Jul 1, 2019

Signed-off-by: Misha Efimov mef@google.com

Description: Add AccessLog ExtensionFilter to allow runtime filter registration.
Risk Level: Medium
Testing: unit test
Docs Changes: Add AccessLog ExtensionFilter documentation.
Release Notes: updated.
Fixes #7326

Signed-off-by: Misha Efimov <mef@chromium.org>
@efimki
Copy link
Copy Markdown
Member Author

efimki commented Jul 1, 2019

This is a WIP of my first PR, and it is NOT ready for review yet.

@junr03
Copy link
Copy Markdown
Member

junr03 commented Jul 1, 2019

Thanks @efimki. I will take a look when you are ready!

/wait

@junr03 junr03 self-assigned this Jul 1, 2019
efimki added 2 commits July 2, 2019 12:04
Signed-off-by: Misha Efimov <mef@google.com>
…xtension

Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
@efimki efimki marked this pull request as ready for review July 9, 2019 19:54
@efimki
Copy link
Copy Markdown
Member Author

efimki commented Jul 9, 2019

I think it is now ready for review. This is my first Envoy PR, so I apologize if I've missed something.

Signed-off-by: Misha Efimov <mef@google.com>
@efimki efimki changed the title Add AccessLog ExtensionFilter to allow runtime filter registration. access_log: add extension filter to allow runtime filter registration. Jul 9, 2019
Signed-off-by: Misha Efimov <mef@google.com>
Copy link
Copy Markdown
Member Author

@efimki efimki left a comment

Choose a reason for hiding this comment

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

Hi Auni, thanks for your comments!
I've addressed them, PTAL.

@efimki
Copy link
Copy Markdown
Member Author

efimki commented Jul 11, 2019

@junr03 Could you take a look when you have a chance? I'll appreciate your input. Thanks in advance!

efimki added 7 commits July 17, 2019 11:05
Signed-off-by: Misha Efimov <mef@google.com>
…xtension

Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
@junr03
Copy link
Copy Markdown
Member

junr03 commented Jul 19, 2019

sorry for the delay. Will get to this today

Copy link
Copy Markdown
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

Very nice, good extension point. Just a few comments. @htuch can you take a look given you have been chatting with @efimki offline?

// Custom configuration that depends on the filter being instantiated.
oneof config_type {
google.protobuf.Struct config = 2;
google.protobuf.Any typed_config = 3;
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.

Why both?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've found @htuch article [1] that suggests that Struct and Any have different benefits in terms of type checking and flexibility. It also matches pattern used in message AccessLog.

  1. https://blog.envoyproxy.io/dynamic-extensibility-and-protocol-buffers-dcd0bf0b8801

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 thought the plan here is that we aren't going to allow Struct for any new things, as a Struct can be embedded in any Any? @htuch?

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 kind of feel we should just be consistent in v2 and in UDPA we can make a clean break.

Signed-off-by: Misha Efimov <mef@google.com>
Copy link
Copy Markdown
Member Author

@efimki efimki left a comment

Choose a reason for hiding this comment

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

@junr03 thanks a lot for review!

// Custom configuration that depends on the filter being instantiated.
oneof config_type {
google.protobuf.Struct config = 2;
google.protobuf.Any typed_config = 3;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've found @htuch article [1] that suggests that Struct and Any have different benefits in terms of type checking and flexibility. It also matches pattern used in message AccessLog.

  1. https://blog.envoyproxy.io/dynamic-extensibility-and-protocol-buffers-dcd0bf0b8801

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.

LGTM modulo nits.
/wait

}

private:
size_t current_ = 0;
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.

Nit: prefer using unsigned explicit sized integers in Envoy, rather than size_t (which you can use for buffer sizes etc.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done, thanks for suggestion!

config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this);
const Json::ObjectSharedPtr filter_config =
MessageUtil::getJsonObjectFromMessage(*factory_config);
return FilterPtr{new SampleExtensionFilter(filter_config->getInteger("rate"))};
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.

Nit: you can make all these Ptr{ new .. just std::make_unique

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for suggestion! Done.

// For rate=5 expect 1st request to be recorded, 2nd-5th skipped, and 6th recorded.
EXPECT_CALL(*file_, write(_));
logger->log(&request_headers_, &response_headers_, &response_trailers_, stream_info_);
for (int i = 2; i <= 5; ++i) {
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.

Nit: just count from 0 to 3?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done. I was trying to express that requests 2-5 are skipped.

Signed-off-by: Misha Efimov <mef@google.com>
@efimki efimki dismissed stale reviews from junr03 and htuch via b68f415 July 29, 2019 17:54
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7435 was synchronize by efimki.

see: more, trace.

Signed-off-by: Misha Efimov <mef@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7435 was synchronize by efimki.

see: more, trace.

Signed-off-by: Misha Efimov <mef@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7435 was synchronize by efimki.

see: more, trace.

Signed-off-by: Misha Efimov <mef@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7435 was synchronize by efimki.

see: more, trace.

Copy link
Copy Markdown
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 with one small doc request. Thank you!

/wait

Access log filters
==================

Envoy supports several built-in access log filters. Currently supported filters are:
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.

Can you ref link into the actual filter config docs? It's up to you if you want to replicate all of the filters here as they may get out of date vs. just link to the filter structure. I mostly just wanted to call out that extension filters are available. https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/filter/accesslog/v2/accesslog.proto#envoy-api-msg-config-filter-accesslog-v2-accesslog

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll be happy to ref link into the actual filter config docs, but I can't figure out how.
Is there an example that I could follow?

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks! I think I've done the right thing now, but not 100% sure.

I'm totally confused about msg vs field in references like <envoy_api_msg_config.filter.accesslog.v2.AccessLogFilter> <envoy_api_field_config.filter.accesslog.v2.AccessLogFilter.extension_filter>.

Signed-off-by: Misha Efimov <mef@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7435 was synchronize by efimki.

see: more, trace.

Copy link
Copy Markdown
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.

Thanks looks great. Sorry one more thing: please add a release note otherwise LGTM!

/wait

Signed-off-by: Misha Efimov <mef@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7435 was synchronize by efimki.

see: more, trace.

* tls: added verification of IP address SAN fields in certificates against configured SANs in the
certificate validation context.
* upstream: added network filter chains to upstream connections, see :ref:`filters<envoy_api_field_Cluster.filters>`.
* config: added access log :ref:`extension filter<envoy_api_field_config.filter.accesslog.v2.AccessLogFilter.extension_filter>`.
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.

Nit: needs to be alpha sorted :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Of course. :)
Done.

Signed-off-by: Misha Efimov <mef@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #7435 was synchronize by efimki.

see: more, trace.

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.

Thanks!

Copy link
Copy Markdown
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.

Thank you!

@mattklein123 mattklein123 merged commit a949328 into envoyproxy:master Jul 31, 2019
@efimki efimki deleted the envoy_accesslog_extension branch August 1, 2019 15:50
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.

Add static registration of AccessLog::Filter implementations

5 participants