get_all_instances is missing instances #1348

Open
pchico opened this Issue Feb 22, 2013 · 7 comments

4 participants

@pchico

I am doing this code to create instances in amazon and wait for them to be running:

reservation = ec2_connection.run_instances(
    image_id=resource.machine_image_name,
    min_count=1, 
    max_count=1, 
    key_name=resource.keypair_name,
    security_groups=[group_name],
    user_data=user_data, 
    instance_type=resource.flavor)

instance_id = reservation.instances[0]
log_info('Amazon created instances {0}'.format(instance_id))

reservation = None
while reservation is None or len(reservation) == 0 or reservation[0].instance[0].state != 'pending': 
  try:
      reservation = ec2_connection.get_all_instances(instance_ids=[instance_id])
  except EC2ResponseError as exception:
      if exception.error_code != 'InvalidInstanceID.NotFound':
          raise      

It is working well for most of the cases, but sometimes (1 of 100), it happens this:

  • I get a value for isntance_id
  • A machine with instance_id is running in amazon
  • ec2_connection.get_all_instances(instance_ids=[instance_id]) returns [] for ever

    Am I doing something wrong? Is this a bug in the library?

@amirbaron

I encountered the same problem.
I also tried with the official amazon aws for bash and I can get the instances there

@danielgtaylor
the boto project member

@amirbaron is there anything else interesting about your setup? Do you have a lot of instances or just a few? Can you reliably reproduce the issue and if so then how? Is it possible your requests are being throttled by EC2 and Boto is handling that poorly?

@methane

get_all_instance() returns not running instances, but returns reserved instances, maybe.

@danielgtaylor
the boto project member

@pchico any further info you can provide about this issue?

@amirbaron

Hi, this is not a bug.
I just launched few instances together so they have been in the same reservation and my code has a bug it assume there is one instance per reservation.

@danielgtaylor
the boto project member

@pchico have you resolved your issue from the comments above as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment