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

adding metadata on requests #3635

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gcemaj
Copy link

@gcemaj gcemaj commented Apr 25, 2024

What this PR does / why we need it:
Attempts to close #3634.
The PR adds a new configuration to the logger system to set a prefix string such that any header in the request that contains the header gets parsed and sent to the cloud event in a new metadata field.

Changes consists of

  • Adds a new configuration to the logger field
  • Adds a new field in the CE to hold the metadata
  • Adds system to parse request headers and extract name/value pairs containing prefix and passes the map to the CE

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #3634

Type of changes
Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Feature/Issue validation/testing:

Please describe the tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.

  • Added unit test to verify that cloud event gets metadata field based on request headers

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Checklist:

  • Have you added unit/e2e tests that prove your fix is effective or that this feature works?
  • Has code been commented, particularly in hard-to-understand areas?
  • Have you made corresponding changes to the documentation?

Release note:

Add new field (Metadata) in cloud event emmited by the request when using request-logging.
Metadata is populated by passing in headers in the request. Headers containing a prefix defined in the configuration will get parsed and sent along as Metadata.

Signed-off-by: Gabe Cemaj <[email protected]>
Copy link

oss-prow-bot bot commented Apr 25, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gcemaj
Once this PR has been reviewed and has the lgtm label, please assign njhill for approval by writing /assign @njhill in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: Gabe Cemaj <[email protected]>
@spolti
Copy link
Contributor

spolti commented Apr 29, 2024

I am not sure about it.
Isn't better to dump the request, similar how it is done with Apache?

@gcemaj
Copy link
Author

gcemaj commented Apr 30, 2024

I am not sure about it. Isn't better to dump the request, similar how it is done with Apache?

dump the headers you mean? that would also work, have a usecase where we need some extra metadata to be associated with the request.

@gcemaj
Copy link
Author

gcemaj commented Apr 30, 2024

I am not sure about it. Isn't better to dump the request, similar how it is done with Apache?

could also be an allowlist of headers?

@spolti
Copy link
Contributor

spolti commented Apr 30, 2024

I might no be fully understand the reason of this change, is there a specific use case that just dumping the request headers in the logs is not enough?

@gcemaj
Copy link
Author

gcemaj commented Apr 30, 2024

I might no be fully understand the reason of this change, is there a specific use case that just dumping the request headers in the logs is not enough?

security concerns where there might be a access token in the headers

@spolti
Copy link
Contributor

spolti commented Apr 30, 2024

I might no be fully understand the reason of this change, is there a specific use case that just dumping the request headers in the logs is not enough?

security concerns where there might be a access token in the headers

I see, maybe just dump the request direct in the logs would be enough, wdyt?

@yuzisun @terrytangyuan

@gcemaj
Copy link
Author

gcemaj commented May 1, 2024

I might no be fully understand the reason of this change, is there a specific use case that just dumping the request headers in the logs is not enough?

security concerns where there might be a access token in the headers

I see, maybe just dump the request direct in the logs would be enough, wdyt?

@yuzisun @terrytangyuan

i think we can just have a allowlist for the headers? so you can explicitly configure what you want sent over? Does that seem reasonable? If so i can make the change in this PR

@spolti
Copy link
Contributor

spolti commented May 6, 2024

Let's wait others to review.

@lizzzcai
Copy link
Member

lizzzcai commented May 7, 2024

option to dump/forward headers + allowlist on headers will be something more flexible. prefix may not be so convenient as not all headers have the same prefix.

@gcemaj
Copy link
Author

gcemaj commented May 8, 2024

option to dump/forward headers + allowlist on headers will be something more flexible. prefix may not be so convenient as not all headers have the same prefix.

ill make this change

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 metadata to logger system
3 participants