-
Notifications
You must be signed in to change notification settings - Fork 970
Saikred/feature/happy path #3276
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
Saikred/feature/happy path #3276
Conversation
|
|
||
| private final SdkHttpClient httpClient; | ||
|
|
||
| private final Logger log = LoggerFactory.getLogger(DefaultEc2Metadata.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted.
|
|
||
| private final Logger log = LoggerFactory.getLogger(DefaultEc2Metadata.class); | ||
|
|
||
| private RequestMarshaller requestMarshaller = new RequestMarshaller(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted.
core/imds/src/main/java/software/amazon/awssdk/imds/internal/DefaultEc2Metadata.java
Show resolved
Hide resolved
| try { | ||
| String token = getToken(); | ||
| URI uri = URI.create(endpoint + path); | ||
| HttpExecuteRequest httpExecuteRequest = requestMarshaller.createDataRequest(uri , SdkHttpMethod.GET, token, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra space before comma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch . Surprising that when I ran checkstyle during local build , it did not show up as warning/error.
| URI uri = URI.create(endpoint + path); | ||
| HttpExecuteRequest httpExecuteRequest = requestMarshaller.createDataRequest(uri , SdkHttpMethod.GET, token, | ||
| tokenTtl); | ||
| HttpExecuteResponse response = httpClient.prepareRequest(httpExecuteRequest).call(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra space after =
core/imds/src/main/java/software/amazon/awssdk/imds/internal/DefaultEc2Metadata.java
Outdated
Show resolved
Hide resolved
| } else if (statusCode == HttpURLConnection.HTTP_FORBIDDEN || statusCode == HttpURLConnection.HTTP_BAD_REQUEST) { | ||
| throw SdkServiceException.builder().message("Could not retrieve token").build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we log the status code? Any reason to have this be a different case than just the else clause below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The status codes mentioned , should not have retries enabled on them. But for the below else case , retries can happen.
| throw SdkServiceException.builder().message("Could not retrieve token").build(); | ||
| } else { | ||
| throw SdkClientException.builder() | ||
| .message("Unexpected Exception during token retrieval with Status Code " + statusCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
core/imds/src/main/java/software/amazon/awssdk/imds/internal/RequestMarshaller.java
Outdated
Show resolved
Hide resolved
core/imds/src/main/java/software/amazon/awssdk/imds/internal/RequestMarshaller.java
Outdated
Show resolved
Hide resolved
| } else { | ||
| throw SdkClientException.builder() | ||
| .message("Unexpected Exception during token retrieval with Status Code " + statusCode) | ||
| .message("Instance metadata service returned unexpected status code " + statusCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the response body isn't present then we'd get unexpected status code 200. Should we special-case the response body not being present with a better error message?
bd36583 to
cb67094
Compare
|
SonarCloud Quality Gate failed. |








Implemented Happy Path client functionality along with Request Marshaller Class
Motivation and Context
Implemented Happy Path client functionality along with Request Marshaller Class
Modifications
Implemented Happy Path client functionality along with Request Marshaller Class. Wrote test cases to check exception handling behavior
Testing
Ran test cases locally in development environment.
Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License