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

Smart State Analysis for Hyper-V Disks #2428

Merged
merged 13 commits into from
Jan 5, 2016

Conversation

jerryk55
Copy link
Member

See the summary - "What Works and What Doesn't" at the bottom.

Add a new MiqDisk Disk Module to handle the VHDX virtual disk
format supported by the new version of Hyper-V and SCVMM.

Get Hard disk information for VMs managed
by SCVMM from the SCVMM and Hyper-V host via powershell
functions.

Read the hard disk from the Hyper-V host.

Gets the vhd, host, vhd type from the Hyper-V Host.
Opens and reads the vhd on the Hyper-V host.

This supports both VHDX files via the new VHDXDisk disk module
and the older VHD files via the existing disk modules. Support
for communicating to Hyper-V via miq_hyperv_disk was added
to the VHD modules.

The Microsoft Provider has been extended to allow SSA scans to be
run in addition to the MiqDisk, MiqVm, and Scvmm gems/pending code.

Enhancements still required:

  1. Currently Snapshots are created using VMNAME__EVM_SNAPSHOT
    as the snapshot name. An enhancement will add the date/time into the
    snapshot name.

  2. Caching has been implemented in the miq_hyperv_disk code which
    allows the VHD and VHDX disk modules to communicate to Hyper-V
    to read the files. We need to continue to look at this caching to speed this
    up as much as possible.

  3. Virtual disk files residing on network-mapped drives on the Hyper-V server, seen
    as starting with \ rather than a drive letter when the inventory is taken from the server,
    show up in the database with a NULL datastore ID. These files currently fail SSA
    because of this NULL ID. Hyper-V Inventory Doesn't Add Storage for VMs with VHDs on Network Drive #5383
    describes this issue. In addition to handling the parsing the code in MiqScvmmVm::getCfg
    needs to handle this situation. it currently does not.

  4. Certain VMs seem to timeout after looping doing I/O for an inordinate amount of time while
    local copies of the same VM VHD files run extremely quickly. Further investigation is needed;
    this may be related to the caching item in Use anand version #2 above.

What Works And What Doesn't -

  1. SSA works on local copies of VHD and VHDX disks and their checkpoints.
  2. SSA works on remote copies of VHD and VHDX disks and their checkpoints residing on Hyper-V servers, except some larger disks may time out based on network bandwidth and possibly one other unresolved issue.
  3. Hyper-V VMs with virtual disks residing on network-mapped drives starting with "" will not currently work.

@roliveri @Fryguy @chessbyte Please Review

By the way - an update to this old comment - this all works at this point.

@@ -0,0 +1,46 @@

Copy link
Member

Choose a reason for hiding this comment

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

Can you remove all these bonus blank lines at the start of every file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Absatootly. :-)

Copy link
Member

Choose a reason for hiding this comment

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

which of the requires below is coming from util? if none, then we do not need this push.

Copy link
Member Author

Choose a reason for hiding this comment

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

miq_winrm

@Fryguy Fryguy added the wip label Apr 20, 2015
@jerryk55 jerryk55 changed the title [WIP] Read Hyper-V VM Harddrive [WIP] Read Hyper-V VM Harddrive And Parse via VhdxDisk Module May 29, 2015
@miq-bot
Copy link
Member

miq-bot commented Jun 11, 2015

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Jun 26, 2015

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@@ -0,0 +1,69 @@
$LOAD_PATH.push("#{File.dirname(__FILE__)}/../util")
Copy link
Member

Choose a reason for hiding this comment

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

which of the requires below is coming from util? if none, then we do not need this push.

Copy link
Member Author

Choose a reason for hiding this comment

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

miq_winrm

@jerryk55 jerryk55 force-pushed the scvmm_harddrive_parsing branch 2 times, most recently from df6b6db to 967962d Compare June 29, 2015 16:24
@vhdx_file
end

