Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(121)

Issue 60620043: ec2: Added NIC support for RunInstances (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by dimitern
Modified:
10 years, 2 months ago
Reviewers:
niemeyer, mp+205148, natefinch, rog
Visibility:
Public.

Description

ec2: Added NIC support for RunInstances This extends RunInstances options to include a list of NetworkInterfaceSpec options. They allow specifying NICs to attach to instances at launch time (either existing or new NICs). It also adds SubnetId, VPCId, SourceDestCheck, and NetworkInterfaces fields to the Instance type, so Instances() and RunInstances() can return the extended VPC-related information for an instance. If any NetworkInterfaceSpec options are provided, or SubnetID is given, RunInstances() will use the latest AWS API version (2013-10-15), otherwise it uses the default version (2011-12-15). Modified terminateInstances() test helper to wait and retry when running against live EC2 servers, to make sure the instances are really gone and not left hanging after the test (leaking related resources with them). In order for this to work with the local testing server, a slight change was made - when an instance is terminated, the next time you fetch it with Instances(), it will report "terminated" (thus simulating the real state transition). Added vpc-id and subnet-id filters to ec2test's Instance and securityGroup types, and also changed TestGroupFiltering and TestInstanceFiltering to include tests for them. Test double changed to support VPC security groups and verify subnet ID in runInstances, as EC2 does. Added NewInstancesVPC() method with vpcId and subnetId, so VPC-enabled instances can be created in the test server. Added a TestRunInstancesVPC live test for the new functionality (only live, because it's not worth it to change the test double to create NICs in runInstances()). https://code.launchpad.net/~dimitern/goamz/vpc-instance-addons/+merge/205148 Requires: https://code.launchpad.net/~dimitern/goamz/nic-api-calls/+merge/204912 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : ec2: Added NIC support for RunInstances #

Total comments: 8

Patch Set 3 : ec2: Added NIC support for RunInstances #

Patch Set 4 : ec2: Added NIC support for RunInstances #

Total comments: 12

Patch Set 5 : ec2: Added NIC support for RunInstances #

Unified diffs Side-by-side diffs Delta from patch set Stats (+540 lines, -78 lines) Patch
A [revision details] View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M ec2/ec2.go View 1 2 3 4 5 chunks +132 lines, -43 lines 0 comments Download
M ec2/ec2_test.go View 1 2 3 4 3 chunks +86 lines, -0 lines 0 comments Download
M ec2/ec2t_test.go View 1 2 3 4 11 chunks +187 lines, -25 lines 0 comments Download
M ec2/ec2test/server.go View 1 2 3 4 12 chunks +56 lines, -8 lines 0 comments Download
M ec2/export_test.go View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M ec2/networkinterfaces_test.go View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M ec2/responses_test.go View 2 chunks +74 lines, -1 line 0 comments Download

Messages

Total messages: 9
dimitern
Please take a look.
10 years, 2 months ago (2014-02-06 12:42:03 UTC) #1
dimitern
Please take a look.
10 years, 2 months ago (2014-02-06 14:24:29 UTC) #2
rog
LGTM with some suggestions below. https://codereview.appspot.com/60620043/diff/20001/ec2/ec2.go File ec2/ec2.go (right): https://codereview.appspot.com/60620043/diff/20001/ec2/ec2.go#newcode299 ec2/ec2.go:299: // given, a VPC-enabled ...
10 years, 2 months ago (2014-02-06 14:56:14 UTC) #3
dimitern
Please take a look. https://codereview.appspot.com/60620043/diff/20001/ec2/ec2.go File ec2/ec2.go (right): https://codereview.appspot.com/60620043/diff/20001/ec2/ec2.go#newcode299 ec2/ec2.go:299: // given, a VPC-enabled instances ...
10 years, 2 months ago (2014-02-06 15:52:19 UTC) #4
dimitern
Please take a look.
10 years, 2 months ago (2014-02-07 12:59:30 UTC) #5
niemeyer
LGTM, but please ask for at least one more review. https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go File ec2/ec2.go (right): https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go#newcode232 ...
10 years, 2 months ago (2014-02-12 14:49:53 UTC) #6
niemeyer
https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go File ec2/ec2.go (right): https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go#newcode204 ec2/ec2.go:204: // NetworkInterfaceSpec encapsulates options for a single network Ah, ...
10 years, 2 months ago (2014-02-12 14:52:17 UTC) #7
natefinch
LGTM, just a couple nice-to-have changes https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go File ec2/ec2.go (right): https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go#newcode305 ec2/ec2.go:305: if options.SubnetId != ...
10 years, 2 months ago (2014-02-12 16:26:29 UTC) #8
dimitern
10 years, 2 months ago (2014-02-12 17:05:57 UTC) #9
*** Submitted:

