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

DB Backups to Openstack Swift #371

Merged
merged 13 commits into from
Oct 17, 2018
Merged

Conversation

jerryk55
Copy link
Member

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.

@jerryk55
Copy link
Member Author

jerryk55 commented Sep 10, 2018 via email

Copy link
Member

@NickLaMuro NickLaMuro left a 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'
Copy link
Member

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.

Copy link
Member

@NickLaMuro NickLaMuro Sep 10, 2018

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)

Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

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.

lib/gems/pending/util/mount/miq_swift_session.rb Outdated Show resolved Hide resolved
require 'util/mount/miq_generic_mount_session'
require 'excon'

class MiqSwiftSession < MiqGenericMountSession

This comment was marked as resolved.

lib/gems/pending/util/mount/miq_swift_session.rb Outdated Show resolved Hide resolved
: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
Copy link
Member

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.

Copy link
Member Author

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.....

Copy link
Member

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.

Copy link
Member Author

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}
Copy link
Member

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?

Copy link
Member Author

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"

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

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.

Copy link
Member Author

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('=')
Copy link
Member

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('=')

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure no problem.

@NickLaMuro NickLaMuro dismissed their stale review September 10, 2018 20:12

We met out of band on how to go forward with this and #361, so going to dismiss this review based on that discussion.

@miq-bot
Copy link
Member

miq-bot commented Sep 12, 2018

This pull request is not mergeable. Please rebase and repush.

@NickLaMuro
Copy link
Member

NickLaMuro commented Sep 18, 2018

@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 [WIP] for me currently, and part of my TODO list), but should help integrate both the existing changes, as well as how file splitting could possibly be implemented as well.

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

Copy link
Member

@carbonin carbonin left a 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'
Copy link
Member

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
Copy link
Member

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}
Copy link
Member

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.

@jerryk55
Copy link
Member Author

jerryk55 commented Oct 9, 2018

@carbonin removed reference to $fog_log that slipped through the cracks. This is ready for review again.

Copy link
Member

@NickLaMuro NickLaMuro left a 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
Copy link
Member

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.

lib/gems/pending/util/miq_object_storage.rb Show resolved Hide resolved
lib/gems/pending/util/miq_object_storage.rb Outdated Show resolved Hide resolved
lib/gems/pending/util/mount/miq_generic_mount_session.rb Outdated Show resolved Hide resolved
@@ -0,0 +1,148 @@
require 'pp'
# require 'util/miq_object_storage'
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

@NickLaMuro let me know...

Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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)
Copy link
Member

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'
Copy link
Member

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:

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.

Copy link
Member

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.

Copy link
Member

@carbonin carbonin left a 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.
Copy link
Member

Choose a reason for hiding this comment

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

Typo, s/teh/the/

Copy link
Member Author

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'
Copy link
Member

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}
Copy link
Member

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

Copy link
Member Author

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|
Copy link
Member

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)
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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

Copy link
Member Author

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")
Copy link
Member

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.

Copy link
Member Author

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")

lib/gems/pending/util/object_storage/miq_swift_storage.rb Outdated Show resolved Hide resolved
Copy link
Member

@NickLaMuro NickLaMuro left a 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)
Copy link
Member

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'
Copy link
Member

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.
Copy link
Member

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)

lib/gems/pending/util/object_storage/miq_swift_storage.rb Outdated Show resolved Hide resolved
#
# Some calls to Fog::Storage::OpenStack::Directories#get will
# return 'nil', and not return an error. This would cause errors down the
# line.
Copy link
Member

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'.

Copy link
Member

@carbonin carbonin left a 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 on initialize
  • #uri_to_local_path (looks like this was removed)
  • #uri_to_object_path
  • validate the auth_url in the #swift private method

lib/gems/pending/util/object_storage/miq_swift_storage.rb Outdated Show resolved Hide resolved
lib/gems/pending/util/object_storage/miq_swift_storage.rb Outdated Show resolved Hide resolved
spec/util/miq_file_storage_spec.rb Outdated Show resolved Hide resolved
spec/util/miq_file_storage_spec.rb Outdated Show resolved Hide resolved
spec/util/miq_file_storage_spec.rb Outdated Show resolved Hide resolved
spec/util/miq_object_storage_spec.rb Outdated Show resolved Hide resolved
spec/util/miq_object_storage_spec.rb Outdated Show resolved Hide resolved
Copy link
Member

@NickLaMuro NickLaMuro left a 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.

lib/gems/pending/util/object_storage/miq_swift_storage.rb Outdated Show resolved Hide resolved
lib/gems/pending/util/object_storage/miq_swift_storage.rb Outdated Show resolved Hide resolved
Copy link
Member

@NickLaMuro NickLaMuro left a 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
Copy link
Member

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

Copy link
Member Author

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.

@NickLaMuro
Copy link
Member

NickLaMuro commented Oct 15, 2018

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!)

Copy link
Member

@carbonin carbonin left a 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.
Copy link
Member

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')
Copy link
Member

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"
Copy link
Member

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.

@carbonin
Copy link
Member

Also, can you either squash the commits in this PR or make them something more meaningful than "Review comments", "Rubocop fixes", "Tavis failure", etc.

Copy link
Member

@NickLaMuro NickLaMuro left a 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'
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.
@jerryk55 jerryk55 force-pushed the swift_db_backup branch 2 times, most recently from c62e61c to e33d295 Compare October 17, 2018 14:00
@jerryk55
Copy link
Member Author

@carbonin @NickLaMuro I believe I have addressed all of your comments. Please give this your blessing and merge if appropriate. Thanks.

@@ -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"
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

doh! Done.

spec/util/object_storage/miq_swift_storage_spec.rb Outdated Show resolved Hide resolved
spec/util/object_storage/miq_swift_storage_spec.rb Outdated Show resolved Hide resolved
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) }
Copy link
Member

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.

Copy link
Member Author

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

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.
Copy link
Member

@NickLaMuro NickLaMuro left a 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') }
Copy link
Member

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"
Copy link
Member

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...

Copy link
Member

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

Copy link
Member

@carbonin carbonin left a 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

@miq-bot
Copy link
Member

miq-bot commented Oct 17, 2018

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
6 files checked, 5 offenses detected

lib/gems/pending/util/object_storage/miq_swift_storage.rb

@carbonin carbonin self-assigned this Oct 17, 2018
@carbonin carbonin merged commit 33ec84a into ManageIQ:master Oct 17, 2018
@carbonin carbonin added this to the Sprint 97 Ending Oct 22, 2018 milestone Oct 17, 2018
simaishi pushed a commit that referenced this pull request Oct 17, 2018
@simaishi
Copy link
Contributor

Hammer backport details:

$ git log -1
commit 66584e4fdeac5863860591bb4eb34c1fe34ecd50
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Wed Oct 17 11:32:28 2018 -0400

    Merge pull request #371 from jerryk55/swift_db_backup
    
    DB Backups to Openstack Swift
    
    (cherry picked from commit 33ec84a811d119f6c605385c2164b53af8ab678e)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1615488

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

Successfully merging this pull request may close these issues.

6 participants