Repository navigation
Shared Filesystems: Grant Access - #346
Conversation
b83719a to
f6c9e98
Compare
f6c9e98 to
e880c52
Compare
e880c52 to
cf83315
Compare
|
@jtopjian IMHO, this PR is ready for review, PTAL. |
2212c52 to
049604d
Compare
049604d to
1b583d8
Compare
|
@pospispa I appreciate the work you've put into this PR, but something like this can't be merged. You've got several third-party libraries including one of your own. Design changes to Gophercloud are OK sometimes, but they need to be discussed separately. As an example, we won't be using Glide, nor the package for parsing versions, nor your |
|
I agree with @jrperritt. With regard to the For discussion, I think we can simplify this PR down to two topics:
In order to do 2, you need to check if the client has a microversion set and then compare that microversion with the minimum version needed for the service. I think this check can be turned into a function so that func GrantAccess(client *gophercloud.ServiceClient, opts GrantAccessOptsBuilder, id string) (r GrantAccessResult) {
if err := supportedMicroversion(client) {
r.Err = err
return
}
...
}Maybe there's a better way of doing that, though -- that was just the first idea that came to me. Edit: Alternatively, we can forgo any microversion check and just let the API service return an error if the client was not configured correctly. |
|
@jrperritt I'm pretty new to |
|
@jtopjian the below:
I tried to set
So firstly, in case the microversion is not checked in the gophercloud library we end up with:
Secondly, in case we check the microversion in the gophercloud library we end up with:
I prefer the second option, i.e. to check the microversions in the gophercloud library. |
@jtopjian in constrast with the documentation I used wireshark to capture packet with So I looked again at manila server code and I didn't found the That's why I think these fields aren't being sent so I suggest I'll remove them. Please, what's your opinion? |
02f0791 to
e6ed0d7
Compare
|
@jtopjian I had to rebase this PR. I believe I've fixed all your comments except a couple of nits and the Please, let me know if you have further comments. |
You don't need to use wireshark. You can use: $ manila --debug ...
I appreciate you finishing the due diligence required to make sure this PR has all of the correct fields. If can find no evidence of those fields being returned, then they cannot be included here. |
By default shares are inaccessible because they do not have set any access permissions. That's why the Grant Access request is added.
34b618d to
3736803
Compare
@jtopjian I didn't find any evidence of those fields being returned so I deleted them. Please, check if everything looks good to you. |
jrperritt
left a comment
There was a problem hiding this comment.
Some naming changes; English is often unintuitive.
|
|
||
| // GrantAccessRequest will grant access to a Share based on the values in GrantAccessOpts. To extract | ||
| // the GrantAccess object from the response, call the Extract method on the GrantAccessResult. | ||
| func GrantAccessRequest(client *gophercloud.ServiceClient, id string, opts GrantAccessOptsBuilder) (r GrantAccessResult) { |
There was a problem hiding this comment.
Adding "Request" (or "Req", or "Res") is a non-starter. We'd like the functions to read well and be succinct. Users will know that this is a request because it starts with a verb ("Grant", which admittedly is very confusing, since "grant" can also be used as a noun). Let's call this GrantAccess.
| } | ||
|
|
||
| // GrantAccess contains all information associated with an OpenStack share Grant Access | ||
| type GrantAccess struct { |
There was a problem hiding this comment.
Following on from my comment above on GrantAccessRequest, response objects should be nouns. Here, something as simple as Access or AccessRight would work fine (again, admittedly confusing because "access" can be both a noun and a verb).
Perhaps @jtopjian has a better suggestion for the name
There was a problem hiding this comment.
@jrperritt thank you for the suggestions. I personally like AccessRight more.
There was a problem hiding this comment.
AccessRight works for me as well. I did not consider how nuanced the words in this PR could be, so I apologize about that.
One thing to keep in mind is that Manila has an API call to list access rules, which is a list of all GrantAccess calls that have been performed. Upon first glance, the body of these entries are slightly different than what AccessRight would be. Of course, it's always possible the docs are wrong.
If that API call gets implemented and new result structs need created, it might be a good idea to carry the AccessRight naming pattern to be consistent. Perhaps AccessRightEntries which is made up of individual AccessRightEntry (assuming AccessRightEntry is different than AccessRight).
Just thinking ahead. No action needs made.
| // GrantAccessResult contains the result body and error from an GrantAccess request. | ||
| type GrantAccessResult struct { | ||
| commonResult | ||
| } |
There was a problem hiding this comment.
@pospispa Take a look at the post-merge discussion that happened in #381 and the additional discussion in #449. I think this should be:
type GrantAccessResult struct {
gophercloud.Result
}The name "commonResult" probably made sense when this shares package was only handling "shares", but now that it also handles Export Locations and Access Rights, it might be helpful to think of commonResult as shareResult and only be applicable to Shares. Technically what you have will work, but it's more about naming and "inheritance" consistency.
@jrperritt hopefully I am correct on this one, or else I've just been looking at Gophercloud code too long and am all sorts of mixed up.
| // Extract will get the GrantAccess object from the commonResult | ||
| func (r GrantAccessResult) Extract() (*AccessRight, error) { | ||
| var s struct { | ||
| AccessRightRes *AccessRight `json:"access"` |
There was a problem hiding this comment.
| return | ||
| } | ||
| _, r.Err = client.Post(grantAccessURL(client, id), b, &r.Body, &gophercloud.RequestOpts{ | ||
| OkCodes: []int{200, 201}, |
There was a problem hiding this comment.
Do you know when a 201 would be returned? Have you seen a 201 in any manila --debug output? I have only been able to find a default 200 response here.
These return codes are usually the hardest pieces to find. I'm OK leaving both 200 and 201 here unless you're confident it's safe to drop 201.
There was a problem hiding this comment.
201 is a copy/paste error from func Create.
There was a problem hiding this comment.
Yeah, OkCodes are usually just taken from the API docs, which we know to be incorrect from time to time. However, IMO, return codes are the hardest thing to search for, so I'm not very strict with them when doing a review.
|
@jtopjian @jrperritt please, does it look good to you? Should I squash the commits? |
| // Extract will get the GrantAccess object from the commonResult | ||
| func (r GrantAccessResult) Extract() (*AccessRight, error) { | ||
| var s struct { | ||
| AccessRight *AccessRight `json:"access"` |
There was a problem hiding this comment.
👍
You're correct with *AccessRight here. I mistyped my last comment.
| // The UUID of the share to which you are granted or denied access. | ||
| ShareID string `json:"share_id"` | ||
| // The access rule type that can be "ip", "cert" or "user". | ||
| AccessType string `json:"access_type,omitempty"` |
There was a problem hiding this comment.
@jrperritt General question: Does omitempty provide any use here?
If I do:
$ grep -R omitempty ~/go/src/github.com/gophercloud/gophercloud | grep resultI see that there are a good number of results.
There was a problem hiding this comment.
Does omitempty provide any use here?
No; I think omitempty is only relevant for encoding. But it doesn't hurt either, so... meh.
There was a problem hiding this comment.
omitempty is probably useless here.
jtopjian
left a comment
There was a problem hiding this comment.
@pospispa This looks good to me. I have a general question with regard to the omitempty in the result struct, but given there are other result structs that are the same, I'll defer to @jrperritt for whether that should be fixed or not.
Don't squash the commits. Github can do a full squash when this gets merged.
Thank you for your patiences on this PR.
|
@jtopjian thank you for merging the PR. |
* Shared File Systems: Grant Access By default shares are inaccessible because they do not have set any access permissions. That's why the Grant Access request is added. * Added unit tests for POST Grant Access request. * Fixes for the first round of code reviews. * Fixes for the second round of code reviews. * Fixes for the third round of code reviews. * Fixes for the fourth round of code reviews. * Fixes for the fifth round of code reviews.
The total statements covered for the DM code is increased from 24.5-26.5% Signed-off-by: vineela-pachchipulusu <[email protected]>
For #315
Links to the line numbers/files in the OpenStack source code that support the
code in this PR:
https://github.com/openstack/manila/blob/stable/newton/manila/api/v1/shares.py#L393