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

[extension/bearertokenauth] Fix the RPC credential updates #35653

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

Conversation

JoonasMelin
Copy link

Fixes a bug - The gRPC headers not getting updated after collecter startup

Description

Does not appear there were any open/closed issues for this, but somewhere down the line the extension handling code has likely changed so that the PerRPCCredentials does not get called anymore for each call.

To excite the issue - you can start the collector with valid credentials, then inject invalid credentials to the token file.
Expected behavior: The collector starts using the invalid credentials and fails authentication
Old behavior: The collector keeps using the credentials it read at startup (problematic if you need to refresh the token)

This fixes the behavior by moving the evaluation of the authorization token to happen when the metadata is being fetched instead of at a time when the auth object is created.

Testing

Manual testing performed by manipulating the token file on the disk.
The interface to the rest of the application should remain exactly the same.

@JoonasMelin JoonasMelin requested review from jpkrohling and a team as code owners October 7, 2024 17:36
Copy link

linux-foundation-easycla bot commented Oct 7, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@JoonasMelin
Copy link
Author

Note that I have in-fact never written golang before so would appreciate any pointers on how this actually should be done.

Copy link
Contributor

github-actions bot commented Nov 9, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Nov 9, 2024
type PerRPCAuth struct {
metadata map[string]string
renderMetadata func() map[string]string
Copy link
Contributor

Choose a reason for hiding this comment

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

tabs, not spaces

@@ -22,13 +22,15 @@ import (
var _ credentials.PerRPCCredentials = (*PerRPCAuth)(nil)

// PerRPCAuth is a gRPC credentials.PerRPCCredentials implementation that returns an 'authorization' header.
// NOTE: Needs a function instead of static values so the data can be refreshed
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this note better as an issue?

Copy link
Author

Choose a reason for hiding this comment

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

I can try and reword the note - this is merely here to help people not trip up on the bug that was originally here as the design does not make it obvious that you actually need a function pointer rather than a static value (that then will not get refreshed)

@atoulme
Copy link
Contributor

atoulme commented Nov 9, 2024

Please add changelog, please add a test.

@github-actions github-actions bot removed the Stale label Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants