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

Openstack cinder v1/v2/auto API support #40423

Merged
merged 2 commits into from
Mar 27, 2017
Merged

Openstack cinder v1/v2/auto API support #40423

merged 2 commits into from
Mar 27, 2017

Conversation

mkutsevol
Copy link
Contributor

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 #39572

Special 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:

Add support for v2 cinder API for openstack cloud provider. By default it autodetects the available version.

@k8s-ci-robot
Copy link
Contributor

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 @k8s-bot ok to test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 25, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 25, 2017
@lavalamp lavalamp assigned jbeda and unassigned lavalamp Jan 26, 2017
@xrl
Copy link

xrl commented Jan 28, 2017

My team is migrating to Mitaka and will lose Cinder V1 support. We are running this code and it's been functional and stable.

@xrl
Copy link

xrl commented Jan 31, 2017

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.

@mkutsevol
Copy link
Contributor Author

Sure @xrl, why not. Will update and push it out tomorrow.

@xsgordon
Copy link

xsgordon commented Feb 6, 2017

@idvoretskyi can you add the sig/openstack label?

@idvoretskyi idvoretskyi added the area/provider/openstack Issues or PRs related to openstack provider label Feb 7, 2017
@xrl
Copy link

xrl commented Feb 10, 2017

@jbeda @bgrant0607 can this work be reviewed and merged? it's significant and important to continue support with modern openstack installations.

@bgrant0607
Copy link
Member

@mkutsevol @xrl This PR needs to be reviewed by someone familiar with Openstack.

@xsgordon @idvoretskyi Please find someone to review.

@bgrant0607 bgrant0607 assigned idvoretskyi and xsgordon and unassigned jbeda and bgrant0607 Feb 28, 2017
@idvoretskyi
Copy link
Member

cc @Quentin-M @anguslees

})
if err != nil || sClient == nil {
glog.Errorf("Unable to initialize cinder client for region: %s", os.region)
return nil, err
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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" {
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

@mkutsevol mkutsevol Mar 10, 2017

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked at v3 and v2 create volume APIs, so far they look the same.

But I buy your points that things could diverge later.

@rootfs
Copy link
Contributor

rootfs commented Mar 21, 2017

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?

@jrperritt
Copy link
Contributor

any comments?

This seems fine to me.

@rootfs
Copy link
Contributor

rootfs commented Mar 21, 2017

@mkutsevol please make another (hopefully last) squash

@xsgordon
Copy link

@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.
@mkutsevol
Copy link
Contributor Author

@rootfs, pushed and tests are ok.

@idvoretskyi
Copy link
Member

cc @e0ne

@rootfs
Copy link
Contributor

rootfs commented Mar 21, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 21, 2017
@rootfs
Copy link
Contributor

rootfs commented Mar 21, 2017

@wojtek-t can you approve? Thanks.

@e0ne
Copy link

e0ne commented Mar 22, 2017

@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

@xsgordon
Copy link

xsgordon commented Mar 22, 2017

@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.

@hogepodge
Copy link

hogepodge commented Mar 22, 2017

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.

@rootfs
Copy link
Contributor

rootfs commented Mar 24, 2017

@anguslees can you approve?

@e0ne
Copy link

e0ne commented Mar 24, 2017

@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)
Copy link
Member

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.

Copy link
Contributor Author

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.

@anguslees
Copy link
Member

I made a minor style comment, but I'm ok with code being merged as-is.

/approve

@wojtek-t
Copy link
Member

/approve

@k8s-github-robot
Copy link

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 27, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 43681, 40423, 43562, 43008, 43381)

@k8s-github-robot k8s-github-robot merged commit 31e596e into kubernetes:master Mar 27, 2017
@xrl
Copy link

xrl commented Mar 27, 2017

How soon does this get in to the 1.5 series?

@mkutsevol
Copy link
Contributor Author

@xrl, hi!
I doubt that it will land into 1.5. It should have severe merge conflicts with 1.5

@xrl
Copy link

xrl commented Mar 29, 2017

OK, so how soon will it land in 1.6? 👍

@rootfs
Copy link
Contributor

rootfs commented Mar 29, 2017

@ethernetdan @calebamiles can this fix be cherry picked into 1.6?

@mkutsevol mkutsevol deleted the feature/openstack_cinder_v1_2_auto branch March 30, 2017 14:44
dims pushed a commit to dims/kubernetes that referenced this pull request Feb 8, 2018
…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.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/openstack Issues or PRs related to openstack provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Openstack blockstorage cinder v2