def d_read(pos, len)
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to have targeted tests for complicated methods like this.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could run VCR like tests of this method by running a full end to end test of some scvmm disks, recording the inputs and outputs as test cases. It might help better understand the conditionals in this method.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would suppose that is a possibility. I'm not sure if we have anything like that for any of the disk formats we already support, by the way. Not that two wrongs make a right.

Copy link
Member

Choose a reason for hiding this comment

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

@jrafanie @jerryk55 - I hope to enable testing things like this in a general way very soon - once we're able to deploy the camcorder FS. Then, we should be able to write tests for all disk file formats.

Copy link
Member Author

Choose a reason for hiding this comment

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

And in the meantime I would think that the lack of the general test would not be a blocker to merging.

@jerryk55
Copy link
Member Author

@Fryguy yes I'll look into that in VhdxDisk.rb, VhdxDiskProbe.rb, MSVSDiskProbe.rb, miq_hyperv_disk.rb, miq_scvmm_vm_ssa_info.rb, as well as host.rb and infra_manager.rb in the microsoft provider. I do see it still out there in a few spots besides this - are these places that were left over, or places it was added back by other PRs? For instance under app/models host.rb, filesystem.rb, miq_server/server_smart_proxy.rb.

@chessbyte
Copy link
Member

@jerryk55 In general, this PR has several challenges.

  1. Too much new code vs little/no new specs.
  2. Too many unrelated changes or changes that should be split out into separate PRs. (eg new VHDx disk format).
  3. Too many changes/additions for the reviewer to absorb in one PR.
  4. Seems to add more duplication to our code base (ie lots of copy/paste without refactoring).

Lets discuss further in 2016.

Thanks,
Oleg

@jerryk55
Copy link
Member Author

@chessbyte okie dokie. Yes I've always thought that VhdxDisk could be its own PR, and the HyperVDisk methods could also stand on their own. Thanks.

@jerryk55
Copy link
Member Author

jerryk55 commented Jan 4, 2016

@roliveri @chessbyte @Fryguy @jrafanie This PR has been amended to pull the VhdxDisk module out as discussed. I will try to reword the log message of one or two of the commit messages but otherwise it is ready for any further review and merging when ready.

@@ -1,4 +1,4 @@
$LOAD_PATH << File.join(GEMS_PENDING_ROOT, "Scvmm")
# encoding: US-ASCII
Copy link
Member

Choose a reason for hiding this comment

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

why is this line being added?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I was under the mistaken impression that was standard practice in our code, but now I see that not to be the case.

@jerryk55
Copy link
Member Author

jerryk55 commented Jan 5, 2016

@chessbyte Removed the above extraneous encoding comments and re-pushed.

@miq-bot
Copy link
Member

miq-bot commented Jan 5, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

jerryk55 and others added 13 commits January 5, 2016 13:52
Get Hard disk information for VMs managed
by SCVMM from the SCVMM via powershell
functions.

Read the hard disk from the Hyper-V host.

Gets the vhd, host, vhd type from the SCVMM.
Opens and reads the vhd on the Hyper-V host.
This is part of the functionality to perform
Hyper-V/SCVMM VM fleecing

This commit was amended with peer review comments.
Get Hard disk information for VMs managed
by SCVMM from the SCVMM via powershell
functions.

Read the hard disk from the Hyper-V host.

Gets the vhd, host, vhd type from the SCVMM.
Opens and reads the vhd on the Hyper-V host.
This is part of the functionality to perform
Hyper-V/SCVMM VM fleecing.
Add a new MiqDisk Disk Module to handle the VHDX virtual
disk format supported by the new version of Hyper-V and
SCVMM.  Supports remote and local copies of vhdx and avhdx
disk files although remote disks need additional testing.
Allow VHD files to be accessed remotely via miq_hyperv_disk
to enable Smart State Analysis of VMs managed by SCVMM on
Hyper-V servers.

