Skip to content

Commit

Permalink
Merge pull request #512 from test-kitchen/cw/block_duration
Browse files Browse the repository at this point in the history
Use defaults when creating spot instances - fixes block_duration_minutes
  • Loading branch information
tyler-ball authored Oct 14, 2020
2 parents 3da2d78 + 49945b7 commit 083d390
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/kitchen/driver/ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,17 @@ def submit_spot
debug("Creating EC2 Spot Instance..")
instance_data = instance_generator.ec2_instance_data

request_duration = config[:spot_wait]
config_spot_price = config[:spot_price].to_s
if %w{ondemand on-demand}.include?(config_spot_price)
spot_price = ""
else
spot_price = config_spot_price
end
spot_options = {
spot_instance_type: "persistent", # Cannot use one-time with valid_until
valid_until: Time.now + request_duration,
instance_interruption_behavior: "stop",
# Must use one-time in order to use instance_interruption_behavior=terminate
# spot_instance_type: "one-time", # default
# Must use instance_interruption_behavior=terminate in order to use block_duration_minutes
# instance_interruption_behavior: "terminate", # default
}
if config[:block_duration_minutes]
spot_options[:block_duration_minutes] = config[:block_duration_minutes]
Expand Down
4 changes: 0 additions & 4 deletions spec/kitchen/driver/ec2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@
describe "#submit_spot" do
before do
expect(driver).to receive(:instance).at_least(:once).and_return(instance)
allow(Time).to receive(:now).and_return(Time.now)
end

it "submits the server request" do
Expand All @@ -263,9 +262,6 @@
instance_market_options: {
market_type: "spot",
spot_options: {
spot_instance_type: "persistent",
instance_interruption_behavior: "stop",
valid_until: Time.now + config[:spot_wait],
block_duration_minutes: 60,
},
}
Expand Down

1 comment on commit 083d390

@RenatoMorenoR
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tyler-ball... when do you think this will be available?
Will we have to wait for ChefDK to be released?
Or we have to wait to this gem? https://rubygems.org/gems/kitchen-ec2

Thank you very much, we really appreciate your work...

Please sign in to comment.