-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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 cinder v1/v2/auto API support #40423
Openstack cinder v1/v2/auto API support #40423
Conversation
Hi @mkutsevol. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
My team is migrating to Mitaka and will lose Cinder V1 support. We are running this code and it's been functional and stable. |
Can I request a bump in the gophercloud version? I am having issues with expiring tokens in my build and a gophercloud update might help. |
Sure @xrl, why not. Will update and push it out tomorrow. |
@idvoretskyi can you add the sig/openstack label? |
@jbeda @bgrant0607 can this work be reviewed and merged? it's significant and important to continue support with modern openstack installations. |
@mkutsevol @xrl This PR needs to be reviewed by someone familiar with Openstack. @xsgordon @idvoretskyi Please find someone to review. |
}) | ||
if err != nil || sClient == nil { | ||
glog.Errorf("Unable to initialize cinder client for region: %s", os.region) | ||
return nil, 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.
This return is suspicious. If v1 API is not enabled, we should keep trying v2.
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.
And we will, creating a ServiceClient doesn't depend on supported blockstorage api versions
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 seems fine: either the user explicitly set "v1" in their config (in which case it should error) or it was determined that "v1" was current.
return nil, err | ||
} | ||
|
||
apiversions_v1.List(sClient).EachPage(func(page pagination.Page) (bool, error) { |
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.
what if block v1 api is disabled?
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.
There is no v2 apiversions at all in the gophercloud library.
It is used only to probe available versions.
So it will work flawlessly if v1 is absent.
return true, nil | ||
}) | ||
// Autoprobing failed, no supported versions available | ||
if os.bsOpts.BSVersion == "auto" { |
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 is redundant, the statement is already under auto
case.
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.
It is not, it will be (if probe is successful) switched to highest supported and available version on lines 589/592,
If it is left in "auto" that means that probe failed and it errors out with a corresponding error message.
return vol.ID, err | ||
} | ||
|
||
func (volumes *VolumesV2) Create(opts VolumeCreateOpts) (string, error) { |
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.
It looks to me, except in getVolume
where ServerID
and Device
are new in V2, CreateDisk
, DeleteDisk
and rest of getVolume
are identical in both V1 and V2.
In such case, why not just pass version as a new parameter into these functions and call the right package based on version, rather than copying code?
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 tend to agree that duplicate code is not good, but in this particular case, please consider why I did that way. I implement the IVolumes interface. Now, the Create/Delete methods are similar. But when v3 arrives that might not be the case. If I'll have a structure like:
func (volumes *VolumesV1) Create(opts VolumeCreateOpts) (string, error) {
return generalCreate('v1',...)
}
func (volumes *VolumesV2) Create(opts VolumeCreateOpts) (string, error) {
return generalCreate('v2',...)
}
... etc
I may force a developer, who will implement v3 support to adapt to that style, and no one knows what the lib will be like at that time. It may be not convenient.
I think that code organized this way (for this particular case) is more manageable.
When v3 arrives IVolumes implementations may be split into separate files, eg openstack_volumes_v#
Did I make you change your opinion? :D
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 tested latest code on my setup. I created a storage class, a claim and a Pod. Eventually the claim and pod were created through v2 api. @jrperritt any comments? |
This seems fine to me. |
@mkutsevol please make another (hopefully last) squash |
@hogepodge yes I had been politely ignoring the need for v3 support as while it is ultimately going to be needed the situation with v1 versus v2 is more critical right now. We probably should have a separate issue tracking the need for v3 support eventually though. |
Support for cinder v1/v2 api with the new gophercloud/gophercloud library. API version is configurable and defaulting autodetection.
@rootfs, pushed and tests are ok. |
cc @e0ne |
/lgtm |
@wojtek-t can you approve? Thanks. |
@xsgordon fair enough about v2 and v3. Anyway, from Cinder perspective both v1 and v2 versions are deprecated now. And as was said above, v3 and v2 versions are the same, so IMO it would be good to have v3 support. It will help to add microversions support in the future |
@rootfs I couldn't find an open issue for gophercloud V3 support so I filed gophercloud/gophercloud#305 - patches welcome I'm sure ;). @e0ne I don't disagree that it would be good, but right now we are blocked on the above and in the meantime the situation is that while V2 is deprecated but still supported V1 (the only version the provider supports right now) is completely removed (not just deprecated), so without this patch the provider's volume integration is not usable at all on OpenStack clouds that use recent releases of OpenStack. V3 support should be added in a separate PR once it is supported via Gophercloud. |
Yes please let's unblock on this PR and then work on cinder v3 in gophercloud, then getting it into a follow up on this patch. |
@anguslees can you approve? |
@xsgordon, @hogepodge sure, I won't block this patch anyway. |
if len(disk.Attachments) > 0 && disk.Attachments[0]["server_id"] != nil && instanceID == disk.Attachments[0]["server_id"] { | ||
if volume.AttachedServerId != instanceID { | ||
errMsg := fmt.Sprintf("Disk: %s has no attachments or is not attached to compute: %s", volume.Name, instanceID) | ||
glog.Errorf(errMsg) |
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.
minor point: This is an openstack-python pattern, and not usual for golang. Usually you want to glog the error xor return the error to your caller, presumably so they might glog it later with some additional context.
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.
@anguslees, thank you for the review, that is a direct port of logic of previous code. If/when time comes to add v3 support I will keep this in mind.
I made a minor style comment, but I'm ok with code being merged as-is. /approve |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: anguslees, mkutsevol, rootfs, wojtek-t
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue (batch tested with PRs 43681, 40423, 43562, 43008, 43381) |
How soon does this get in to the 1.5 series? |
@xrl, hi! |
OK, so how soon will it land in 1.6? 👍 |
@ethernetdan @calebamiles can this fix be cherry picked into 1.6? |
…cinder_v1_2_auto Automatic merge from submit-queue (batch tested with PRs 43681, 40423, 43562, 43008, 43381) Openstack cinder v1/v2/auto API support **What this PR does / why we need it**: It adds support for v2 cinder API + autodetection of available cinder API level (as in LBs). **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes kubernetes#39572 **Special notes for your reviewer**: Based on work by @anguslees. The first two commits are just rebased from kubernetes#36344 which already had a lgtm by @jbeda **Release note**: ``` Add support for v2 cinder API for openstack cloud provider. By default it autodetects the available version. ```
What this PR does / why we need it:
It adds support for v2 cinder API + autodetection of available cinder API level (as in LBs).
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #39572Special notes for your reviewer:
Based on work by @anguslees. The first two commits are just rebased from #36344 which already had a lgtm by @jbeda
Release note: