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

For database dumps don't modify the directory name #18058

Merged
merged 3 commits into from
Oct 15, 2018

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Oct 4, 2018

overview

Typically "db_dump" or "db_backup" is added the remote path for backup upload.

This PR gives the rake task the --skip-directory option so "db_backup" is not added to the target directory name

related to:

before:

bundle exec rake evm:db:dump:remote -- --uri ftp://ftp.example.com/incoming/ \
                                       --remote-file-name test-db3.backup

# target: ftp://ftp.example.com/incoming/db_dump/the_file.tgz

after (using this option):

bundle exec rake evm:db:dump:remote -- --uri ftp://ftp.example.com/incoming/ \
                                       --remote-file-name test-db3.backup --skip-directory

# target: ftp://ftp.example.com/incoming/the_file.tgz

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 a suggestion, the rest of the code seems fine.

"db_dump"
else
"db_backup"
end
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 is my only suggestion. Just don't like how this looks currently (question if my suggestion is better...), but I am a bit squeamish about passing a [] to File.join (seems odd):

folder   = nil
folder ||= action == :dump ? "db_dump" : "db_backup" unless connect_opts[:skip_directory]
uri = File.join(*[connect_opts[:uri], folder, connect_opts[:remote_file_name].compact)

I would maybe suggest moving this to a method, but since we are doing class methods here (not necessarily a fan of how this class is built) we would have to pass action and connect_opts as well, so I did it this way for less complexity.

Copy link
Member Author

Choose a reason for hiding this comment

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

File.join("a", %w(b c), nil, "d")
TypeError: no implicit conversion of nil into String
	from (irb):1:in `join'
	from (irb):1
	from /opt/rubies/ruby-2.3.7/bin/irb:11:in `<main>'
File.join("a", %w(b c), [], "d")
# => "a/b/c/d"  

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 put in a work around, hope this one looks better.

Copy link
Member

Choose a reason for hiding this comment

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

@kbrock just an FYI, I was using the * (splat) operator on a compacted array (removes nil values), so that is why my sample worked, where your example does not.

But, I think what you have changed it to works for me, so lets go with that. Thanks. 👍

@@ -57,7 +58,7 @@ module EvmDba
db_opts
end

CONNECT_OPT_KEYS = [:uri, :uri_username, :uri_password, :aws_region, :remote_file_name].freeze
CONNECT_OPT_KEYS = %i(uri uri_username uri_password aws_region remote_file_name skip_directory).freeze
Copy link
Member

@NickLaMuro NickLaMuro Oct 9, 2018

Choose a reason for hiding this comment

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

NO! Boo! 😡

See ManageIQ/manageiq-providers-amazon#434 (comment)

(pedantic, don't actually change this)

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.

Looks good to me. 👍

@miq-bot
Copy link
Member

miq-bot commented Oct 12, 2018

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

Typically "db_dump" or "db_backup" is added the remote path for
backup upload.

This gives the rake task the --skip-directory option so "db_backup"
is not added to the target directory name
@kbrock
Copy link
Member Author

kbrock commented Oct 15, 2018

fixed merge conflict

@miq-bot
Copy link
Member

miq-bot commented Oct 15, 2018

Checked commits kbrock/manageiq@28a79ac~...77d1616 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍰

@carbonin carbonin self-assigned this Oct 15, 2018
@carbonin carbonin merged commit 256bdd6 into ManageIQ:master Oct 15, 2018
@carbonin carbonin added this to the Sprint 97 Ending Oct 22, 2018 milestone Oct 15, 2018
simaishi pushed a commit that referenced this pull request Oct 15, 2018
For database dumps don't modify the directory name

(cherry picked from commit 256bdd6)
@simaishi
Copy link
Contributor

Hammer backport details:

$ git log -1
commit d765fee4ed82b5a62e16dfff70f9e143b98323d8
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Mon Oct 15 09:53:24 2018 -0400

    Merge pull request #18058 from kbrock/skip_directory_upload
    
    For database dumps don't modify the directory name
    
    (cherry picked from commit 256bdd6a579fea32ce46a5742b9de0ecb6bc36c5)

@kbrock kbrock deleted the skip_directory_upload branch October 15, 2018 17:31
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.

5 participants