Skip to content

Add support for os-retype volumeaction#2113

Merged
jtopjian merged 1 commit intogophercloud:masterfrom
nikParasyr:retype_volumeaction
Feb 13, 2021
Merged

Add support for os-retype volumeaction#2113
jtopjian merged 1 commit intogophercloud:masterfrom
nikParasyr:retype_volumeaction

Conversation

@nikParasyr
Copy link
Copy Markdown
Contributor

For #2110

Add support for the "os-retype" volumeaction that changes the volume_type of a volume.

The lowe-level implementation of the os-retype is driver specific on cinder. The links below are blobs on the api level.

Copy link
Copy Markdown
Contributor Author

@nikParasyr nikParasyr left a comment

Choose a reason for hiding this comment

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

@jtopjian I've added some comments/questions I have. Also the acceptance tests cover only blockstorage V3. The action is valid for V2 as well. let me know if you want me to add acceptance tests for V2 as well.

// no extra specs. This is required to bypass cinder-scheduler filters and be able
// to create a volume with this volumeType. An error will be returned if the volume
// type was unable to be created.
func CreateVolumeTypeNoExtraSpecs(t *testing.T, client *gophercloud.ServiceClient) (*volumetypes.VolumeType, error) {
Copy link
Copy Markdown
Contributor Author

@nikParasyr nikParasyr Feb 4, 2021

Choose a reason for hiding this comment

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

VolumeType needs to have empty extra specs in order to be able to create a volume with this type. Otherwise the cinder-scheduler and filterOpts get in the middle and the volume cannot be created. Currently on CreateVolumeType the extra specs are not tested due to some limitations, so it could be incorporated but i'm not sure if its the right move as ideally extra specs should be tested

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the limitations have to do with the OpenLab testing environment? If so it's OK to pass on doing that kind of test. As long as functionality was tested some other way - such as a local devstack environment.

Copy link
Copy Markdown
Contributor Author

@nikParasyr nikParasyr Feb 5, 2021

Choose a reason for hiding this comment

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

In my understanding, if you set extra_specs then the cinder-scheduler tries to map the volumeType to a back-end that matches these extra_specs. That behavior can be different per cloud depending on how the cinder-scheduler has been configured (which filters to use etc). I'd still say that the acceptance test is useful and i expect without extra_specs to avoid all the cloud-specific limitations of how the backens and cinder-scheduler is set-up.

I tested this on our test cluster and the acceptance passed (volume created properly, and type changed without an issue etc). I've also run a retype, basically the example on docs.go, between 2 valid volume_types that also went fine.

I've tried also on "in-use" volumes, the api call works, but the underlying retype operation fails. Same thing when i use openstack cli or horizon. This has to do with how the backends are set-up, the volume types etc so i consider it out of scope for gophercloud. The api docs have some info about restrictions.

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 4, 2021

Coverage Status

Coverage decreased (-0.0007%) to 79.839% when pulling c2f789d on nikParasyr:retype_volumeaction into 633d735 on gophercloud:master.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Feb 4, 2021

Build failed.

// MigrationPolicy specifies if the volume should be migrated when it is
// re-typed. Possible values are "on-demand" or "never". If not specified,
// the default is "never".
MigrationPolicy string `json:"migration_policy,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like there are only two possible values for MigrationPolicy: https://github.com/openstack/cinder/blob/876ac4e79fe14887ee3902ef833be5e2273d800b/cinder/api/schemas/volume_actions.py#L94-L96

Using a generic string is fine, but it's also possible to create a specific type for this like how it's done here:

If the migration policy choices rarely change, creating a type is usually a good method for more specific data modeling.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@nikParasyr nikParasyr force-pushed the retype_volumeaction branch 2 times, most recently from d3b8749 to 724b3de Compare February 5, 2021 09:19
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Feb 5, 2021

Build failed.

@nikParasyr
Copy link
Copy Markdown
Contributor Author

recheck

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Feb 7, 2021

Build succeeded.

@jtopjian
Copy link
Copy Markdown
Contributor

@nikParasyr Is this ready for review/merge?

@nikParasyr
Copy link
Copy Markdown
Contributor Author

nikParasyr commented Feb 13, 2021

@jtopjian Yes

Copy link
Copy Markdown
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

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

LGTM - Thank you!

@jtopjian jtopjian merged commit 632e052 into gophercloud:master Feb 13, 2021
@nikParasyr nikParasyr deleted the retype_volumeaction branch February 23, 2021 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants