-
Notifications
You must be signed in to change notification settings - Fork 107
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
Enable dynamic cloud volume modifications #177
Conversation
c6e19e7
to
c79c93d
Compare
c79c93d
to
2611e7b
Compare
manageiq-providers-amazon.gemspec
Outdated
@@ -13,7 +13,7 @@ Gem::Specification.new do |s| | |||
|
|||
s.files = Dir["{app,config.lib}/**/*"] | |||
|
|||
s.add_dependency("aws-sdk", ["~>2.6.14"]) | |||
s.add_dependency("aws-sdk", ["~>2.7.8"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you put this in a separate PR - for backporting reasons...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, it's already in #176 👍
This pull request is not mergeable. Please rebase and repush. |
2611e7b
to
88cf776
Compare
Since #176 was just merged, I rebased it and removed the gem version bump from this one. |
it "is allowed when :name is provided" do | ||
# Name is set via AWS tags so stub the create_tags. | ||
expect_any_instance_of(Aws::EC2::Volume).to receive(:create_tags).with( | ||
:tags => [{:key => "Name", :value => "new_name"}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can also stub this. add the api calls to with_aws_stubbed
below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible, but only to some degree. I wanted to ensure that specific arguments are used as well as check whether the call is made or not (if name is given, it must be called, if it's not given, it should not be called).
What I could do is ignore input parameters to create_tags
and then use an exception in the stub to ensure it doesn't get called. I'll have a look.
with_provider_object do |volume| | ||
volume.create_tags(:tags => [{:key => "Name", :value => options[:name]}]) | ||
end | ||
res = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does any caller really care about the return value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not completely sure. Perhaps I just misunderstood what's needed.
modify_opts = {} | ||
if volume_type != 'standard' | ||
modify_opts[:volume_type] = options[:volume_type] if options[:volume_type] && options[:volume_type] != 'standard' | ||
modify_opts[:size] = options[:size] if options[:size] && options[:size] != (size / 1_073_741_824) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this something like 1.gigabyte
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, alternative check would be ... && options[:size].gigabyte == size
. Database stores the size in bytes, but the :size
in options must be in gigabytes.
28aa126
to
d586e19
Compare
Checked commit gberginc@d586e19 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
@durandom I've updated the change:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gberginc awesome second iteration 👏
besides the options question great
modify_opts = {} | ||
if volume_type != 'standard' | ||
modify_opts[:volume_type] = options[:volume_type] if options[:volume_type] && options[:volume_type] != 'standard' | ||
modify_opts[:size] = options[:size] if options[:size] && options[:size].gigabytes != size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does options[:size]
come from? Maybe do Integer(options[:size])
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@durandom Thanks for spotting this. So far value of options[:size]
came from the UI where I tested only with valid values, however it could also come from API or automate which means that it could in fact be invalid. I added two more tests to ensure that valid and invalid strings work properly with the updated function.
Recently Amazon introduced a capability to modify existing cloud volumes on the fly. Depending on the volume type size, volume type and IOPS can be modified without detaching the volume first. This patch enhances the existing `update_volume` method that previously allowed changing only the name of the volume by using the new method `#modify_volume` from the aws-sdk gem. The patch also adds a set of tests verifying different possible options passed to the `update_volume`.
d586e19
to
fe5147c
Compare
looks great, very nice specs 👍 |
Recently Amazon introduced a capability to modify existing cloud volumes
on the fly. Depending on the volume type size, volume type and IOPS can
be modified without detaching the volume first.
This patch enhances the existing
update_volume
method that previouslyallowed changing only the name of the volume by using the new method
#modify_volume
from the aws-sdk gem. The patch also adds a set oftests verifying different possible options passed to the
update_volume
.Depends on #176 (requires newer aws-sdk gem).
@miq-bot add_label enhancement