Skip to content

IMDS Release #3723

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

Closed
wants to merge 14 commits into from
Closed

IMDS Release #3723

wants to merge 14 commits into from

Conversation

L-Applin
Copy link
Contributor

@L-Applin L-Applin commented Jan 27, 2023

Implementation of the Ec2 Instance Metadata Client

Release moved to #3725

Motivation and Context

Part of the V2.x parity effort.

Modifications

Creates a new module for the Client with

  • Sync Client interface + implementation
  • Async Client interface + implementation

Testing

Added unit test for clients using Wiremock

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

srsaikumarreddy and others added 14 commits June 21, 2022 15:38
* Created the Configuration class for Ec2Metadata

* Added CR comments in EndpointMode.java

Co-authored-by: Sai Chandupatla <[email protected]>
* Implemented Happy Path client functionality along with Request Marshaller Class

* Changed expected Exception message in Test Case

* Incorporated PR feedback

* Fixed SonarCloud Issues

Co-authored-by: Sai Chandupatla <[email protected]>
* Implemented Response Handling and Parsing Methods for output

* Added Javadoc info

* Implemented PR comments

* Changed dependency scope

Co-authored-by: Sai Chandupatla <[email protected]>
* Implemented Retries functionality

* Incorporated Code Review comments

* Implemented PR Changes-2

* Adding CR review files

* Implemented CR comments -4

* nit comment fixed

Co-authored-by: Sai Chandupatla <[email protected]>
* Placed EndpointMode.java outside internal folder. Increased Test Coverage

* Removed aws-json-protocol dependency

* Added test cases for DocumentUnMarshaller

Co-authored-by: Sai Chandupatla <[email protected]>
* Added Apache Client tests

* Removed extra space in imds pom file

* Removed duplicated cases as per PR comments

* Removed duplicated cases as per PR comments

Co-authored-by: Sai Chandupatla <[email protected]>
* IMDS Ec2 Metada refactoring

* IMDS Ec2 Metada refactoring

* IMDS Ec2 Metada refactoring

* IMDS Ec2 Metada refactoring

* IMDS Ec2 Metada refactoring

* IMDS Ec2 Metada refactoring

* IMDS Ec2 Metada refactoring

* fix checkstyle error

* Increase IMDS test code coverage
* IMDS Async client

* Fix test classes

* JavaDoc

* PR comments and added IMDS to test-coverage-reporting
- Create a common builder Ec2MetadataClientBuilder
- Create a common test class BaseEc2MetadataClientTest
- Refactor common initialization logic for both sync and async client in BaseEc2MetadataClient class
- Use netty async client in unit tests
- fix Async error logic

* Improve JavaDoc and rename some variables
- fix one failing unit test
* IMDS Async

* IMDS Async client

* Token caching in sync and async client and sync client unit test

* Async token caching with retry

* Temporarily remove AsyncClient token cache implementation
- Pr comments

* internal Api for token cache strategies
Async token cache implementation
* Surface area review
- removed getters on client builder public interface
- rename MetadataResponse to Ec2MetadataResponse
- add builder-consumer for retry policy
- add DefaultSdkAsyncHttpClientBuilder and DefaultSdkHttpClientBuilder to client builders
- remove duplication in BaseEc2MetadataClient constructors
- TokenResponseHandler cleanup
- Updated ttl header logic if not found in response headers
- use SdkHttpClient.Builder in IMDS Client Builder interface
- Javadoc
- Async Http Request Handlers refactor
- add test for mutual exclusion of http client and http client builder in IMDS client builders
- dont retry on bad response format from server
* feature changelog
@L-Applin L-Applin requested a review from a team as a code owner January 27, 2023 21:59
<url>https://aws.amazon.com/sdkforjava</url>

<dependencies>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: can we organize the dependencies a bit by separating compile and test dependencies ? Non-test dependencies should be put to the top.

<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this module only have JUnit5 tests only? If so, let's remove JUnit4 dependencies to avoid the chances of mixing JUnit4 and JUnit5 annotations. See https://github.com/aws/aws-sdk-java-v2/blob/master/services-custom/s3-transfer-manager/pom.xml#L121-L130

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, will do that to prevent any junit4 dependency in the classpath

import software.amazon.awssdk.utils.SdkAutoCloseable;

/**
* Interface to represent the Ec2Metadata Client Class. Used to access instance metadata from a running instance.
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add some code snippets using {@snippet}

/**
* Gets the specified instance metadata value by the given path. For more information about instance metadata, check the
* <a href=https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html>Instance metadata documentation</a>.
*
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a code sample here as well. Same as sync client.

@L-Applin L-Applin closed this Jan 30, 2023
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.

3 participants