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

Fix uri dirname parsing for swift restore #18166

Merged

Conversation

NickLaMuro
Copy link
Member

The swift protocol is the only file storage used by EvmDatabaseOps at this time that uses query params as part of setting it's options.

The previous implementation of .with_file_storage would use a simple File.dirname to determine the mount point. This causes the query params to be completely stripped from the uri, and messes with the configuration set by the user via the query params.

There is also a quirk with the implementation of URI::FTP (stdlib) that overrides .path differently since it swaps it's "/" characters for "%2F", which we don't happening unannounced.

So for the fix, we use URI::Generic.new directly, and avoid the URI.parse method since it will make use of URI::FTP in those cases. Split is used as just a convenient way of getting the args for URI::Generic.new.

The swift protocol is the only file storage used by `EvmDatabaseOps`
at this time that uses query params as part of setting it's options.

The previous implementation of `.with_file_storage` would use a simple
`File.dirname` to determine the mount point.  This causes the query
params to be completely stripped from the uri, and messes with the
configuration set by the user via the query params.

There is also a quirk with the implementation of `URI::FTP` (stdlib)
that overrides `.path` differently since it swaps it's `"/"` characters
for `"%2F"`, which we don't happening unannounced.

So for the fix, we use `URI::Generic.new` directly, and avoid the
`URI.parse` method since it will make use of `URI::FTP` in those cases.
Split is used as just a convenient way of getting the args for
`URI::Generic.new`.
@NickLaMuro NickLaMuro force-pushed the fix_uri_for_database_restore_mount_point branch from ad4ec3a to 2d9e5d7 Compare November 5, 2018 22:42
@NickLaMuro
Copy link
Member Author

@miq-bot assign @carbonin
@miq-bot add_labels bug, core, hammer/yes

@miq-bot
Copy link
Member

miq-bot commented Nov 5, 2018

Checked commit NickLaMuro@2d9e5d7 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 1 offense detected

lib/evm_database_ops.rb

Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

looking good - just that one catch

@@ -291,10 +291,28 @@ def execute_with_file_storage(action = :backup)
execute_with_file_storage(:restore)
end

it "parses the dirname of the `uri` and passes that in `connect_opts`" do
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it "parses the dirname of the `uri` and passes that in `connect_opts`" do
it "parses the dirname of the 'uri' and passes that in 'connect_opts'" do

do you really want backticks in 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 always use backticks to denote variable names (pulled from markdown syntax). It isn't executed, so it is just a standard I am using to say this_is_code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, to further explain, I use backticks because I want to clarify that I am referencing a variable or some other syntax element, and not a string value (so not object.class.name.downcase == 'uri').

Copy link
Member

Choose a reason for hiding this comment

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

nvr mind -brain freeze

@kbrock kbrock merged commit 3d2a9b6 into ManageIQ:master Nov 6, 2018
@kbrock kbrock assigned kbrock and unassigned carbonin Nov 6, 2018
@kbrock kbrock added this to the Sprint 99 Ending Nov 19, 2018 milestone Nov 6, 2018
simaishi pushed a commit that referenced this pull request Nov 7, 2018
…e_mount_point

Fix uri dirname parsing for swift restore

(cherry picked from commit 3d2a9b6)
@simaishi
Copy link
Contributor

simaishi commented Nov 7, 2018

Hammer backport details:

$ git log -1
commit bdaaea6978c8f8e6b35ab92b52e1e67e5ace1404
Author: Keenan Brock <[email protected]>
Date:   Tue Nov 6 15:32:24 2018 -0500

    Merge pull request #18166 from NickLaMuro/fix_uri_for_database_restore_mount_point
    
    Fix uri dirname parsing for swift restore
    
    (cherry picked from commit 3d2a9b698468941b9606beed5926c8bc1f729587)

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