Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext_authz: expose fields latency, bytesSent and bytesReceived for CEL and logging #37074

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

hypnoce
Copy link
Contributor

@hypnoce hypnoce commented Nov 8, 2024

Commit Message:
ext_authz: expose fields latency, bytesSent and bytesReceived for CEL and logging

Additional Description:
This PR adds field access support for ext_authz filter state object ExtAuthzLoggingInfo. It exposes simple fields

  • latency
  • bytesSent
  • bytesReceived

This enables usage of ext_authz filter state in access logs, and any filter/logger using CEL after #35698.

Risk Level: Low

Testing:
Added field access test with valid and invalid field names

Docs Changes: added in proto api and docs

Release Notes: added filter state field latency, bytesSent and bytesReceived access for CEL and logging.

Platform Specific Features: none

PS: I'm not a native english speaker please let me know if I need to change any docs.

Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @abeyad
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #37074 was opened by hypnoce.

see: more, trace.

@hypnoce hypnoce force-pushed the ext_authz_fields branch 6 times, most recently from 8d1a776 to d0b4962 Compare November 11, 2024 14:53
@@ -306,6 +306,8 @@ message ExtAuthz {
//
// If this is false the filter will not emit stats, but filter_metadata will still be respected if
// it has a value.
//
// Fields ``latency``, ``bytesSent`` and ``bytesReceived`` are exposed for CEL and logging
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment on L304 indicates if not using Envoy gRPC, only latency is emitted. Does this comment override that one? If so, would be good to update that comment too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Let me know if the new formulation is clearer.

Copy link
Contributor

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

/wait

source/extensions/filters/http/ext_authz/ext_authz.h Outdated Show resolved Hide resolved
source/extensions/filters/http/ext_authz/ext_authz.h Outdated Show resolved Hide resolved
source/extensions/filters/http/ext_authz/ext_authz.h Outdated Show resolved Hide resolved
JACQUES Francois added 3 commits November 13, 2024 00:06
Signed-off-by: JACQUES Francois <[email protected]>
@ggreenway
Copy link
Contributor

@hypnoce in the future please don't force push/rebase (see

* Once your PR is under review, *please do not rebase it*. If you rebase, you will need to force push to
).

Copy link
Contributor

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

Apologies, I had a typo in two of the suggested changes I left you last time. Fixed here.

/wait

source/extensions/filters/http/ext_authz/ext_authz.h Outdated Show resolved Hide resolved
source/extensions/filters/http/ext_authz/ext_authz.h Outdated Show resolved Hide resolved
EXPECT_THAT(ext_authz_logging_info->getField("bytesReceived"),
testing::VariantWith<int64_t>(ext_authz_logging_info->bytesReceived().value()));
} else {
EXPECT_THAT(ext_authz_logging_info->getField("bytesReceived"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this case is ever run; it should be failing with the current version that calls value() instead of has_value() in the check. Please make sure this case (field is requested, but not value available) is covered.

Copy link
Contributor Author

@hypnoce hypnoce Nov 13, 2024

Choose a reason for hiding this comment

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

This case is ran. It does not fail because the value is actually set to 0

logging_info_->setBytesReceived(bytes_meter->wireBytesReceived());
, so the getField returns monostate (has_value is truthy while value() is falsy which is clearly misleading).

@hypnoce
Copy link
Contributor Author

hypnoce commented Nov 13, 2024

Apologies, I had a typo in two of the suggested changes I left you last time. Fixed here.

/wait

Yes I was a bit confused I thought you wanted to check the values are non 0. Will change that.

@tyxia
Copy link
Member

tyxia commented Nov 13, 2024

/assign @antoniovleonti

You may want to take a look? as you added the billing/logging feature

Signed-off-by: JACQUES Francois <[email protected]>
Signed-off-by: JACQUES Francois <[email protected]>
Copy link
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

Thanks for contribution!

source/extensions/filters/http/ext_authz/ext_authz.h Outdated Show resolved Hide resolved
JACQUES Francois added 3 commits November 13, 2024 20:36
Signed-off-by: JACQUES Francois <[email protected]>
Signed-off-by: JACQUES Francois <[email protected]>
Signed-off-by: JACQUES Francois <[email protected]>
@hypnoce
Copy link
Contributor Author

hypnoce commented Nov 14, 2024

@hypnoce in the future please don't force push/rebase (see

* Once your PR is under review, *please do not rebase it*. If you rebase, you will need to force push to

).

Yes, but sometimes there are random github action errors and to trigger them I force push...Do you know another way for me to rerun github actions on technical failure ?

@ggreenway
Copy link
Contributor

Yes, but sometimes there are random github action errors and to trigger them I force push...Do you know another way for me to rerun github actions on technical failure ?

I think you can add /retest to a comment to re-run failed tests.

@hypnoce
Copy link
Contributor Author

hypnoce commented Nov 14, 2024

/retest

@hypnoce
Copy link
Contributor Author

hypnoce commented Nov 14, 2024

@ggreenway @tyxia @antoniovleonti Thanks for your comments. Anything else to change ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants