-
Notifications
You must be signed in to change notification settings - Fork 53
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
Refactor AWS client creation #332
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #332 +/- ##
============================================
- Coverage 24.04% 23.62% -0.43%
+ Complexity 542 538 -4
============================================
Files 169 172 +3
Lines 8895 8996 +101
Branches 1230 1223 -7
============================================
- Hits 2139 2125 -14
- Misses 6543 6661 +118
+ Partials 213 210 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
src/main/java/com/conveyal/datatools/common/utils/AWSUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/editor/controllers/api/SnapshotController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/controllers/api/ServerController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/jobs/DeployJob.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/jobs/DeployJob.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/jobs/MonitorServerStatusJob.java
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/models/FeedSource.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/models/FeedSource.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/persistence/FeedStore.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/jobs/RecreateBuildImageJob.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/jobs/PublishProjectFeedsJob.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/common/utils/NonRuntimeAWSException.java
Outdated
Show resolved
Hide resolved
I'm calling the request to fix #269 out of scope for this PR. Also, I ended up adding some more fault tolerance to the DeployJob so that it will properly fail in certain circumstances and still gracefully wait for the termination of the RecreateBuildImageJob. |
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.
This looks great. Looks like @landonreed swept through everything already. I have a few minor questions/suggestions as noted but otherwise this can be merged.
src/main/java/com/conveyal/datatools/manager/controllers/api/FeedVersionController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/controllers/api/ProjectController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/controllers/api/ServerController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/conveyal/datatools/manager/jobs/DeployJob.java
Outdated
Show resolved
Hide resolved
status.update("Creating build image", 5); | ||
// Create a new image of this instance. | ||
CreateImageRequest createImageRequest = new CreateImageRequest() | ||
.withInstanceId(graphBuildingInstances.get(0).getInstanceId()) | ||
.withName(otpServer.ec2Info.buildImageName) | ||
.withDescription(otpServer.ec2Info.buildImageDescription); | ||
CreateImageResult createImageResult = ec2.createImage(createImageRequest); | ||
// Wait for image creation to complete (it can take a few minutes) | ||
CreateImageResult createImageResult = null; |
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 previous syntax looks cleaner. I am not sure I like this pattern of declaring a variable then assigning it inside of the try/catch block, although we may be stuck with that.
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.
How would a syntax like the one below work?
CreateImageResult createImageResult = tryCreateImage(...);
if (createImageResult) {
// do the things.
}
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.
There would still need to be a clause to handle the failure case, so I think this actually adds more code.
@evansiroky, looks to be good to merge. I'm going to apply |
Some changes have been pushed to address PR review, and this has been verified to work for MTC-QA. I'm removing the blocked tag and reassigned for review. |
🎉 This PR is included in version 3.8.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Checklist
dev
before they can be merged tomaster
)Description
The creation of various AWS clients was happening in various random places and in multiple different methods of creation. This PR seeks to standardize the creation of AWS clients in a central place in the AWSUtils class. All classes that use an AWS client have been refactored to obtain a client from the AWSUtils class. Within the AWSUtils class, each AWS client is created and stored in an in-memory cache. Furthermore, clients that are dependent on a role (and thus the creation of a session) will automatically renew their session/client as needed.
This PR also adds additional exception handling in various places as this refactor will throw non-runtime exceptions which the compiler will flag as needed to be caught. This can help identify places where AWS exceptions that are Runtime Exceptions (which the compiler doesn't flag as needing to be caught) are probably thrown.
This PR is built on top of #331.