Skip to content
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

Split core module to core, aws-auth and aws-core #475

Merged
merged 1 commit into from
May 11, 2018

Conversation

zoewangg
Copy link
Contributor

@zoewangg zoewangg commented May 2, 2018

Description

Splitting core module to auth, core, aws-core and profiles modules.

  • regions: regions classes
  • profiles: contains profile classes.
  • auth: contains credentials, aws signer classes
  • aws-core: core runtime classes used by aws java clients.
  • core: core runtime classes.

Dependencies:
profiles -> core
regions -> profiles
auth -> regions
aws-core -> auth
services -> aws-core
Apigatway generated clients -> core
Apigatway generated clients using IAM role -> core, auth

Motivation and Context

Related to #27
Note: This is the first task to move out AWS related classes.
The rest of the tasks left are:

  • ResponseHandler and Json error response handler classes are still dealing with aws headers and need to be moved to aws-core.
  • CRC32_FROM_COMPRESSED_DATA_ENABLED needs to be moved to aws-core module once we replace the legacyHttpResponse with SdkHttpFullResponse

Testing

mvn clean install and all integration tests were passed

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 read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG

License

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

@kiiadi
Copy link
Contributor

kiiadi commented May 3, 2018

Out of interest why aws-auth / aws-core rather than just auth and core ? we're already bounded by the AWS groupId and it means we have repetition in the package name as well: software.amazon.awssdk.awsauth.credentials for exampl has "aws" in it twice.

@zoewangg
Copy link
Contributor Author

zoewangg commented May 3, 2018

This motivation of splitting core module is to break out AWS related concepts(AWS credentials, AWS signers, etc) to a separate module so that the clients generated from API gateway API just needs to depend on core module rather than pulling the whole AWS-specific logic.

As to the naming, using aws-auth makes is clear that it contains AWS related authentication classes and applies to all AWS services. The clients generated from API gateway don't need to depend on it unless they use IAM roles for authentication.

I thought about updating core to sdk-core to differentiate from aws-core, but don't have strong opinions and open to discussion.

@kiiadi
Copy link
Contributor

kiiadi commented May 3, 2018

I suppose that makes the thought process a little clearer - but from a customer perspective do you think they're going to notice the subtly between software.amazon.awssdk:auth and software.amazon.awssdk:aws-auth? As I say, we're already in the awssdk groupId.

Copy link
Contributor

@shorea shorea left a comment

Choose a reason for hiding this comment

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

Still working my way through this. I'll revisit after lunch.

