Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bugfix/overzealous elastic ips #222

Closed
wants to merge 1 commit into from

3 participants

@nickmarden

Without this patch, facets which do not specify an elastic_ip will get an error like this:

Syncing to Chef:
Syncing to cloud:
  prod-services-1:  setting termination flag false
  prod-services-1:  associating Elastic IP 
WARNING: Error running :
WARNING: MissingParameter => Either public IP or allocation id must be specified
ERROR: MissingParameter => Either public IP or allocation id must be specified (Fog::Compute::AWS::Error)
/Users/nick/.rvm/gems/ruby-1.9.3-p194@ironfan-homebase/gems/excon-0.16.4/lib/excon/connection.rb:290:in `request_kernel'
@nickmarden

@schade, this fix looks right to me but can you verify that I've put the conditional logic in the right place?

Actually there is a better way... above the first line ( elastic_ip = computer.server.ec2.elastic_ip ) add this line:
return unless computer.server.ec2.elastic_ip.nil?

and it will harmlessly bypass if no elastic_ip is set in the facet definition. I suppose you could also put it at the end of the line referenced as well.

But I see now that Nathan beat me to it and just combined my code with the first test; so all good. Guess I should read further before answering next time. Working as a team on github is still a little new to me right now. :)

I had originally thought about doing the

return unless ...

approach, but I generally shy away from early return statements as they tend to be widowmakers in more complex code.

At any rate, all's well that ends well. Don't worry about being a newbie on github collaboration - it's better for Ironfan if there is some imperfect collaboration than none at all, and we'll all get better quickly as time goes on.

@temujin9

Thanks for the heads up; I ended up going with a slightly different conditional.

@temujin9 temujin9 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/ironfan/provider/ec2/elastic_ip.rb
View
11 lib/ironfan/provider/ec2/elastic_ip.rb
@@ -51,11 +51,12 @@ def self.load!(cluster=nil)
def self.save!(computer)
return unless computer.created?
- elastic_ip = computer.server.ec2.elastic_ip
- Ironfan.step(computer.name, "associating Elastic IP #{elastic_ip}", :blue)
- Ironfan.unless_dry_run do
- Ironfan.safely do
- Ec2.connection.associate_address( computer.machine.id, elastic_ip )
+ if elastic_ip = computer.server.ec2.elastic_ip
+ Ironfan.step(computer.name, "associating Elastic IP #{elastic_ip}", :blue)
+ Ironfan.unless_dry_run do
+ Ironfan.safely do
+ Ec2.connection.associate_address( computer.machine.id, elastic_ip )
+ end
end
end
end
Something went wrong with that request. Please try again.