Skip to content
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

ironfan 6.1.6 doesn't respect AWS region / AZ defined for realm #355

Open
westbywest opened this issue May 28, 2014 · 5 comments
Open

ironfan 6.1.6 doesn't respect AWS region / AZ defined for realm #355

westbywest opened this issue May 28, 2014 · 5 comments

Comments

@westbywest
Copy link

I'm trying out ironfan v6.1.6 gem within ironfan-homebase, and I discovered the latest version in master apparently does not respect the region or AZ I have defined for the realm, defaulting instead to us-east-1.

Here is what I see trying to launch an instance:

MyMac:ironfan-homebase mymachine$ bundle exec knife cluster launch dev1-sandbox-simple-0
no realm-specific Gemfile found. using default Gemfile.
Inventorying servers in dev1 realm, sandbox cluster, simple facet, servers 0
  sandbox:  Loading chef
  sandbox:  Loading ec2
  sandbox:  Reconciling DSL and provider information
  +-----------------------+-------+-------------+----------+------------+-------------+-------+
  | Name                  | Chef? | State       | Flavor   | AZ         | Env         | Realm |
  +-----------------------+-------+-------------+----------+------------+-------------+-------+
  | dev1-sandbox-simple-0 | no    | not running | m1.large | us-west-2a | development | dev1  |
  +-----------------------+-------+-------------+----------+------------+-------------+-------+
Syncing to chef
Preparing shared resources:
  sandbox:  Loading chef
  sandbox:  Loading ec2
  sandbox:  Reconciling DSL and provider information
Loaded information for 1 computer(s) in cluster sandbox
  dev1-sandbox: creating key pair for dev1-sandbox
  sandbox:  creating security groups
  dev1:           creating dev1 security group
  dev1-sandbox:   creating dev1-sandbox security group
  splice_aws:         creating splice_aws security group
  splice_ssh:         creating splice_ssh security group
  sandbox:  ensuring security group permissions
  dev1-sandbox:   ensuring access from dev1-sandbox to dev1-sandbox
  splice_ssh:         ensuring tcp access from 0.0.0.0/0 to 22..22

Launching computers
  +-----------------------+-------+-------------+----------+------------+-------------+-------+
  | Name                  | Chef? | State       | Flavor   | AZ         | Env         | Realm |
  +-----------------------+-------+-------------+----------+------------+-------------+-------+
  | dev1-sandbox-simple-0 | no    | not running | m1.large | us-west-2a | development | dev1  |
  +-----------------------+-------+-------------+----------+------------+-------------+-------+
  dev1-sandbox-simple-0:    creating cloud machine
WARNING: Error running #<Ironfan::Broker::Computer(server=#<Ironfan::Dsl::Server(name="0", components=c{  }, run_list_items=c{ role[splice_aws], role[dev1-sandbox-cluster], role[dev1-sandbox-simple-facet] }, clouds=c{ ec2 }, volumes=c{  }, security_groups=c{ dev1, dev1-sandbox }, environment=:development, realm_name="dev1", cluster_role=#<Ironfan::Dsl::Role>, facet_role=#<Ironfan::Dsl::Role>, cluster_names={:sandbox=>:sandbox}, cluster_name="sandbox", facet_name="simple")>, resources=c{  }, drives=c{ root, ephemeral0, ephemeral1 }, providers=c{ chef, iaas })>:
WARNING: Failed validation: {"mismatched region"=>["us-east-1", "us-west-2"]}
ERROR: Failed validation: {"mismatched region"=>["us-east-1", "us-west-2"]} (ArgumentError)
/Users/me/src/ironfan/lib/ironfan/provider/ec2/machine.rb:172:in `create!'
/Users/me/src/ironfan/lib/ironfan/broker/computer.rb:78:in `launch'
/Users/me/src/ironfan/lib/ironfan/broker/computer.rb:320:in `block in launch'
/Users/me/src/ironfan/lib/ironfan.rb:114:in `block (3 levels) in parallel'
/Users/me/src/ironfan/lib/ironfan.rb:123:in `safely'
/Users/me/src/ironfan/lib/ironfan.rb:113:in `block (2 levels) in parallel'
ERROR: /Users/me/src/ironfan/lib/ironfan/provider/ec2/machine.rb:172:in `create!'
/Users/me/src/ironfan/lib/ironfan/broker/computer.rb:78:in `launch'
/Users/me/src/ironfan/lib/ironfan/broker/computer.rb:320:in `block in launch'
/Users/me/src/ironfan/lib/ironfan.rb:114:in `block (3 levels) in parallel'
/Users/me/src/ironfan/lib/ironfan.rb:123:in `safely'
/Users/me/src/ironfan/lib/ironfan.rb:113:in `block (2 levels) in parallel'
ERROR: Error launching #<ArgumentError: Failed validation: {"mismatched region"=>["us-east-1", "us-west-2"]}>; skipping after-launch tasks.
Some computers could not be launched

This is the realm I have defined in $IRONFAN_HOMBASE/realms/dev1.rb:

