-
Notifications
You must be signed in to change notification settings - Fork 79
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
DB Backups to Openstack Swift #371
Conversation
@nick LaMuro <nlamuro@redhat.com> I understand your concern and probably
agree but that will not make it into this release which is supposed to be
completed in the next two weeks. I submit that we revisit this once we
have the functionality working. Is that agreeable to you?
… ***@***.**** commented on this pull request.
------------------------------
> + disconnect
+ logger.error("Access to Swift container ***@***.***_name} failed due to a bad username or password. #{err}")
+ msg = "Access to Swift container ***@***.***_name} failed due to a bad username or password. #{err}"
+ raise err, msg, err.backtrace
+ rescue => err
+ disconnect
+ logger.error("Error uploading #{local_file} to Swift container ***@***.***_name}. #{err}")
+ msg = "Error uploading #{local_file} to Swift container ***@***.***_name}. #{err}"
+ raise err, msg, err.backtrace
+ end
+ end
+
+ private
+
+ def swift
+ require 'manageiq/providers/openstack/legacy/openstack_handle'
I don't like that we are requiring something here that isn't a dependency
of this gem.
Perhaps we should consider what @Fryguy <https://github.com/Fryguy> had
suggested and move both this and the S3 provider code to their respective
provider repos.
|
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.
@jerryk55 First off, that one off comment was meant for this review, and I tried to delete it before you saw it, but I guess that didn't happen. Opps and sorry.
@carbonin and @jerryk55 #361 has been open for a month now, and this PR basically has proven that nobody has looked at it, even though I have invited you both to do so since pretty much the moment it has been opened. The subsequent code I have that has been open for about just as long (some of it longer) and heavily depends on the patterns built in #361, and this code directly conflicts with said patterns.
I have even gone to the trouble of already converting the S3 code to completely support the new framework, but this is basically going to have the same treatment done to it if it just gets merged as is.
I would prefer to get out of this rebasing loop I have been in for the past month and either determine if what I have is being scrapped (again), or if we need to get my changes merged so this PR can work with that new functionality.
-Nick
private | ||
|
||
def swift | ||
require 'manageiq/providers/openstack/legacy/openstack_handle' |
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 don't like that we are requiring something here that isn't a dependency of this gem.
Perhaps we should consider what @Fryguy had suggested and move both this and the S3 provider code to their respective provider repos.
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.
#371 (comment) was meant in response to this, but I deleted it and moved it into my full review (sorry for the confusion).
Answer to Jerry's response can be found in #371 (review)
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 don't like that we are requiring something here that isn't a dependency of this gem.
I agree, in fact I wouldn't think this would work at all if not for the amount of autoload magic we do within the actual rails app. Is there no better way to get what we need to do this?
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.
For what it is worth, OpenstackHandle::Handle
is basically a thin wrapper around fog-openstack
, so we probably could just include that and use that directly.
I will try and see what is necessary in my branch to make the changes later if I have some time.
Note: I still think the suggestion from above (move in to providers repos) is better long term, but agree that we are probably to close to the deadline to pull that off safely.
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.
So - FWIW there is similar code in ManageIQ/manageiq#17967 for the same reason. Yes its a wrapper around fog-openstack but I believe it to be a necessary one. Short of pulling that code out into a repo/gem separate from the openstack provider, or moving this MountSession code into the Provider.
require 'util/mount/miq_generic_mount_session' | ||
require 'excon' | ||
|
||
class MiqSwiftSession < MiqGenericMountSession |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
:ssl_cert_store => OpenSSL::X509::Store.new | ||
} | ||
extra_options[:domain_id] = @domain_id | ||
extra_options[:omit_default_port] = ::Settings.ems.ems_openstack.excon.omit_default_port |
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 don't think we can use Settings
here.
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.
We can't use as in its an error? Or as in its wrong for some reason? Because the code works.....
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'm very surprised the code works. Settings
is set up in the core repo and should not be relied upon in this gem.
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.
@carbonin I hope you like surprises then. :-)
extra_options[:service] = "Compute" | ||
|
||
@osh ||= OpenstackHandle::Handle.new(@username, @password, @host, @port, @api_version, @security_protocol, extra_options) | ||
@osh.connection_options = {:instrumentor => $fog_log} |
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 $fog_log
defined in this repo?
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.
Based on the fact that I don't know where any of the log variables are defined offhand, I'd have to answer "i don't know"
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.
Defined in ManageIQ/manageiq here:
https://github.com/ManageIQ/manageiq/blob/c1156912/lib/vmdb/loggers.rb#L57
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.
Yeah, then this also shouldn't be used here.
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'm just going to take that out then.
|
||
def query_params(query_string) | ||
query_string.split('&').each do |query| | ||
query_parts = query.split('=') |
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 this would be easier to read as key, value = query.split('=')
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.
Sure no problem.
We met out of band on how to go forward with this and #361, so going to dismiss this review based on that discussion.
This pull request is not mergeable. Please rebase and repush. |
370a172
to
278608a
Compare
278608a
to
120c914
Compare
@jerryk55 Been spending a good portion of today looking into how we can update these changes to work with the changes I introduced in #361 I have put together a branch that does just that: master...NickLaMuro:swift-storage-as-object-storage Not very well tested, specifically the swift parts (getting an environment for that is a I might break out some of the pieces into their own PRs as it isn't meant to be somewhat generic, but they didn't exist previously so I included them all in one spot for now. Hope this helps. cc @carbonin |
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.
Core manageiq lists this gem as a dependency, as such we shouldn't be depending on resources from core (Settings
, $fog_log
) or from other provider gems like manageiq-providers-openstack
.
private | ||
|
||
def swift | ||
require 'manageiq/providers/openstack/legacy/openstack_handle' |
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 don't like that we are requiring something here that isn't a dependency of this gem.
I agree, in fact I wouldn't think this would work at all if not for the amount of autoload magic we do within the actual rails app. Is there no better way to get what we need to do this?
:ssl_cert_store => OpenSSL::X509::Store.new | ||
} | ||
extra_options[:domain_id] = @domain_id | ||
extra_options[:omit_default_port] = ::Settings.ems.ems_openstack.excon.omit_default_port |
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'm very surprised the code works. Settings
is set up in the core repo and should not be relied upon in this gem.
extra_options[:service] = "Compute" | ||
|
||
@osh ||= OpenstackHandle::Handle.new(@username, @password, @host, @port, @api_version, @security_protocol, extra_options) | ||
@osh.connection_options = {:instrumentor => $fog_log} |
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.
Yeah, then this also shouldn't be used here.
0f578f8
to
be5eb9a
Compare
cd98e19
to
58267a7
Compare
@carbonin removed reference to $fog_log that slipped through the cracks. This is ready for review again. |
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.
So I will leave a link to my current experimental branch here for anyone else reviewing:
master...NickLaMuro:swift-storage-as-object-storage
But most of this review is just commentary on what was pulled in, and things that can potentially be improved upon from that.
|
||
attr_accessor :settings | ||
attr_writer :logger | ||
|
||
DEFAULT_CHUNKSIZE = Net::BufferedIO::BUFSIZE |
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.
For some reference, this comes from net/protocol
, and it is the same chunk size that is used by Net::FTP
when uploading. Figured it was a reasonable value to pick out of a hat and use here.
@@ -0,0 +1,148 @@ | |||
require 'pp' | |||
# require 'util/miq_object_storage' |
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 might have left this in as a comment at one point, but I think you can delete this.
Actually... looking at this more, possibly this should change to use this line... let me get back to you on that one.
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.
@NickLaMuro let me know...
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 I might have been trying to test this file in irb
on it's own, and doing the below require made it easier to do that. I will give this a shot in a few with this uncommented and the other included and see if it should work.
I am pretty sure this line should be the one we want, but I want to make sure tests pass (unit and integration) before I say one way or the other.
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.
This can be uncommented and the line below deleted. I think my explanation from above is the reason... I guess.
Anyway, sorry for the extra crap left lying around...
super(settings) | ||
|
||
# NOTE: This line to be removed once manageiq-ui-class region change implemented. | ||
@bucket_name = URI(@settings[:uri]).host |
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 being used in the FileDepot
code then? If so, then that is probably why I omitted it by mistake in my branch.
Sorry about that.
raise err, msg, err.backtrace | ||
end | ||
|
||
def download_single(source, destination) |
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.
Maybe raise an error in here for now instead of implementing it with s3
code 😉
|
||
def swift | ||
return @swift if @swift | ||
require 'manageiq/providers/openstack/legacy/openstack_handle' |
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.
So of note, I have written a version of this that makes use of fog/openstack
directly:
manageiq-gems-pending/lib/gems/pending/util/object_storage/miq_swift_storage.rb
Lines 92 to 114 in cd2beb7
def swift | |
return @swift if @swift | |
require 'fog/openstack' | |
auth_url = URI::Generic.build( | |
:scheme => @security_protocol == 'non-ssl' ? "http" : "https", | |
:host => @host, | |
:port => @port.to_i, | |
:path => "/#{@api_version}#{@api_version == "v3" ? "/auth" : ".0"}/tokens" | |
).to_s | |
connection_params = { | |
:openstack_auth_url => auth_url, | |
:openstack_username => @username, | |
:openstack_api_key => @password, | |
:openstack_project_domain_id => @domain_id, | |
:openstack_user_domain_id => @domain_id, | |
:openstack_region => @region, | |
:connection_options => { :debug_request => true } | |
} | |
swift = Fog::Storage::OpenStack.new(connection_params) | |
end |
And seems to work with the tests I have setup for this (rake tasks only). If we want to limit the amount of dependencies from that repo, that might be something to consider. I spent a decent amount of time pulling out the relevant pieces from the OpenstackHandle
code base to make that work, so hopefully that does the trick for most use cases.
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.
👍 For @NickLaMuro's approach. Based on the snippet linked here, I don't see much simplification in the way the code is currently vs using fog/openstack
.
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.
In addition to my comments please add specs.
|
||
def uri_to_object_path(remote_file) | ||
# Strip off the leading "swift://" and the container name from the URI" | ||
# Also remove teh leading delimiter. |
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.
Typo, s/teh/the/
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.
yep.
|
||
def swift | ||
return @swift if @swift | ||
require 'manageiq/providers/openstack/legacy/openstack_handle' |
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.
👍 For @NickLaMuro's approach. Based on the snippet linked here, I don't see much simplification in the way the code is currently vs using fog/openstack
.
extra_options[:domain_id] = @domain_id | ||
extra_options[:service] = "Compute" | ||
@osh ||= OpenstackHandle::Handle.new(@username, @password, @host, @port, @api_version, @security_protocol, extra_options) | ||
@osh.connection_options = {:instrumentor => $fog_log} |
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.
$fog_log
should be removed I think
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.
Removed at some point in the last day or so...
|
||
with_standard_s3_error_handling("downloading", source) do | ||
if destination.kind_of?(IO) | ||
s3.client.get_object(:bucket => bucket_name, :key => object_key) do |chunk| |
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 don't think s3
should be a thing in the swift
code, right? Agree with @NickLaMuro, if this isn't implemented then let's raise a NotImplementedError
rather than just copying and pasting unrelated code.
extra_options = {} | ||
extra_options[:domain_id] = @domain_id | ||
extra_options[:service] = "Compute" | ||
@osh ||= OpenstackHandle::Handle.new(@username, @password, @host, @port, @api_version, @security_protocol, extra_options) |
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.
There looks like there's some extra indentation on this line that isn't needed.
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.
Fixed, and in a couple of other places.
@osh ||= OpenstackHandle::Handle.new(@username, @password, @host, @port, @api_version, @security_protocol, extra_options) | ||
@osh.connection_options = {:instrumentor => $fog_log} | ||
begin | ||
@swift ||= @osh.swift_service |
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.
No need for ||=
here right? The first line in the method is return @swift if @swift
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.
Done.
|
||
def create_container | ||
container = swift.directories.create(:key => container_name) | ||
logger.debug("Swift container [#{container}] created") |
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.
What does this print? Is this just the container name or does this print the object inspect? Just want to make sure this isn't printing connection passwords by mistake.
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.
changed to logger.debug("Swift container [#{container_name}] created")
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.
Okay, think I caught some things from my last review, as well as some comment wording suggestions. They should be quick fixes.
|
||
raise "username and password are required values!" if @settings[:username].nil? || @settings[:password].nil? | ||
_scheme, _userinfo, @host, @port, _registry, @mount_path, _opaque, query, _fragment = URI.split(URI.encode(@settings[:uri])) | ||
query_params(query) |
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.
So I actually have a test for this:
https://github.com/ManageIQ/manageiq-gems-pending/compare/master...NickLaMuro:swift-storage-as-object-storage#diff-29a17f03343e08092b7e3f3fbbeaf113R97
That will actually fail with how things are currently (just noticed when running them when looking into something else). The issue is that passing a nil
value to URI.decode_www_form
doesn't play well, and that is what that test is checking against.
This can be solve by either adding a if query
to the end of this line, or doing a nil
check in #query_params
. Up to you, but that should be done.
@@ -0,0 +1,148 @@ | |||
require 'pp' | |||
# require 'util/miq_object_storage' |
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.
This can be uncommented and the line below deleted. I think my explanation from above is the reason... I guess.
Anyway, sorry for the extra crap left lying around...
# | ||
# Instead of investigating further, we created a new method that is in charge of | ||
# OpenStack container creation, and that is called from '#container' if 'nil' is | ||
# returned, or the error for 'NotFound' is called to cover both cases. |
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.
or the error for 'NotFound' is called to cover both cases.
Maybe change it to this:
or call '#create_container' in the rescue case for 'NotFound' to cover that scenario as well.
(sorry, this is verbatim from my commit message, and I admit I wrote that poorly)
# | ||
# Some calls to Fog::Storage::OpenStack::Directories#get will | ||
# return 'nil', and not return an error. This would cause errors down the | ||
# line. |
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.
Maybe to be more specific:
... down the line in '#upload' or '#download'.
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.
Most of this should be covered by the bot, but I think it has been stuck for a while and is still catching up to PR changes.
Otherwise can we add specs for some of the more testable methods in MiqSwiftStorage
?
I think some good candidates would be:
- ensure that
@container_name
is set properly oninitialize
-
#uri_to_local_path
(looks like this was removed) -
#uri_to_object_path
- validate the
auth_url
in the#swift
private method
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.
Just some formatting things I noticed. Minor.
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.
Syntax error that needs fixing.
@container ||= begin | ||
container = swift.directories.get(container_name) | ||
logger.debug("Swift container [#{container}] found") if container | ||
unless container raise Fog::Storage::OpenStack::NotFound |
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.
This is C
style syntax for conditional, and is causing your syntax errors. Should be:
raise Fog::Storage::OpenStack::NotFound unless container
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.
Yeah I already caught this with a test I was trying. Thanks.
Just an FYI, I "Unresolved" my most recent two comments, but I expect that a new push to this branch will automatically resolve them when that is done. Would prefer that they were resolved that way (and should be based on where I made the comments), even though I fully assume you will be doing the changes as you said. I will keep an eye on them and resolve them again if github doesn't do it's job, however. Thanks! (Update: Yay! it worked!) |
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.
Would still like to see a spec for the auth_url
in the #swift
private method.
def initialize(settings) | ||
super(settings) | ||
|
||
# NOTE: This line to be removed once manageiq-ui-class region change implemented. |
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 the case here also?
Also typo, s/manageiq-ui-class/manageiq-ui-classic/
describe MiqSwiftStorage do | ||
before(:each) do | ||
@uri = "swift://foo.com/abc/def" | ||
@object_storage = described_class.new(:uri => @uri, :username => 'user', :password => 'pass', :region => 'region') |
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.
This should really use let
or subject
rather than an instance variable.
|
||
describe MiqSwiftStorage do | ||
before(:each) do | ||
@uri = "swift://foo.com/abc/def" |
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.
This should really use let
rather than an instance variable.
Also, can you either squash the commits in this PR or make them something more meaningful than "Review comments", "Rubocop fixes", "Tavis failure", etc. |
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.
Besides what @carbonin had mentioned, I don't see much else to change here besides the gemspec addition. The "Request changes" status is only here to make sure we have the dependency defined here as well (which I assume is what we want to do since we did the same for s3
, and not have it a implied dependency).
Otherwise, I have tested this branch with my test suite and everything seems to be working, so looks good otherwise!
|
||
def swift | ||
return @swift if @swift | ||
require 'fog/openstack' |
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, can we add this to the manageiq-gems-pending.gemspec
now?
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.
setting it to "=0.1.22" as in the manageiq-providers-openstack gemspec.
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.
setting it to "=0.1.22" as in the manageiq-providers-openstack gemspec.
Please, don't. If we can use a less strict constraint for what we're doing here, then let's let the other repos dictate what exact version they need. Making this a hard constraint will only make it more difficult to 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.
Ok, then setting it to ~>0.1.22 SHouldn't be less than the Provider...
Add an Openstack Swift session object to allow backups to Swift.
Rework query string processing as per review comments. Remove $fog_log reference.
S3 was moved over to the object file session rather than this mount session subclass by a separate PR, so adding it back in via this PR is incorrect and causes Travis build failures.
Removing the swift class for the Mount Session, and adding a new swift class for Object Storage instead. This works with the streaming db backups/dumps now implemented.
As per review comment don't use $fog_log here.
Review comments by various reviews. Some nitpicks but the major change is to not use Openstack Provider handle code but instead use Fog::Openstack.
Major and minor changes - some indentation, some new tests (thanks Nick L) Stubbed out download_single method since it isn't fully working yet.
Fixed spacing, parentheses, and reworded and added some comments.
Review comments, adding some tests, and removing unused uri_to_local_path method.
c62e61c
to
e33d295
Compare
@carbonin @NickLaMuro I believe I have addressed all of your comments. Please give this your blessing and merge if appropriate. Thanks. |
manageiq-gems-pending.gemspec
Outdated
@@ -27,7 +27,9 @@ Gem::Specification.new do |s| | |||
s.add_runtime_dependency "aws-sdk", "~> 2.9.7" | |||
s.add_runtime_dependency "binary_struct", "~> 2.1" | |||
s.add_runtime_dependency "bundler", ">= 1.8.4" # rails-assets requires bundler >= 1.8.4, see: https://rails-assets.org/ | |||
s.add_runtime_dependency "fog-openstack", "~>0.1.22" |
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 format this like every other line in the gemspec? With a space between the >
and the version?
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.
doh! Done.
e33d295
to
90f3555
Compare
context "with non-ssl security protocol" do | ||
let(:uri) { "swift://foo.com:5678/abc/def?region=region&api_version=v3&security_protocol=non-ssl" } | ||
let(:object_storage) { described_class.new(:uri => uri, :username => 'user', :password => 'pass') } | ||
let(:auth_url) { object_storage.send(:auth_url) } |
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.
This isn't really a good use of let
. Since this is the actual method under test I think it would be better to call it directly in the test.
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.
Got it. Amended and Pushed. All comments addressed (again) @NickLaMuro @carbonin
90f3555
to
bea075e
Compare
In order to test the private mechanisms within more easily, pull the auth_url construction out of the private method #swift. Add tests for it as well as for #uri_to_object_path, and to make sure #initialize sets the container name correctly. Add fog-openstack and mime-types to the gemspec.
bea075e
to
47dd52c
Compare
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.
These comments are minor or just commentary. I think this looks good. So feel free to merge as far as I am concerned.
require "util/object_storage/miq_swift_storage" | ||
|
||
describe MiqSwiftStorage do | ||
let(:object_storage) { described_class.new(:uri => uri, :username => 'user', :password => 'pass') } |
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 was going to suggest moving this here. 😄
👍
s.add_runtime_dependency "linux_admin", "~> 1.0" | ||
s.add_runtime_dependency "mime-types", "~> 3.0" |
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.
Ugh.... another gem that uses mime-types
... kill me now...
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.
For those completely confused with the above, see: ManageIQ/manageiq#14525
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.
This looks great! Thanks for the work on this @jerryk55 and @NickLaMuro
Checked commits jerryk55/manageiq-gems-pending@ecf715f~...518f48f with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 lib/gems/pending/util/object_storage/miq_swift_storage.rb
|
DB Backups to Openstack Swift (cherry picked from commit 33ec84a) https://bugzilla.redhat.com/show_bug.cgi?id=1615488
Hammer backport details:
|
Add an Openstack Swift session object to allow backups to Swift.
This is part of the RFE contained in https://bugzilla.redhat.com/show_bug.cgi?id=1615488.
There is a Schema change already submitted for review in
ManageIQ/manageiq-schema#259.
Further PRs will be added including in manageiq-ui-classic, manageiq (core), and manageiq-appliance-console for the backup and restore side of the picture.
These changes are similar to those implemented for the Amazon S3 DB backups.
@carbonin @NickLaMuro @roliveri please review and merge when appropriate. Thank you.