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

Snapshots revert API #13829

Merged
merged 1 commit into from
Feb 27, 2017
Merged

Conversation

imtayadeway
Copy link
Contributor

@imtayadeway imtayadeway commented Feb 9, 2017

Adds a revert action to the Vms and Instances APIs

@miq-bot add-label wip, api, enhancement
@miq-bot assign @abellotti

@@ -299,7 +299,7 @@ def validate_post_api_action_as_subcollection(cname, mname, aname)
return if cname == @req.collection
return if collection_config.subcollection_denied?(@req.collection, cname)

aspec = collection_config.typed_subcollection_actions(@req.collection, cname)
aspec = collection_config.typed_subcollection_actions(@req.collection, cname, @req.s_id ? :subresource : :subcollection)
Copy link
Member

Choose a reason for hiding this comment

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

why this change here ? do you need to rebase maybe ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Up to this point we haven't needed to have a subresource POST action, so this wasn't needed in the previous PR

Copy link
Member

Choose a reason for hiding this comment

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

I'm confused, we had the delete post action before. we may be missing a test for that, so it was never exercised.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@abellotti in the case of snapshots, the delete action would have used the collection identifier erroneously, which happens to be the same. So there was no way to test this in an integration test.

Copy link
Member

Choose a reason for hiding this comment

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

Got it now, problem is that it worked for delete because it used the delete action's identifier on the subcollection, but we don't implement a bulk revert action on the snapshots subcollection (does not make sense to do so), thus this problem emerged. So I'm good with this fix, Thanks.

expect(response).to have_http_status(:forbidden)
end
end

describe "POST /api/vms/:c_id/snapshots/:s_id with delete action" do
it "can queue a snapshot for deletion" do
api_basic_authorize(action_identifier(:vms, :delete, :snapshots_subresource_actions, :delete))
Copy link
Member

Choose a reason for hiding this comment

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

missing delete post action test ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understand - is this not it?

Copy link
Member

Choose a reason for hiding this comment

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

sorry, misread the diffs. yes you have it.

@@ -374,6 +420,52 @@
end
end

describe "POST /api/vms/:c_id/snapshots/:s_id with revert action" do
Copy link
Member

Choose a reason for hiding this comment

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

should reflect instances

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@imtayadeway
Copy link
Contributor Author

Please rebase this PR to incorporate #13846 in order to ensure api.yml integrity ❤️ ❤️ ❤️

@miq-bot
Copy link
Member

miq-bot commented Feb 9, 2017

This pull request is not mergeable. Please rebase and repush.

config/api.yml Outdated
@@ -848,6 +848,8 @@
- :name: read
:identifier: cloud_volume_snapshot_view
:post:
- :name: revert
:identifier: cloud_volume_snapshot_revert # doesn't exist yet
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@h-kataria are you able to advise on this? Unfortunately I don't have any development instances that are snapshot-able - is it possible to revert an instance snapshot? Or is that tied into the backup/restore flow?

Copy link
Member

Choose a reason for hiding this comment

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

/cc @agrare @blomquisg is it possible to revert snapshots on instances ?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any cloud providers implementing snapshot revert, @blomquisg correct me if I'm wrong but it might be because they actually snapshot cloud volumes not instances. At least in GCE you can't revert to a snapshot volume, you just create a new instance from the snapshot, not sure if that's the same in AWS/Azure/etc...

@chessbyte chessbyte changed the title [wip] Snapshots revert API [WIP] Snapshots revert API Feb 14, 2017
@imtayadeway imtayadeway changed the title [WIP] Snapshots revert API Snapshots revert API Feb 17, 2017
@imtayadeway
Copy link
Contributor Author

@miq-bot rm-label wip

@miq-bot
Copy link
Member

miq-bot commented Feb 23, 2017

Checked commit imtayadeway@b221e27 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks good. 🏆

@abellotti
Copy link
Member

How did the tests go with a physical Vm ?

@AllenBW
Copy link
Member

AllenBW commented Feb 27, 2017

Any update on this one?

@abellotti abellotti added this to the Sprint 55 Ending Feb 27, 2017 milestone Feb 27, 2017
@abellotti
Copy link
Member

Just tested this with @imtayadeway and it's good, got VM's reverted on Esx successfully. 👍

@abellotti
Copy link
Member

LGTM!! 🎵

@abellotti abellotti merged commit 2af5d7f into ManageIQ:master Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants