Skip to content

impl(auth): add retries for universe_domain endpoint on MDS client#5310

Open
alvarowolfx wants to merge 1 commit intogoogleapis:mainfrom
alvarowolfx:impl-auth-mds-client-retry
Open

impl(auth): add retries for universe_domain endpoint on MDS client#5310
alvarowolfx wants to merge 1 commit intogoogleapis:mainfrom
alvarowolfx:impl-auth-mds-client-retry

Conversation

@alvarowolfx
Copy link
Copy Markdown
Collaborator

Towards #3646

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 91.60839% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.76%. Comparing base (146ab54) to head (74d1acc).

Files with missing lines Patch % Lines
src/auth/src/mds/client.rs 91.60% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5310      +/-   ##
==========================================
- Coverage   97.78%   97.76%   -0.03%     
==========================================
  Files         220      220              
  Lines       45833    45975     +142     
==========================================
+ Hits        44818    44947     +129     
- Misses       1015     1028      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alvarowolfx alvarowolfx marked this pull request as ready for review April 7, 2026 17:04
@alvarowolfx alvarowolfx requested review from a team as code owners April 7, 2026 17:04
Comment on lines +145 to +147
if !retry_config.has_retry_config() {
return self.send(request, error_message).await;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: This doesn't seem like a special case. I think we should always use a retry loop, and the default settings are policies that don't retry. That is less complexity IMO.

Comment on lines +153 to +172
let req = request
.try_clone()
.expect("client libraries only create builders where `try_clone()` succeeds");
let response = req
.send()
.await
.map_err(google_cloud_gax::error::Error::io)?;

let status = response.status();
if !status.is_success() {
let err_headers = response.headers().clone();
let err_payload = response.bytes().await.map_err(|e| {
google_cloud_gax::error::Error::transport(err_headers.clone(), e)
})?;
return Err(google_cloud_gax::error::Error::http(
status.as_u16(),
err_headers,
err_payload,
));
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are we duping the send(...) code? can we reuse it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

send(...) maps errors to Credentials Errors and is simpler (we don't need to clone requests). On the retry loop we need to map to gax errors and clone requests. I tried to reuse both, but code was not looking nicer. We could make send(...) already return gax errors and map later to credentials errors, but we can loose some information as gax errors are more specific

pub(crate) fn universe_domain(&self) -> UniverseDomainRequest {
UniverseDomainRequest {
client: self.clone(),
retry_config: RetryConfig::default(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what about creating the policies once, and storing them on the client?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we want to have different policies per call, because the MDS Client is reused on the MDS Credentials provider. For calls to fetch tokens we don't want retries, because the TokenCache already handles retries. We only want retries here for universe_domain calls

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What I want is to allocate the policies once.

If we only make one attempt to get the universe_domain per credentials, then it's fine to do it on that call.

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.

2 participants