-
Notifications
You must be signed in to change notification settings - Fork 156
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
Implementation for com.rultor.agents.ec2.Amazon interface - Issue #755 #760
Conversation
Remove todo annotation from Amazon
Thanks for your pull request, let me find someone who can review it |
@krzyk cuold you review this pull request |
* Creates a new {@link RunInstancesRequest}. | ||
* @return The {@link RunInstancesRequest} created | ||
*/ | ||
private RunInstancesRequest createRequest() { |
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.
just create()
is enough
@Marczeeee some comments above, and would be nice to have a test for this |
@krzyk I made the suggested changes in the code, and please see my comment about the waiting in execution. By the way it isn't so easy to test the functionality of this class as it performs direct request to Amazon to run a new EC2 instance. |
final List<Instance> instances = client.runInstances( | ||
this.create() | ||
).getReservation().getInstances(); | ||
if ((instances != null) && !instances.isEmpty()) { |
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.
According to Amazon docs:
One or more instances.
So it shouldn't return 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.
also, please also invert the if check ( not
checks are confusing, that's why PMD complains) and remove Suppress from above
So the if would look like this:
if (instances.isEmpty()) {
throw new IllegalStateException("No Instance was available in the RunInstanceRequest reply!");
} else {
instance = instances.get(0);
}
@Marczeeee and more comment and we are ready to go |
@krzyk Done. |
@rultor merge pls |
throw new IllegalStateException( | ||
"No Instance was available in the RunInstanceRequest reply!" | ||
); | ||
} else { |
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.
TimeUnit.SECONDS.sleep(Tv.FIFTEEN); | ||
} catch (final InterruptedException ex) { | ||
Thread.currentThread().interrupt(); | ||
break; |
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.
why swallowing the exception? why can't we just throw it up, wrapped into IllegalStateException
@Marczeeee a few comments from me above. besides that, what about a test? how do you know all this works? |
@yegor256 The suggested changes are done. The problem with the test is that after calling 'runOnDemand()' it will connect to Amazon to run the instance. |
Isse #755