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

Fixes and cleanup for MiqSwiftStorage #398

Merged

Conversation

NickLaMuro
Copy link
Member

  • Fixes a bug with @container_name generation (didn't properly handle nested keys
    • "Simplifies" the code a bit too (depends on your affinity for regular expressions I guess...)
  • Aligns comments to a standard 80 character width, with a few tweaks.

There was a bug when passing in a `:uri` to `MiqSwiftStorage` where if
the path for uri contained a filename as well:

    swift://example.com/container/path/to/file?query=params

It would assign the `@container_name` to the full path (minus the
leading slash), and not just the top level "directory".

This fixes that so it is correct.
Also adds some spacing for clarity.
@miq-bot
Copy link
Member

miq-bot commented Nov 2, 2018

Checked commits NickLaMuro/manageiq-gems-pending@aa9436d~...10ac180 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/gems/pending/util/object_storage/miq_swift_storage.rb

  • ⚠️ - Line 19, Col 94 - Lint/UriEscapeUnescape - URI.encode method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.

@@ -16,12 +16,15 @@ def initialize(settings)
@bucket_name = URI(@settings[:uri]).host

raise "username and password are required values!" if @settings[:username].nil? || @settings[:password].nil?
_scheme, _userinfo, @host, @port, _registry, @mount_path, _opaque, query, _fragment = URI.split(URI.encode(@settings[:uri]))
Copy link
Member

Choose a reason for hiding this comment

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

Was the @mount_path variable unused before? Seems odd that it was being assigned here if we didn't need it. @jerryk55 ?

Copy link
Member

Choose a reason for hiding this comment

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

To clarify, I see that it was being used to set @container_name, but because it's an instance variable (rather than a local) I'm being cautious about it being used elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

Just took a closer look. Looks like this is only used in mount sessions (rather than object stores).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we should probably remove the @mount_path and just make it a local variable so it can be garbage collected, but I decided to leave it for now. Can do a follow up later to fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I just looked at the code I wrote, and I did do that... ignore me...

@carbonin carbonin self-assigned this Nov 5, 2018
@carbonin carbonin merged commit 54b6861 into ManageIQ:master Nov 5, 2018
@carbonin carbonin added this to the Sprint 98 Ending Nov 5, 2018 milestone Nov 5, 2018
simaishi pushed a commit that referenced this pull request Nov 5, 2018
…ft-storage

Fixes and cleanup for MiqSwiftStorage

(cherry picked from commit 54b6861)
@simaishi
Copy link
Contributor

simaishi commented Nov 5, 2018

Hammer backport details:

$ git log -1
commit 43a08d8ab2f78d718d20dd487f00e18b78d7bb2c
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Mon Nov 5 10:07:11 2018 -0500

    Merge pull request #398 from NickLaMuro/fixes-and-cleanup-for-miq-swift-storage
    
    Fixes and cleanup for MiqSwiftStorage
    
    (cherry picked from commit 54b6861ad921308110fec037888832afea5b139c)

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.

4 participants