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

Support for DB Restore from Object Stores #17791

Merged
merged 4 commits into from
Aug 2, 2018

Conversation

jerryk55
Copy link
Member

@jerryk55 jerryk55 commented Aug 1, 2018

Support restore from an object store. This is one of several PRs in support of the RFE for
https://bugzilla.redhat.com/show_bug.cgi?id=1513520. Another PR against the manageiq-appliance_console is also forthcoming.

@roliveri @carbonin please review and merge when appropriate.

Links [Optional]

@@ -110,6 +111,7 @@ def self.restore(db_opts, connect_opts = {})
if db_opts[:local_file].nil?
if action == :restore
uri = connect_opts[:uri]
connect_opts[:remote_file_name] ||= connect_opts[:uri]
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 we can remove this and use uri (remote_file_uri) in the block, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! I knew there was something we changed that could handle that. Thanks. Changing now.

@@ -89,7 +89,8 @@ def self.restore(db_opts, connect_opts = {})
# :username => 'samba_one',
# :password => 'Zug-drep5s',

uri = with_mount_session(:restore, db_opts, connect_opts) do |database_opts, _session, _remote_file_uri|
uri = with_mount_session(:restore, db_opts, connect_opts) do |database_opts, session, _remote_file_uri|
database_opts[:local_file] = session.download(database_opts[:local_file], connect_opts[:remote_file_name]) if session
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 connect_opts[:remote_file_name] here can just be the yielded remote_file_uri

Instead of overloading the connect opts by adding :remote_file_name
use the already yielded remote_file_uri as the argument to the session.download
call for restore.
@jerryk55
Copy link
Member Author

jerryk55 commented Aug 2, 2018

@carbonin fixed. good catch - thanks.

@@ -89,7 +89,8 @@ def self.restore(db_opts, connect_opts = {})
# :username => 'samba_one',
# :password => 'Zug-drep5s',

uri = with_mount_session(:restore, db_opts, connect_opts) do |database_opts, _session, _remote_file_uri|
uri = with_mount_session(:restore, db_opts, connect_opts) do |database_opts, session, remote_file_uri|
database_opts[:local_file] = session.download(database_opts[:local_file], remote_file_uri) if session
Copy link
Member

@carbonin carbonin Aug 2, 2018

Choose a reason for hiding this comment

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

So I'm thinking that this should only reassign database_opts[:local_file] if the local file doesn't exist already.

I'm worried that we're clobbering the value set on line 122 for mount types that actually mount.

Maybe something like this:

database_opts[:local_file] = session&.download(database_opts[:local_file], remote_file_uri) unless File.exist?(database_opts[:local_file])

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I feel like database_opts[:local_file] will be set for the S3 case, but won't actually exist yet because we don't mount, but for the other cases we should just restore from the mounted filesystem rather than essentially re-running the download.

Only run the download if the local file doesn't exist.
@miq-bot
Copy link
Member

miq-bot commented Aug 2, 2018

Checked commits jerryk55/manageiq@979731f~...8ee1edc with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. ⭐

@carbonin carbonin self-assigned this Aug 2, 2018
@carbonin carbonin merged commit 47cec75 into ManageIQ:master Aug 2, 2018
@carbonin carbonin added this to the Sprint 92 Ending Aug 13, 2018 milestone Aug 2, 2018
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.

3 participants