Note that pre-existing checksum handling for the header and footer in
this code is non-functional and has been turned off via the "skip_check"
argument.
Add a new MiqDisk Disk Module to handle the VHDX virtual
disk format supported by the new version of Hyper-V and
SCVMM.  Supports remote and local copies of vhdx and avhdx
disk files although remote disks need additional testing.
Add a new MiqDisk Disk Module to handle the VHDX virtual disk format
supported by the new version of Hyper-V and SCVMM.  Also supports
older VHD virtual disk format.  Supports remote and local copies of
files.
Multiple RuboCop Warning cleanup.  Of note is that MiqVM.rb has been modified
to clean up all spacing issues.  This was previously handled but is being
accomodated again due to rebasing issues with this PR eliminating the previous
spacing fix.
Multiple RuboCop Warning cleanup.  Of note is that MiqVM.rb has been modified
to clean up all spacing issues.  This was previously handled but is being
accomodated again due to rebasing issues with this PR eliminating the previous
spacing fix.
1) Bug in server_smart_proxy.rb caused VMware SSA to fail with "VM not found"
2) Reduce blocks read in miq_hyperv_disk.rb from 16 to 4.
3) Minor Rubocop cleanup.
1) Increase miq_hyperv_disk buffer cache from 200 to 300 entries.
2) Add a per-provider timeout adjustment to the VmScan object.  It defaults
   to 1 but is set to 4 for Microsoft so that very slow scans may succeed.
Fix timeout adjustment so that it does not occur when rspec is running.
Remove test which expected failure when running SSA on microsoft.
1. Fix test failures caused by timeout mods for Microsoft provider.
2. Mods for review comments by @roliveri to make provider->MiqVM interaction
   consistent with other providers - specifically change so that connect_to_ems
   connects and passed the handle to the connection in the ost structure.
1. Fix test failures caused by timeout mods for Microsoft provider.
2. Mods for review comments by @roliveri to
   i) make provider->MiqVM interaction consistent with other providers -
      specifically change so that connect_to_ems connects and passed
      the handle to the connection in the ost structure.
   ii) fix calculation of blocks in a disk in miq_hyperv_disk
3) Add debugging miq_hyperv_disk cache statistics code.
@miq-bot
Copy link
Member

miq-bot commented Jan 5, 2016

<github_pr_commenter_batch />Some comments on commits jerryk55/manageiq@3fabb83~...d17004d

@miq-bot
Copy link
Member

miq-bot commented Jan 5, 2016

Checked commits jerryk55/manageiq@3fabb83~...d17004d with ruby 2.2.3, rubocop 0.34.2, and haml-lint 0.13.0
28 files checked, 26 offenses detected

app/models/manageiq/providers/microsoft/infra_manager/host.rb

  • 🔹 - Line 10, Col 3 - Metrics/AbcSize - Assignment Branch Condition size for verify_credentials_windows is too high. [15.56/15]

app/models/manageiq/providers/microsoft/infra_manager/vm_or_template_shared/scanning.rb

gems/pending/MiqVm/MiqVm.rb

gems/pending/MiqVm/miq_scvmm_vm.rb

gems/pending/Scvmm/miq_hyperv_disk.rb

gems/pending/Scvmm/miq_scvmm_parse_powershell.rb

gems/pending/Scvmm/miq_scvmm_vm_ssa_info.rb

  • 🔹 - Line 33, Col 3 - Metrics/AbcSize - Assignment Branch Condition size for vm_all_harddisks is too high. [15.36/15]

gems/pending/disk/modules/MSCommon.rb

gems/pending/util/miq_winrm.rb

  • 🔹 - Line 32, Col 3 - Metrics/AbcSize - Assignment Branch Condition size for validate_options is too high. [16.03/15]

chessbyte added a commit that referenced this pull request Jan 5, 2016
Smart State Analysis for Hyper-V Disks
@chessbyte chessbyte merged commit 5ae91e2 into ManageIQ:master Jan 5, 2016
@chessbyte chessbyte added this to the Sprint 35 Ending Jan 25, 2016 milestone Jan 5, 2016
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.

7 participants