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

Create Snapshot for Azure #15865

Merged
merged 4 commits into from
Aug 28, 2017
Merged

Conversation

jerryk55
Copy link
Member

@jerryk55 jerryk55 commented Aug 21, 2017

For Azure VMs check if a snapshot is required for SSA and if
so call the snapshot code.

On this go-round the snapshot will only be required for Managed Disks.

This is one of several PRs required to add support for SSA for Managed Disks,
that is is response to the following BZs:
https://bugzilla.redhat.com/show_bug.cgi?id=1475540
and
https://bugzilla.redhat.com/show_bug.cgi?id=1459612

A PR for the azure-armrest gem has already been merged in advance of this:
ManageIQ/azure-armrest#299

A PR for the manageiq-smartstate gem has been submitted as well:
ManageIQ/manageiq-smartstate#23

In addition a PR for the manageiq-providers-azure repo was added:
ManageIQ/manageiq-providers-azure#117

Links

Steps for Testing/QA

Add an Azure VM with a Managed Disk.
Run SmartState Analysis against the VM.

@roliveri @hsong-rh please review.

@@ -102,6 +102,8 @@ def call_snapshot_create
if vm.kind_of?(ManageIQ::Providers::Openstack::CloudManager::Vm) ||
vm.kind_of?(ManageIQ::Providers::Microsoft::InfraManager::Vm)
return unless create_snapshot(vm)
elsif vm.kind_of?(ManageIQ::Providers::Azure::CloudManager::Vm) && vm.require_snapshot_for_scan?
Copy link
Member

@chessbyte chessbyte Aug 22, 2017

Choose a reason for hiding this comment

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

why not just have each type of Vm have a require_snapshot_for_scan? method and remove all this complex if/else/elsif logic?

Copy link
Member Author

@jerryk55 jerryk55 Aug 22, 2017

Choose a reason for hiding this comment

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

@chessbyte I agree. It does open up a larger can of worms because there is similar logic for the snapshot removal and it seems that there is VMware logic built in to the code here in both cases. Doing some cleanup in this file would be helpful. For the purposes of fixing this BZ however, I'm not sure this is the right place to have it done. I can add it as a follow-on if you like. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Follow-up PRs to address this make sense. Please put it on your team's radar.

Copy link
Member

Choose a reason for hiding this comment

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

Ideally, we'd have different scan job classes based on VM type. The jobs for the types of VMs that don't require snapshots won't even have a snapshot state.

@@ -242,7 +244,8 @@ def call_snapshot_delete
# or, make type-specific Job classes.
if vm.kind_of?(ManageIQ::Providers::Openstack::CloudManager::Vm)
vm.ext_management_system.vm_delete_evm_snapshot(vm, mor)
elsif vm.kind_of?(ManageIQ::Providers::Microsoft::InfraManager::Vm)
elsif vm.kind_of?(ManageIQ::Providers::Microsoft::InfraManager::Vm) ||
vm.kind_of?(ManageIQ::Providers::Azure::CloudManager::Vm)
Copy link
Member

Choose a reason for hiding this comment

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

The condition for creating the snapshot is:

vm.kind_of?(ManageIQ::Providers::Azure::CloudManager::Vm) && vm.require_snapshot_for_scan?

Shouldn't that be the same condition for deleting the snapshot? The same question applies to the delete snapshot in the about code path.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep. Fixing.

For Azure VMs check if a snapshot is required for SSA and if
so call the snapshot code.

On this go-round the snapshot will only be required for Managed Disks.
Add Snapshot delete calls on abort and success.
Multiline condition indentation fixed.
Review comment pointed out that while we are validating that a VM requires
a snapshot (for a managed disk) before taking the snapshot, we are not
checking that the snapshot is required before deleting it either in the
success or abort case.
@jerryk55 jerryk55 force-pushed the snapshot_azure_for_ssa branch from dc883e4 to 9c80330 Compare August 25, 2017 17:18
@miq-bot
Copy link
Member

miq-bot commented Aug 25, 2017

Checked commits jerryk55/manageiq@8d6454d~...9c80330 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks fine. 🏆

@roliveri roliveri merged commit ab36e54 into ManageIQ:master Aug 28, 2017
@roliveri roliveri added this to the Sprint 68 Ending Sep 4, 2017 milestone Aug 28, 2017
@jerryk55
Copy link
Member Author

jerryk55 commented Sep 5, 2017

@miq-bot add_label fine/yes

simaishi pushed a commit that referenced this pull request Sep 6, 2017
@simaishi
Copy link
Contributor

simaishi commented Sep 6, 2017

Fine backport details:

$ git log -1
commit 35a1dfa5ff2dfaa79568c9bff42ec6055d77988d
Author: Richard Oliveri <[email protected]>
Date:   Mon Aug 28 16:35:43 2017 -0400

    Merge pull request #15865 from jerryk55/snapshot_azure_for_ssa
    
    Create Snapshot for Azure
    (cherry picked from commit ab36e54eadec6fdfdfdb31367c4d2a69df584b67)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1488967

d-m-u pushed a commit to d-m-u/manageiq that referenced this pull request Jun 6, 2018
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.

6 participants