Skip to content

Commit

Permalink
Fix send_args for EvmDatabaseOps.restore
Browse files Browse the repository at this point in the history
The `send_args` that are to be passed to `MiqFileStorage.download`
didn't account for the changes between `.upload` and `.download`, which
downloading expects a `nil` for the first argument when in block form
(who writes this crap*...).

To account for that, we prepend the `nil` value if we are doing a
`.restore`, which is the only time we are doing a download from a file
storage.

Partially addresses issues in the following tickets:

  - https://bugzilla.redhat.com/show_bug.cgi?id=1633573
  - https://bugzilla.redhat.com/show_bug.cgi?id=1513520

* Hint:  It was me...
  • Loading branch information
NickLaMuro committed Nov 5, 2018
1 parent 29907f5 commit 60fed56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/evm_database_ops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ def self.restore(db_opts, connect_opts = {})
MiqFileStorage.with_interface_class(connect_opts) do |file_storage|
send_args = [uri, db_opts[:byte_count]].compact

# Okay, this probably seems a bit silly seeing that we just went to the
# trouble of doing a `.compact)`. The intent is that with a restore, we
# are doing a `MiqFileStorage.download`, and the interface for that
# method is to pass a `nil` for the block form since we are streaming the
# data from the command that we are writting as part of the block.
send_args.unshift(nil) if action == :restore

# Note: `input_path` will always be a fifo stream (input coming from
# PostgresAdmin, and the output going to the `uri`), since we want to
# maintain the same interface for all backup types.
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/evm_database_ops_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def execute_with_file_storage(action = :backup)

context "for a restore action" do
it "updates db_opts[:local_file] in the method context" do
expect(file_storage).to receive(:send).with(:download, "smb://tmp/foo")
expect(file_storage).to receive(:send).with(:download, nil, "smb://tmp/foo")
execute_with_file_storage(:restore)
end

Expand Down

0 comments on commit 60fed56

Please sign in to comment.