ec2: Added NIC support for RunInstances

This extends RunInstances options to include
a list of NetworkInterfaceSpec options. They
allow specifying NICs to attach to instances
at launch time (either existing or new NICs).

It also adds SubnetId, VPCId, SourceDestCheck,
and NetworkInterfaces fields to the Instance
type, so Instances() and RunInstances() can
return the extended VPC-related information
for an instance.

If any NetworkInterfaceSpec options are provided,
or SubnetID is given, RunInstances() will use the
latest AWS API version (2013-10-15), otherwise it
uses the default version (2011-12-15).

Modified terminateInstances() test helper to wait
and retry when running against live EC2 servers,
to make sure the instances are really gone and
not left hanging after the test (leaking related
resources with them). In order for this to work
with the local testing server, a slight change
was made - when an instance is terminated, the
next time you fetch it with Instances(), it will
report "terminated" (thus simulating the real
state transition).

Added vpc-id and subnet-id filters to ec2test's
Instance and securityGroup types, and also changed
TestGroupFiltering and TestInstanceFiltering to
include tests for them.

Test double changed to support VPC security groups
and verify subnet ID in runInstances, as EC2 does.
Added NewInstancesVPC() method with vpcId and subnetId,
so VPC-enabled instances can be created in the test
server.

Added a TestRunInstancesVPC live test for the new
functionality (only live, because it's not worth
it to change the test double to create NICs in
runInstances()).

R=rog, niemeyer, nate.finch
CC=
https://codereview.appspot.com/60620043

https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go
File ec2/ec2.go (right):

https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go#newcode204
ec2/ec2.go:204: // NetworkInterfaceSpec encapsulates options for a single
network
On 2014/02/12 14:52:17, niemeyer wrote:
> Ah, and as we discussed, this type should be something along the lines of
> 
>     RunNetworkInterface
> 
> It's an unfortunate name, but I cannot come up with anything better that is
not
> absurdly long.
> 
> For the record, the generic name "NetworkInterfaceSpec" sounds like a problem
> because this is actually a set of options that only really make sense in the
> specific context of RunInstances. We already have another bag of data that
only
> really makes sense in the context of CreateNetworkInterface.  If we need one
> more, will we name it NetworkInterface..Data?..Stuff?

Done.

https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go#newcode232
ec2/ec2.go:232: SecondaryPrivateIPsCount int
On 2014/02/12 14:49:53, niemeyer wrote:
> s/IPsCount/IPCount/, as per the previous point?

Done.

https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go#newcode305
ec2/ec2.go:305: if options.SubnetId != "" || len(options.NetworkInterfaces) > 0
{
On 2014/02/12 16:26:29, nate.finch wrote:
> I'd like to have this extracted into a standalone function so it can be tested
> by itself.

Extracted and added a test.

https://codereview.appspot.com/60620043/diff/60001/ec2/ec2.go#newcode362
ec2/ec2.go:362: for i, ni := range options.NetworkInterfaces {
On 2014/02/12 16:26:29, nate.finch wrote:
> I'd really prefer if the internals to this and the loop above were factored
out
> into separate functions. I know you didn't write the loop above, but it would
> cut down on the size of this already pretty large function.

I've extracted both loops in separate helpers.

https://codereview.appspot.com/60620043/diff/60001/ec2/ec2t_test.go
File ec2/ec2t_test.go (right):

https://codereview.appspot.com/60620043/diff/60001/ec2/ec2t_test.go#newcode141
ec2/ec2t_test.go:141: c.Assert(err, IsNil, Commentf("%d INSTANCES LEFT
RUNNING!!!", ids))
On 2014/02/12 16:26:29, nate.finch wrote:
> either len(ids) or %v here, right?

Oops, thanks! Done.

https://codereview.appspot.com/60620043/diff/60001/ec2/ec2t_test.go#newcode146
ec2/ec2t_test.go:146: Total: 10 * time.Minute,
On 2014/02/12 16:26:29, nate.finch wrote:
> do we really want tests that might wait 10 minutes?

Yes, I think so. I've adjusted this value after numerous live test runs.
Sometimes EC2 just gets stubborn and an instance is stuck in "shutting-down"
state for like 10m, and you can't even terminate it from the EC2 console. So
shutting down instances cleanly could take a while longer than other entities.
We'll never wait that long when running the "fake live" tests or when EC2 works
as expected.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b