-
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
Openstack Swift DB Backups #17967
Openstack Swift DB Backups #17967
Conversation
a5a526a
to
4becfca
Compare
I would agree 100% if that was what we are doing. But its not. The
credentials are being passed/stored just as they are for the other
FileDepot implementations. We are only adding the additional parameters
not used by other FileDepots to the URI as Query parameters.
…On Tue, Sep 11, 2018 at 9:56 AM Marek Aufart ***@***.***> wrote:
Just $0.02 from OpenStack provider point of view. This seems to be as
pretty much of duplication of credentials and config needed to connect to
OpenStack. Storing credentials in encoded URL looks to me to have also
security implications since it is different (older) way than
Authentications are stored now.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#17967 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF1cZy_p1BwpK7GVzrZcUcWrZoIKP7JWks5uZ8EMgaJpZM4WiMPF>
.
--
JERRY KESELMAN
PRINCIPAL SOFTWARE ENGINEER,
CLOUDFORMS VM SMARTSTATE ANALYSIS & STORAGE
Red Hat Inc. <https://www.redhat.com/>
[email protected]
Gitter: jerryk55
IRC: jerrykbiker
|
@carbonin any chance of a final review and merge on this? Thanks! |
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 something I noticed that is in regards to what I am working on. (Update: Derp... this is wrong... resolving)
I was clearly confused... ignore me
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.
@agrare can you weigh in on how we should be writing out Open[s|S]tack?
app/models/database_backup.rb
Outdated
'smb' => 'Samba', | ||
'nfs' => 'Network File System', | ||
's3' => 'AWS S3', | ||
'swift' => 'Openstack Swift' |
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.
Should this be OpenStack
? Not sure how exact we need to be with branding here (I'm not sure if this is displayed to the user).
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 believe this should be OpenStack per https://www.redhat.com/en/technologies/linux-platforms/openstack-platform and https://www.openstack.org/
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.
Ok cool. I have to change this in here and in the UI code as well. Thanks for pointing it out.
app/models/file_depot_swift.rb
Outdated
end | ||
|
||
def verify_credentials(auth_type = nil, options = {}) | ||
auth_type ||= '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.
Couldn't we just make 'default'
the .. well .. default value for the parameter in the method definition? Why have the parameter default be nil
then set a value if it's nil.
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.
Absolutely.
'smb' => 'Samba', | ||
'nfs' => 'Network File System', | ||
's3' => 'Amazon Web Services', | ||
'swift' => 'Openstack Swift' |
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.
Same question here about Openstack
vs OpenStack
app/models/file_depot_swift.rb
Outdated
uri.query = [uri.query, "region=#{openstack_region}"].compact.join('&') if openstack_region.present? | ||
uri.query = [uri.query, "api_version=#{keystone_api_version}"].compact.join('&') if keystone_api_version.present? | ||
uri.query = [uri.query, "domain_id=#{v3_domain_ident}"].compact.join('&') if v3_domain_ident.present? | ||
uri.query = [uri.query, "security_protocol=#{security_protocol}"].compact.join('&') if security_protocol.present? |
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 think we could simplify this a bit by building a list of query elements outside of the uri.query
string object. Like this:
query_elements = []
query_elements << "region=#{openstack_region}" if openstack_region.present?
query_elements << "api_version=#{keystone_api_version}" if keystone_api_version.present?
query_elements << "domain_id=#{v3_domain_ident}"] if v3_domain_ident.present?
query_elements << "security_protocol=#{security_protocol}"] if security_protocol.present?
uri.query = query_elements.join('&').presence
Also we can drop the .present?
calls if these will only ever be nil or usable.
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.
If its nil then we'll end up with query strings like "region=&api_version=&domain_id=", won't we?
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.
Nope, I'm pretty sure my version works as I'm only adding the key=value
if the value is present, then joining only when the array is fully assembled.
Also, I'm not sure what "it" you're referencing here, but we should probably have a test for this method either way. I would suggest writing some tests that cover nil
values and then we can refactor with confidence.
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.
@carbonin I'm referring to your question about dropping the ".present?" calls if these will be nil or usable. if they're nil, and there is no .present? call, then the wrong thing will happen. Your code works correctly as written.
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.
if they're nil, and there is no .present? call, then the wrong thing will happen.
No, nil
is falsey.
This won't print anything:
foo = nil
puts "this won't print" if foo
What present?
and presence
do is move empty strings (and also other empty objects like arrays, hashes, etc) to also be false
or nil
respectively. So when I saw you using present?
I assumed that these could possibly be empty strings, but that seemed strange, which is why I asked.
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.
Doh! Obviously my physical exhaustion is affecting my mental capacity. Of course what you're saying is true. I think I need more coffee...
locale/en.yml
Outdated
@@ -730,6 +730,7 @@ en: | |||
FileDepotFtpAnonymous: Anonymous FTP | |||
FileDepotNfs: NFS | |||
FileDepotS3: AWS S3 | |||
FileDepotSwift: Openstack Swift |
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.
Same as the others.
4becfca
to
1978b36
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.
We should add specs here. At least for FileDepotSwift#merged_uri
, but ideally for more.
app/models/file_depot_swift.rb
Outdated
|
||
def merged_uri(uri, api_port) | ||
port = api_port.presence || 5000 | ||
uri = URI.parse("#{URI(uri).scheme}://#{URI(uri).host}:#{port}#{URI(uri).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.
Ah this was supposed to be part of the review, but this is rather complicated and I don't understand what it is accomplishing. Specs would help.
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.
Putting the port in the 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.
Since we had the same kind of things here:
ManageIQ/manageiq-appliance_console#66 (review)
Can we switch to just assigning port
to the uri
object as well? (instead of the quadruple URI.parse
)
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.
yes! I thought that was in this PR someplace - I forgot where we'd done it. Thanks!
1978b36
to
6c20977
Compare
@NickLaMuro @carbonin I've fixed the issue with credential verification. I see that there was a request for a spec in one case but other than this should be ready to go. The UI PR is ready to go and waiting on this one. I have gems-pending code from Nick L to push out and we should be ready at least with the Backup side of the equation if I can get buy-in from everyone. Let me look at a spec here. |
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 think this looks good to me, but I am a bit fuzzy on the workflow of the FileDepot
code, so I might have missed something.
The comments I left are minor, so they don't need to hold up the merge.
app/models/file_depot_swift.rb
Outdated
@@ -0,0 +1,69 @@ | |||
class FileDepotSwift < FileDepot | |||
attr_accessor :swift |
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.
Is this 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.
Not that I'm aware of. Removing.
@carbonin tests added. ready to rock and roll? |
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.
Nearly there, just some minor cleanup type stuff.
app/models/file_depot_swift.rb
Outdated
connect(options.merge(:auth_type => auth_type)) | ||
rescue Excon::Errors::Unauthorized => err | ||
msg = "Access to Swift host #{host} failed due to a bad username or password." | ||
logger.error("Access to Swift host #{host} failed due to a bad username or password. #{err}") |
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.
Same
886a660
to
7c17051
Compare
@carbonin All comments addressed and pushed. |
7c17051
to
c25ac99
Compare
spec/models/file_depot_swift_spec.rb
Outdated
expect(FileDepotSwift.uri_prefix).to eq "swift" | ||
end | ||
|
||
context "valid merged uri" do |
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.
This should really be the name of the method under test in this block. Also I prefer describe
for blocks which are testing a particular method and use context
for blocks which define shared setup.
So this would be the convention we normally would use here:
describe "#merged_uri" do
In support of the RFE described in BZ https://bugzilla.redhat.com/show_bug.cgi?id=1615488. Add a new FileDepot subclass for Swift. Since we need to pass info in to the Mount Session (in gems-pending) regarding the Openstack connection, utilize the URI with Query Parameters to do so.
Several changes based on PR review comments - 1) Change "Openstack Swift" to "OpenStack Swift" 2) Fix default argument handling 3) Refactor Query String processing.
Fix credentials verification. Cleanup extra log messages.
Nuff said.
Add some spec tests for the class including the merged_uri method.
Fixed one test so that it doesn't use the default port for the URI. Cleaned up some msg logging to be more efficient.
The merged_uri method was working incorrectly - coded to let the spec tests succeed but the validation of the Swift connection to fail.
Some formatting changes based on review comments.
c25ac99
to
3700e44
Compare
@carbonin spec changes made as requested. |
@jerryk55 We're still targeting hammer for this right? |
Yup. Assuming that the restore side can be finished by then. Which we are relying on @NickLaMuro to do the bulk of that... UI, Core, and Schema are merged. I'm working through comments on the backup side of the gems-pending PR, and there is still an outstanding appliance_console PR. |
Openstack Swift DB Backups (cherry picked from commit 520f007) https://bugzilla.redhat.com/show_bug.cgi?id=1615488
Hammer backport details:
|
Checked commits jerryk55/manageiq@fc21e30~...c25ac99 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 app/models/file_depot_swift.rb
spec/models/file_depot_swift_spec.rb
|
In support of the RFE described in BZ https://bugzilla.redhat.com/show_bug.cgi?id=1615488.
Add a new FileDepot subclass for Swift.
Since we need to pass info in to the Mount Session (in gems-pending) regarding the Openstack
connection, utilize the URI with Query Parameters to do so.
@carbonin @NickLaMuro @roliveri please review.
Links