Secondary ip addresses on network interfaces not showing

Bug #1394127 reported by Michael Foord
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
goamz
Invalid
Undecided
Unassigned

Bug Description

If I create an instance in a region with a default-vpc, and use the AssignPrivateIPAddresses api to add a new private ip address to the network interface for the instance, the new ip address is not shown on the network interface after a call to Instances.

The code below illustrates the problem. It creates the instance and adds the ip address. It sleeps 30 seconds so you can manually confirm that the new address is showing in the dashboard (and to rule out "eventual consistency" as the cause of the bug). It then fetches an updated version of the instance and prints out the network interface.

I would expect the "PrivateIPs" field to contain the new address.

package main

import (
        "fmt"
        "time"

        "launchpad.net/goamz/aws"
        "launchpad.net/goamz/ec2"
        "launchpad.net/goamz/ec2/ec2test"
        "launchpad.net/goamz/s3/s3test"
)

func setupServer() {
        ec2srv, err := ec2test.NewServer()
        if err != nil {
                panic(err)
        }
        config := &s3test.Config{}
        s3srv, err := s3test.NewServer(config)
        if err != nil {
                panic(err)
        }
        aws.Regions["test"] = aws.Region{
                Name: "test",
                EC2Endpoint: ec2srv.URL(),
                S3Endpoint: s3srv.URL(),
                S3LocationConstraint: true,
                Sign: aws.SignV2,
        }
        ec2srv.SetInitialAttributes(map[string][]string{
                "default-vpc": []string{"vpc-xxxxxxx"},
        })
}

func main() {
        //setupServer()
        // region := aws.Regions["test"]
        region := aws.APSoutheast2 // our region with default-vpc
        auth, err := aws.EnvAuth()
        if err != nil {
                panic(err.Error())
        }
        e := ec2.New(auth, region)
        options := &ec2.RunInstances{
                ImageId: "ami-b90c6083", // ap-southeast-2 specific
                //ImageId: "ami-ccf405a5", // Ubuntu Maverick, i386, EBS store
                InstanceType: "t1.micro"}
        resp, err := e.RunInstances(options)
        if err != nil {
                panic(err)
        }

        // display the network interface
        fmt.Printf("Network interface on new instance.\n")
        fmt.Printf("%#v\n\n", resp.Instances[0].NetworkInterfaces[0])

        instanceId := resp.Instances[0].InstanceId
        netId := resp.Instances[0].NetworkInterfaces[0].Id

        // response is useless here
        aResp, err := e.AssignPrivateIPAddresses(netId, []string{}, 1, false)
        if err != nil {
                panic(err)
        }
        fmt.Printf("Response from assign private ip addresses.\n")
        fmt.Printf("%#v\n\n", aResp)

        time.Sleep(30 * time.Second)

        iResp, err := e.Instances([]string{instanceId}, nil)
        // display the updated network interface
        fmt.Printf("Updated network interface from instance.\n")
         fmt.Printf("%#v\n", iResp.Reservations[0].Instances[0].NetworkInterfaces[0])
}

Revision history for this message
Michael Foord (mfoord) wrote :

It turns out that the response from ec2 includes the network interface but does *not* include the secondary ip address information. So this bug is invalid. Use "NetworkInterfaces" (which does include it).

Changed in goamz:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.