@@ -32,39 +34,14 @@
+ "4. The remaining public AWS stuff should be moved to the AWS module. "
+ "We should also consider making some of the SDK/AWS-owned set of attributes part of the immutable context "
+ "if we don't want the interceptors to modify them.")
public final class AwsExecutionAttributes {
public interface AwsExecutionAttributes extends SdkExecutionAttributes {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be more of an awscore thing rather than auth specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used by Aws4Signer for now to get the credentials from ExecutionAttributes. I guess this will be moved around once we start working on signer refactor.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shirley the awsauth module should depend on awscore?

@@ -43,9 +35,8 @@
public enum AwsSystemSetting implements SystemSetting {
Copy link
Contributor

Choose a reason for hiding this comment

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

Belongs in awscore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used by some credential providers, eg:SystemSettingsCredentialsProvider is using it to locate the credentials.

@@ -132,7 +132,7 @@ public void close() {
private String asyncThreadName;

/**
* Created using {@link #builder()}.
* Created using {@link #build()}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicky but this seemed more correct before. Comment is mostly useless though anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, removed

@@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.core.internal.net;
package software.amazon.awssdk.awsauth.credentials.internal;
Copy link
Contributor

Choose a reason for hiding this comment

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

For ConnectionUtils we should consider refactoring to use the SDK HTTP client instead of URL connection. Also we should consider putting the ec2 metadata "client" into it's own module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added ReviewBeforeRelease on it

@@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.auth.profile;
package software.amazon.awssdk.awsauth.credentials.profile;
Copy link
Contributor

Choose a reason for hiding this comment

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

The profile stuff may be better place in it's own module. It isn't just credentials and region and we may expand on it in the future to include other profile configuration.

@@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.core.regions;
package software.amazon.awssdk.awsauth.regions;
Copy link
Contributor

Choose a reason for hiding this comment

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

Auth and region are related but not necesarrily coupled. Should region related stuff be in a separate module?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can further split aws-auth module to region, profile, credentials, signer, I'll try and see how it looks like, not sure if they have circular dependency right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

profile classes are moved to profiles module via commit 70825f4.

As to regions and credential classes, they are tightly coupled now because they share common functionalities to to retrieve regions/creds from local EC2 instances in HttpCredentialUtils, endpointRetry and other classes, unless we break out those class to a separate module, it's difficult to separate them. If we are going with that route, we might end up having plenty "micro" modules and it could increase our maintenance burden and unlike profiles, regions and creds seem to be always used together.

}
return expirationInSeconds;
}

private boolean isAnonymous(AwsCredentials credentials) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why inline this but not in query string signer? Should this be moved up to abstract?

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 catch, fixed

@@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.core.auth;
Copy link
Contributor

Choose a reason for hiding this comment

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

There may be other places where we'd want to mock the clock. This can be moved up to the generic core.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.core.auth.internal;
package software.amazon.awssdk.awsauth.signer;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you sync up with @varunnvs92 about the signer refactoring? I'd imagine there will be another module like signer-spi that has just the interfaces for signing and awsauth contains the AWS specific implementations like SigVn


import java.net.URI;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.regions.Region;
import software.amazon.awssdk.core.runtime.endpoint.DefaultServiceEndpointBuilder;
import software.amazon.awssdk.awsauth.regions.Region;
Copy link
Contributor

Choose a reason for hiding this comment

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

EndpointUtils feels more like awscore than auth.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -51,7 +53,7 @@ public void testSigning() throws Exception {
"Signature=e73e20539446307a5dc71252dbd5b97e861f1d1267456abda3ebd8d57e519951";


AwsCredentials credentials = new AwsCredentials("access", "secret");
AwsCredentials credentials = AwsCredentials.create("access", "secret");
Copy link
Contributor

Choose a reason for hiding this comment

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

How was this compiling before? Was the constructor protected? If so should we make it private?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the constructor is protected and this class was in the same package with AwsCredentials. can't make is private since it has child classes.

final class SdkAsyncClientHandlerImpl extends BaseAsyncClientHandler implements AsyncClientHandler {

@ReviewBeforeRelease("Should this be migrated to use a params object, particularly because it crosses module boundaries?" +
"We might also need to think about how it will work after AWS/SDK are split.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment now addressed?

@@ -68,7 +68,7 @@ private ClientAsyncHttpConfiguration(DefaultHttpConfigurationBuilder builder) {
* to ease resolution of the client. Returns an empty {@link Optional} if neither is set.
*/
@SdkInternalApi
Optional<Either<SdkAsyncHttpClient, SdkAsyncHttpClientFactory>> toEither() {
public Optional<Either<SdkAsyncHttpClient, SdkAsyncHttpClientFactory>> toEither() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I don't like this. Is there anything we can do about it? Maybe a ReviewBeforeRelease annotation as I believe we want to flatten this out anyways which could make this cleaner.

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 catch. public was added in the middle of the work before I moved the duplicate codes to parent class and I forgot to remove it. Fixed

@@ -55,15 +55,15 @@

@ThreadSafe
@SdkInternalApi
public class AmazonHttpClient implements SdkAutoCloseable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a ReviewBeforeRelease annotation to come up with a better name for this and the async variant?

private boolean shouldSign(Signer signer, AwsCredentials credentials) {
return signer != null && (credentials != null || signer instanceof CanHandleNullCredentials);
private boolean shouldSign(Signer signer) {
return signer != null;
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a behavior change. Is this okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the credential check because core is no long aware of AwsCredentials. Will add a note here to add back this logic when we start working on signer refactor

* The key under which the request config is stored.
*/
@ReviewBeforeRelease("RequestConfig feels pretty internal. Can we just expose parts of it?")
ExecutionAttribute<RequestOverrideConfig> REQUEST_CONFIG = new ExecutionAttribute<>("RequestConfig");
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment doesn't seem to apply anymore since RequestOverrideConfig is a public class.

@shorea
Copy link
Contributor

shorea commented May 4, 2018

This may be out of scope of this review but I think the other couplings we have to AWS in core is the retry related stuff. How we detect throttling and clock skew is a bit AWS specific (moreso throttling).

I think there is also some coupling in the marshalling/unmarshalling paths. Particularly around the response handlers and error response handlers.

@zoewangg
Copy link
Contributor Author

zoewangg commented May 4, 2018

Yes, this PR is just the first step and there are still some remaining AWS functionality such as parsing aws headers in response handler, stax response marshaller, retry related stuff as you mentioned. To keep PR smaller(it's already huge as it is..), I will create separate PR for each of the remaining task.

@zoewangg zoewangg merged commit 2bb7e5b into master May 11, 2018
@zoewangg zoewangg deleted the CoreModuleBreakDown branch May 11, 2018 22:44
@dagnir dagnir mentioned this pull request Jun 27, 2018
aws-sdk-java-automation added a commit that referenced this pull request Apr 16, 2019
…2cb15bf8

Pull request: release <- staging/416f5504-caf9-45ad-a842-345f2cb15bf8
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