out_opentelemetry: oauth2 token-source rework (review)#2
Open
evgfitil wants to merge 1 commit into
Open
Conversation
7438702 to
b6ef09c
Compare
Add an oauth2 token-source abstraction so the OpenTelemetry output plugin can fetch short-lived IAM tokens from a cloud-provider local metadata server, instead of requiring static client credentials. A new resolver in src/flb_oauth2.c dispatches refresh by token source: client_credentials or metadata. New config keys oauth2.token_source, oauth2.metadata_url and oauth2.metadata_header are exposed under [OUTPUT] for opentelemetry. Validated end-to-end against Google Cloud metadata server. Signed-off-by: Evgenii Akhmetzianov <evgfitil@gmail.com>
fea1743 to
081660c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes fluent#11675.
The OTel output plugin supports OAuth2 client-credentials authentication but cannot fetch Bearer tokens from a cloud-instance metadata endpoint - the standard mechanism on platforms where a VM has a linked service account. The metadata path is added as a mode of the existing OAuth2 in
flb_oauth2core and exposes a uniformoauth2.*namespace; the public contract offlb_oauth2_get_access_token()is unchanged.Public API
Three new keys (binding for any plugin that exposes the
flb_oauth2config map):oauth2.token_sourceclient_credentialsormetadataclient_credentialsoauth2.metadata_urloauth2.metadata_headerName: ValueformTesting
Example configuration - metadata mode (GCE)
Debug log output - metadata token fetch + refresh
Debug log output - backward-compat (client_credentials, default)
oauth2.token_sourcedefaults toclient_credentials; existing OAuth2 configurations are byte-identical to pre-PR behaviour.Valgrind - 0 leaks, 0 errors
Build:
cmake -DFLB_DEV=On -DFLB_VALGRIND=On -DFLB_TESTS_INTERNAL=On -DFLB_TESTS_RUNTIME=Onvalgrind --leak-check=full --show-leak-kinds=allagainst081660c546:flb-it-oauth2_metadata: 41 tests pass; 76,461 allocs / 76,461 frees; 0 bytes in use at exit; 0 errors;flb-rt-out_opentelemetry: 2 tests pass (default_config,oauth2_metadata_smoke); 14,708 allocs / 14,708 frees; 0 bytes in use at exit; 0 errors.Full output: https://gist.github.com/evgfitil/34c515cae74ca5388685ac70bf6e5cc4
Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.