-
Notifications
You must be signed in to change notification settings - Fork 897
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
Add file splitting to evm:db tasks (V2) #17894
Add file splitting to evm:db tasks (V2) #17894
Conversation
This pull request is not mergeable. Please rebase and repush. |
b087e1e
to
d5d4eca
Compare
d5d4eca
to
462721d
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.
Mostly just asking for some clarification so I can understand what's going on a bit better. But looks good from a high level.
lib/evm_database_ops.rb
Outdated
STORAGE_ACTIONS_TO_METHODS = { :backup => :add, :dump => :add, :restore => :download }.freeze | ||
private_class_method def self.with_file_storage(action, db_opts, connect_opts) | ||
db_opts = merged_db_opts(db_opts) | ||
connect_opts = connect_opts.reverse_merge(:uri => "file://") |
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 will this put the resulting backup file? Is this the same behavior as before or should we choose a better default?
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, so this is a bit of a hack to force the MiqLocalMountSession
to come out. Basically, all of the evm:db:remote
tasks should come with a :uri
by default, but evm:db:local
does not, and just passes a :local_file
option.
This "HACK" basically forces the MiqLocalMountSession
to be initialized when building the MiqFileStorage
object below, the :uri
is never used in that case, but just forces the scheme to the proper class.
Everything should work as it has before, and this just handles the case of local files in the same way.
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.
Hm, okay it looks like this all could be simplified because it sounds like we're actually removing special cases by handling them all the same, but I won't ask (and don't want) a refactoring of all of this in this PR.
lib/evm_database_ops.rb
Outdated
db_opts[:local_file] = session.uri_to_local_path(uri) | ||
MiqFileStorage.with_interface_class(connect_opts) do |file_storage| | ||
send_args = [uri, db_opts[:byte_count]].compact | ||
file_storage.send(STORAGE_ACTIONS_TO_METHODS[action], *send_args) do |input_path| |
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.
input_path
here is the IO stream that the actual backup command will either write to or read from, correct?
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.
Yup.
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 it's worth noting here in a comment that this can either be a stream or a file on a mounted filesystem. What do you 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.
Yeah, that seems reasonable. I will add some docs.
462721d
to
f12f99c
Compare
Okay |
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 comments on the comments, then this should be good to go.
lib/evm_database_ops.rb
Outdated
# | ||
# This just puts the bare minimum necessary for URI.parse to recognize | ||
# the :uri option as "file" scheme, and allows MiqFileStorage to then | ||
# instanciate MiqLocalMountSession below in the `.with_interface_class` |
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/instanciate/instantiate/
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 you believe me if I even made sure to :Spellcheck
prior to pushing... and still didn't catch this...
lib/evm_database_ops.rb
Outdated
# `uri` will always be the final destination, but `input_path` below will | ||
# be an intermediary fifo that will take the input from `pg_dump`, | ||
# `pg_restore`, or `pg_basebackup`, and stream the results (in ruby) it | ||
# to whatever endpoint it might be the resulting `uri`. |
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.
and stream the results (in ruby) it to whatever endpoint it might be the resulting
uri
.
This end bit of the sentence here just doesn't make sense.
lib/evm_database_ops.rb
Outdated
# HACK(ish): Since everything is flowing through MiqFileStorage so that | ||
# we can handle the file splitting logic all in one place, this means | ||
# that local dumps/backups also need to now have a "uri" in the | ||
# connection opts so that MiqLocalMountSession will be used. |
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 know I asked for this comment, but I think just the second paragraph gets the point across.
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.
Sometimes I write books, and sometimes it is just "word vomit"... you got the latter here.
MiqFileStorage is the new wrapper class around Object Stores and mounts, will a consistent interface for interacting with both. It's job is to handle streaming command output to the source destination, without letting the contents of the commands touch the local disk (unless the target is the local disk). A call to either `.add` or `.download` is now required for the proper IO redirection to work, but the interface is consistent between all providers, and the IO is expected to be handled in the same way for each.
Adds the `--byte-count` flag to evm:db:dump:* and evm:db:backup:* rake tasks which passes the `:byte_count` option to the MiqFileStorage for handling file splitting. Works with all classes that conform to the MiqFileStorage interface.
f12f99c
to
64f7f10
Compare
Some comments on commits NickLaMuro/manageiq@6902abc~...64f7f10 lib/evm_database_ops.rb
|
Checked commits NickLaMuro/manageiq@6902abc~...64f7f10 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 lib/evm_database_ops.rb
lib/tasks/evm_dba.rake
|
This is a reworking of #17652
By integrating the
MiqFileStorage::Interface
from ManageIQ/manageiq-gems-pending#361, we can introduce file splitting to all file storages that conform to that interface.The PR simply reworks
EvmDatabaseOps
to use that new interface, and introduces a--byte-count
flag to the dump/backup tasks to tell the File Storage to split the files on creation.Links
Steps for Testing/QA
You can use my test suite... if you can understand what it is doing and how to set it up...