Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use Ec2MetadataClient in defaults mode#6301

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
S-Saranya1 wants to merge11 commits intofeature/master/use-imds-client
base:feature/master/use-imds-client
Choose a base branch
Loading
fromsomepal/Use-IMDS-Client
Open
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Additional changes
  • Loading branch information
@S-Saranya1
S-Saranya1 committedJul 29, 2025
commitad0fd2704eef769da2051bbe524009b4b96de341
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,7 @@ private DefaultEc2MetadataClientWithFallback(Ec2MetadataBuilder builder) {

this.imdsV1FallbackEnabled = !resolveImdsV1Disabled();

this.tokenCache = CachedSupplier.builder(() -> RefreshResult.builder(this.getToken())
this.tokenCache = CachedSupplier.builder(() -> RefreshResult.builder(this.getTokenWithFallback())
.staleTime(Instant.now().plus(tokenTtl))
.build())
.cachedValueName(toString())
Expand DownExpand Up@@ -122,7 +122,7 @@ public Ec2MetadataResponse get(String path) {
RetryPolicyContext retryPolicyContext = RetryPolicyContext.builder().retriesAttempted(attempt).build();
try {
if (token == null || token.isExpired()) {
token =getTokenWithFallback();
token =tokenCache.get();
}
return sendRequest(path, token != null ? token.value() : null);
} catch (UncheckedIOException | RetryableException e) {
Expand DownExpand Up@@ -154,13 +154,13 @@ public Ec2MetadataResponse get(String path) {
}

/**
* Gets token with fallback logic thatmatches EC2MetadataUtils behavior.
* Gets token with fallback logic thatcan be cached.
* If token retrieval fails with 400 error, throws exception.
* Otherwise, returns null to indicate fallback to IMDSv1.
*/
private Token getTokenWithFallback() {
try {
returntokenCache.get();
returngetToken();
} catch (Exception e) {
boolean is400ServiceException = e instanceof Ec2MetadataClientException
&& ((Ec2MetadataClientException) e).statusCode() == 400;
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp