Skip to content

Commit d4a98a9

Browse files
markdrothpaulosjca
authored andcommitted
[TokenFetcherCredentials] add backoff and pre-fetching (grpc#37531)
This adds functionality that is intended to be used for the new GcpServiceAccountIdentityCallCredentials implementation, as per gRFC A83 (grpc/proposal#438). However, it is also a useful improvement for all token-fetching call credentials types, so I am adding it to the base class. Closes grpc#37531 COPYBARA_INTEGRATE_REVIEW=grpc#37531 from markdroth:token_fetcher_call_creds_prefetch_and_backoff 0fcdb48 PiperOrigin-RevId: 666809903
1 parent b8f7baa commit d4a98a9

File tree

12 files changed

+638
-89
lines changed

12 files changed

+638
-89
lines changed

doc/trace_flags.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4335,14 +4335,17 @@ grpc_cc_library(
43354335
deps = [
43364336
"arena_promise",
43374337
"context",
4338+
"default_event_engine",
43384339
"metadata",
43394340
"poll",
43404341
"pollset_set",
43414342
"ref_counted",
43424343
"time",
43434344
"useful",
4345+
"//:backoff",
43444346
"//:gpr",
43454347
"//:grpc_security_base",
4348+
"//:grpc_trace",
43464349
"//:httpcli",
43474350
"//:iomgr",
43484351
"//:orphanable",
@@ -4436,7 +4439,6 @@ grpc_cc_library(
44364439
language = "c++",
44374440
deps = [
44384441
"closure",
4439-
"default_event_engine",
44404442
"env",
44414443
"error",
44424444
"error_utils",

src/core/lib/debug/trace_flags.cc

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/lib/debug/trace_flags.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/lib/debug/trace_flags.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ timer:
308308
timer_check:
309309
default: false
310310
description: more detailed trace of timer logic in grpc internals.
311+
token_fetcher_credentials:
312+
default: false
313+
description: Token fetcher call credentials framework, used for (e.g.) oauth2 token fetcher credentials.
311314
tsi:
312315
default: false
313316
description: TSI transport security.

src/core/lib/promise/map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION auto CheckDelayed(Promise promise) {
8686
delayed = true;
8787
return Pending{};
8888
}
89-
return std::make_tuple(r.value(), delayed);
89+
return std::make_tuple(std::move(r.value()), delayed);
9090
};
9191
}
9292

src/core/lib/security/credentials/external/external_account_credentials.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include <grpc/support/port_platform.h>
4646
#include <grpc/support/string_util.h>
4747

48-
#include "src/core/lib/event_engine/default_event_engine.h"
4948
#include "src/core/lib/gprpp/status_helper.h"
5049
#include "src/core/lib/security/credentials/credentials.h"
5150
#include "src/core/lib/security/credentials/external/aws_external_account_credentials.h"
@@ -591,10 +590,7 @@ ExternalAccountCredentials::Create(
591590
ExternalAccountCredentials::ExternalAccountCredentials(
592591
Options options, std::vector<std::string> scopes,
593592
std::shared_ptr<grpc_event_engine::experimental::EventEngine> event_engine)
594-
: event_engine_(
595-
event_engine == nullptr
596-
? grpc_event_engine::experimental::GetDefaultEventEngine()
597-
: std::move(event_engine)),
593+
: TokenFetcherCredentials(std::move(event_engine)),
598594
options_(std::move(options)) {
599595
if (scopes.empty()) {
600596
scopes.push_back(GOOGLE_CLOUD_PLATFORM_DEFAULT_SCOPE);

src/core/lib/security/credentials/external/external_account_credentials.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,6 @@ class ExternalAccountCredentials : public TokenFetcherCredentials {
185185

186186
absl::string_view audience() const { return options_.audience; }
187187

188-
grpc_event_engine::experimental::EventEngine& event_engine() const {
189-
return *event_engine_;
190-
}
191-
192188
private:
193189
OrphanablePtr<FetchRequest> FetchToken(
194190
Timestamp deadline,
@@ -204,7 +200,6 @@ class ExternalAccountCredentials : public TokenFetcherCredentials {
204200
Timestamp deadline,
205201
absl::AnyInvocable<void(absl::StatusOr<std::string>)> on_done) = 0;
206202

207-
std::shared_ptr<grpc_event_engine::experimental::EventEngine> event_engine_;
208203
Options options_;
209204
std::vector<std::string> scopes_;
210205
};

src/core/lib/security/credentials/external/file_external_account_credentials.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <grpc/support/json.h>
2727
#include <grpc/support/port_platform.h>
2828

29-
#include "src/core/lib/event_engine/default_event_engine.h"
3029
#include "src/core/lib/gprpp/load_file.h"
3130
#include "src/core/lib/slice/slice.h"
3231
#include "src/core/lib/slice/slice_internal.h"

0 commit comments

Comments
 (0)