#
# dev1 realm -- use this for general development
#
Ironfan.realm 'dev1' do
  cluster 'sandbox' do
    cloud(:ec2) do
      permanent           false
      availability_zones  %w[ us-west-2a ]
      flavor              'm1.large'
      backing             'ebs'
      image_name          'ironfan-precise'
      bootstrap_distro    'ubuntu12.04-ironfan'
      chef_client_script  'client.rb'
      mount_ephemerals
    end

    environment           :development

    role                :my_aws, :first
    cloud(:ec2).security_group :my_aws
    cloud(:ec2).security_group(:my_ssh).authorize_port_range 22..22

    facet :simple do
      instances           1
    end

    cluster_role.override_attributes({
                                     })
  end
end

I bundle ironfan v6.1.6 into ironfan-homebase by checking out a local copy of the repo and adding this to $IRONFAN_HOMBASE/Gemfile: gem 'ironfan', :path => "~/src/ironfan"

I can confirm that explicitly setting the same region in $IRONFAN_HOMBASE/knife/credentials/knife-org.rb does allow this instance to launch into the correct region:

Chef::Config.knife[:region]  = "us-west-2"

Is ironfan not picking up the AWS region specified for the realm?

@westbywest
Copy link
Author

Following up after commit be017d4 , this is now the error which I get:

WARNING: Error running #<Ironfan::Broker::Computer(server=#<Ironfan::Dsl::Server(name="0", components=c{  }, run_list_items=c{ role[splice_aws], role[dev1-sandbox-cluster], role[dev1-sandbox-simple-facet] }, clouds=c{ ec2 }, volumes=c{  }, security_groups=c{ dev1, dev1-sandbox }, environment=:development, realm_name="dev1", cluster_role=#<Ironfan::Dsl::Role>, facet_role=#<Ironfan::Dsl::Role>, cluster_names={:sandbox=>:sandbox}, cluster_name="sandbox", facet_name="simple")>, resources=c{ security_group__splice_aws, security_group__splice_ssh }, drives=c{ root, ephemeral0, ephemeral1 }, providers=c{ chef, iaas })>:
WARNING: Failed validation: {"mismatched region"=>{:ec2_connection=>"us-east-1", :cloud=>"us-west-2", :knife=>nil, :chef_config=>nil}}
ERROR: Failed validation: {"mismatched region"=>{:ec2_connection=>"us-east-1", :cloud=>"us-west-2", :knife=>nil, :chef_config=>nil}} (ArgumentError)
/Users/me/src/ironfan/lib/ironfan/provider/ec2/machine.rb:172:in `create!'
/Users/me/src/ironfan/lib/ironfan/broker/computer.rb:93:in `launch'
/Users/me/src/ironfan/lib/ironfan/broker/computer.rb:335:in `block in launch'
/Users/me/src/ironfan/lib/ironfan.rb:114:in `block (3 levels) in parallel'
/Users/me/src/ironfan/lib/ironfan.rb:123:in `safely'
/Users/me/src/ironfan/lib/ironfan.rb:113:in `block (2 levels) in parallel'
ERROR: /Users/me/src/ironfan/lib/ironfan/provider/ec2/machine.rb:172:in `create!'
/Users/me/src/ironfan/lib/ironfan/broker/computer.rb:93:in `launch'
/Users/me/src/ironfan/lib/ironfan/broker/computer.rb:335:in `block in launch'
/Users/me/src/ironfan/lib/ironfan.rb:114:in `block (3 levels) in parallel'
/Users/me/src/ironfan/lib/ironfan.rb:123:in `safely'
/Users/me/src/ironfan/lib/ironfan.rb:113:in `block (2 levels) in parallel'
ERROR: Error launching #<ArgumentError: Failed validation: {"mismatched region"=>{:ec2_connection=>"us-east-1", :cloud=>"us-west-2", :knife=>nil, :chef_config=>nil}}>; skipping after-launch tasks.

@westbywest
Copy link
Author

Further snooping suggests this may be a continuation/duplicate of this issue: #91
The new detail is that this problem, i.e. inability to deploy to region besides us-east-1 w/o explicitly setting Chef::Config[:knife][:region], didn't occur w/ ironfan v4.11.3 .

@rottmanj
Copy link
Contributor

Any traction on this issue? We are separating out our environments a bit and ran into this very same issue.

@westbywest
Copy link
Author

No meaningful traction. I'm pretty new to ironfan, so am a bit hesitant to go mucking around too much in the codebase.

As a lazy workaround, I edited my knife-org.rb to take the environment variable EC2_REGION, if present:

Chef::Config.knife[:region]  = ENV['EC2_REGION']

This at least lets me specify a region at the command line:

EC2_REGION="us-west-2" bundle exec knife cluster blah blah blah

This would not work for multi-region deployments, tho.

@moogoos
Copy link

moogoos commented Aug 29, 2014

1UP

I am suffering from the same bug. It seems regions are disregarded in cluster or realm definitions which prevents me from using realms the way I would like. I don't want to be restricted to one region because it's the only one I can define in my knife-org.rb.

This workaround works but again, is really just defining the default region in a config and I'd rather have the defined in a realm ideally. Any other suggestions welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants