Project

General

Profile

Actions

Bug #13779

closed

Setting compute profile in EC2 provisioning over-rides image AMI with a default AMI

Added by Matthew Ceroni almost 9 years ago. Updated almost 9 years ago.

Status:
Duplicate
Priority:
High
Assignee:
-
Category:
Compute resources - EC2
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

For EC2 provisioning, setting the compute profile on a new host causes a default AMI to be set that differs from the AMI set in the image associated with the compute resource.

Steps to reproduce:

1) add a new AWS EC2 compute resource
2) create an image, set an AMI (in this case an HVM AMI)
3) create t2.micro compute profile (t2.micro requires HVM AMI)
4) set the image on compute profile to the image you created in step 2
5) provision a host, setting compute profile and image (on Operating System Page)

AWS will report back message:

InvalidParameterCombination</Code><Message>Virtualization type 'hvm' is required for instances of type 't2.micro'. Ensure that you are using an AMI with virtualization type 'hvm'. For more information, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html

Which is confusing since the AMI set on the image is of type HVM. I setup a developer install of Foreman and enable compute resource API debug. The following was noted:

excon.request
  :body                => "Action=RunInstances&ImageId=ami-e0ec60d0&InstanceType=t2.micro&KeyName=foreman-1c5b55767-4b56-46a0-a8ec-955757c4f9df&MaxCount=1&MinCount=1&Placement.AvailabilityZone=us-west-2b&SecurityGroupId.1=sg-f52ffd92&SubnetId=subnet-420be726&Version=2014-10-01" 
  :chunk_size          => 1048576
  :ciphers             => "HIGH:!SSLv2:!aNULL:!eNULL:!3DES" 
  :connect_timeout     => 60
  :debug_request       => true
  :debug_response      => true
  :expects             => 200
  :headers             => {
    "Authorization" => "REDACTED" 
    "Content-Type"  => "application/x-www-form-urlencoded" 
    "Host"          => "ec2.us-west-2.amazonaws.com" 
    "User-Agent"    => "fog-core/1.35.0" 
    "x-amz-date"    => "20160217T205521Z" 
  }
  :host                => "ec2.us-west-2.amazonaws.com" 
  :hostname            => "ec2.us-west-2.amazonaws.com" 
  :idempotent          => false
  :instrumentor        => Excon::StandardInstrumentor
  :instrumentor_name   => "excon" 
  :method              => "POST" 
  :middlewares         => [
    Excon::Middleware::ResponseParser
    Excon::Middleware::Expects
    Excon::Middleware::Idempotent
    Excon::Middleware::Instrumentor
    Excon::Middleware::Mock
  ]
  :mock                => false
  :nonblock            => true
  :omit_default_port   => false
  :path                => "/" 
  :persistent          => false
  :port                => 443
  :query               => nil
  :read_timeout        => 60
  :response_block      => #<Proc:0x0000000bba69a8@/root/foreman/vendor/ruby/gems/fog-xml-0.1.2/lib/fog/xml/sax_parser_connection.rb:29 (lambda)>
  :retries_remaining   => 4
  :retry_limit         => 4
  :scheme              => "https" 
  :ssl_verify_peer     => true
  :tcp_nodelay         => false
  :thread_safe_sockets => true
  :uri_parser          => URI
  :versions            => "excon/0.45.4 (x86_64-linux) ruby/2.0.0" 
  :write_timeout       => 60
excon.error
  :error => #<Excon::Errors::BadRequest: Expected(200) <=> Actual(400 Bad Request)
excon.error.request
  :body                => "Action=RunInstances&ImageId=ami-e0ec60d0&InstanceType=t2.micro&KeyName=foreman-1c5b55767-4b56-46a0-a8ec-955757c4f9df&MaxCount=1&MinCount=1&Placement.AvailabilityZone=us-west-2b&SecurityGroupId.1=sg-f52ffd92&SubnetId=subnet-420be726&Version=2014-10-01" 
  :chunk_size          => 1048576
  :ciphers             => "HIGH:!SSLv2:!aNULL:!eNULL:!3DES" 
  :connect_timeout     => 60
  :debug_request       => true
  :debug_response      => true
  :expects             => 200
  :headers             => {
    "Authorization"  => "REDACTED" 
    "Content-Length" => 250
    "Content-Type"   => "application/x-www-form-urlencoded" 
    "Host"           => "ec2.us-west-2.amazonaws.com" 
    "User-Agent"     => "fog-core/1.35.0" 
    "x-amz-date"     => "20160217T205521Z" 
  }
  :host                => "ec2.us-west-2.amazonaws.com" 
  :hostname            => "ec2.us-west-2.amazonaws.com" 
  :idempotent          => false
  :instrumentor        => Excon::StandardInstrumentor
  :instrumentor_name   => "excon" 
  :method              => "POST" 
  :middlewares         => [
    Excon::Middleware::ResponseParser
    Excon::Middleware::Expects
    Excon::Middleware::Idempotent
    Excon::Middleware::Instrumentor
    Excon::Middleware::Mock
  ]
  :mock                => false
  :nonblock            => true
  :omit_default_port   => false
  :path                => "/" 
  :persistent          => false
  :port                => 443
  :query               => nil
  :read_timeout        => 60
  :response_block      => #<Proc:0x0000000bba69a8@/root/foreman/vendor/ruby/gems/fog-xml-0.1.2/lib/fog/xml/sax_parser_connection.rb:29 (lambda)>
  :retries_remaining   => 4
  :retry_limit         => 4
  :scheme              => "https" 
  :ssl_verify_peer     => true
  :tcp_nodelay         => false
  :thread_safe_sockets => true
  :uri_parser          => URI
  :versions            => "excon/0.45.4 (x86_64-linux) ruby/2.0.0" 
  :write_timeout       => 60
excon.error.response
  :body          => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response><Errors><Error><Code>InvalidParameterCombination</Code><Message>Virtualization type 'hvm' is required for instances of type 't2.micro'. Ensure that you are using an AMI with virtualization type 'hvm'. For more information, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html</Message></Error></Errors><RequestID>3d90ec03-d920-4721-bea7-c17a1b7e0934</RequestID></Response>" 
  :headers       => {
    "Date"       => "Wed, 17 Feb 2016 20:55:21 GMT" 
    "Server"     => "AmazonEC2" 
    "nnCoection" => "close" 
  }
  :local_address => "10.200.18.245" 
  :local_port    => 50057
  :reason_phrase => "Bad Request" 
  :remote_ip     => "54.240.251.0" 
  :status        => 400
  :status_line   => "HTTP/1.1 400 Bad Request\r\n" 
>

Looking at the body request

body                => "Action=RunInstances&ImageId=ami-e0ec60d0&InstanceType=t2.micro&KeyName=foreman-1c5b55767-4b56-46a0-a8ec-955757c4f9df&MaxCount=1&MinCount=1&Placement.AvailabilityZone=us-west-2b&SecurityGroupId.1=sg-f52ffd92&SubnetId=subnet-420be726&Version=2014-10-01"

You can see that it set ImageId to ami-e0ec60d0, that is not the AMI set in the image under the Compute Resource.

If you leave the compute profile blank on the host provisioning page you get

:body                => "Action=RunInstances&ImageId=ami-1255b321&InstanceType=t2.micro&KeyName=foreman-1c5b55767-4b56-46a0-a8ec-955757c4f9df&MaxCount=1&MinCount=1&Placement.AvailabilityZone=us-west-2b&SecurityGroupId.1=sg-f52ffd92&SubnetId=subnet-420be726&Version=2014-10-01"

Where ImageId ami-1255b321 is the AMI set in the image under the Compute Resource.

Maybe of note, vendor/ruby/gems/fog-aws-0.8.1/lib/fog/aws/models/compute/server.rb specifies this default AMI (ami-e0ec60d0) that is being sent.


Related issues 1 (0 open1 closed)

Is duplicate of Foreman - Bug #13980: VMWARE: since 1.10, NIC type and Network different from profile configurationClosedDominic Cleal03/01/2016Actions
Actions

Also available in: Atom PDF