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

r/virtual_machine: Enforce storage vMotion restrictions #319

Merged
merged 4 commits into from
Dec 14, 2017

Conversation

vancluever
Copy link
Contributor

This PR adds restrictions to storage vMotion:

  • Externally-attached disks cannot be migrated.
  • Disk names must match the standard vSphere naming convention based on
    the current name of the virtual machine.
  • Linked clones are blocked from being migrated at this time.

The latter two restrictions will be lifted once #295 is fully realized
and we are tracking disks via a label/UUID combination.


Disk attachment migration is something I'd like for us to handle as well eventually, but exactly how that will be handled is a bit tricky as VM configuration needs to be updated as well pretty much at the same time. It might not be possible in the long run.

For use in some VM tests - will probably be removed once we fix the disk
naming issues.
This commit adds restrictions to storage vMotion:

* Externally-attached disks cannot be migrated.
* Disk names must match the standard vSphere naming convention based on
the current name of the virtual machine.
* Linked clones are blocked from being migrated at this time.

The latter two restrictions will be lifted once #295 is fully realized
and we are tracking disks via a label/UUID combination.
All of these restrictions will more than likely be removed or modified
in some way. The external attachment restriction will be a challenge,
but ultimately we want to try and control the lifecycle of that outside
of the VM, and work to re-attach that disk somehow after the migration.
How we go about that remains to be seen.
@vancluever vancluever added the bug Type: Bug label Dec 14, 2017
@vancluever
Copy link
Contributor Author

Test output pending.

PS: This also vendors the null resource as we use it in one test example now to stabilize disk names.

@vancluever
Copy link
Contributor Author

Tests pass:

=== RUN   TestAccResourceVSphereVirtualMachine
=== RUN   TestAccResourceVSphereVirtualMachine/basic
=== RUN   TestAccResourceVSphereVirtualMachine/ESXi-only_test
=== RUN   TestAccResourceVSphereVirtualMachine/shutdown_OK
=== RUN   TestAccResourceVSphereVirtualMachine/multi-device
=== RUN   TestAccResourceVSphereVirtualMachine/add_devices
=== RUN   TestAccResourceVSphereVirtualMachine/remove_middle_devices
=== RUN   TestAccResourceVSphereVirtualMachine/remove_middle_devices,_change_disk_unit
=== RUN   TestAccResourceVSphereVirtualMachine/high_disk_unit_numbers
=== RUN   TestAccResourceVSphereVirtualMachine/high_disk_units_to_regular_single_controller
=== RUN   TestAccResourceVSphereVirtualMachine/cdrom
=== RUN   TestAccResourceVSphereVirtualMachine/maximum_number_of_nics
=== RUN   TestAccResourceVSphereVirtualMachine/upgrade_cpu_and_ram
=== RUN   TestAccResourceVSphereVirtualMachine/modify_annotation
=== RUN   TestAccResourceVSphereVirtualMachine/grow_disk
=== RUN   TestAccResourceVSphereVirtualMachine/swap_scsi_bus
=== RUN   TestAccResourceVSphereVirtualMachine/extraconfig
=== RUN   TestAccResourceVSphereVirtualMachine/extraconfig_swap_keys
=== RUN   TestAccResourceVSphereVirtualMachine/attach_existing_vmdk
=== RUN   TestAccResourceVSphereVirtualMachine/in_folder
=== RUN   TestAccResourceVSphereVirtualMachine/move_to_folder
=== RUN   TestAccResourceVSphereVirtualMachine/static_mac
=== RUN   TestAccResourceVSphereVirtualMachine/single_tag
=== RUN   TestAccResourceVSphereVirtualMachine/multiple_tags
=== RUN   TestAccResourceVSphereVirtualMachine/switch_tags
=== RUN   TestAccResourceVSphereVirtualMachine/orphaned_(renamed)_disk_in_place_of_existing
=== RUN   TestAccResourceVSphereVirtualMachine/clone_from_template
=== RUN   TestAccResourceVSphereVirtualMachine/clone,_multi-nic_(template_should_have_one)
=== RUN   TestAccResourceVSphereVirtualMachine/clone_with_different_timezone
=== RUN   TestAccResourceVSphereVirtualMachine/clone_with_bad_timezone
=== RUN   TestAccResourceVSphereVirtualMachine/clone_with_bad_eagerly_scrub_with_linked_clone
=== RUN   TestAccResourceVSphereVirtualMachine/clone_with_bad_thin_provisioned_with_linked_clone
=== RUN   TestAccResourceVSphereVirtualMachine/clone_with_bad_size_with_linked_clone
=== RUN   TestAccResourceVSphereVirtualMachine/clone_with_bad_size_without_linked_clone
=== RUN   TestAccResourceVSphereVirtualMachine/clone_-_prevent_accidental_disk_deletion_from_shared_name_variable
=== RUN   TestAccResourceVSphereVirtualMachine/clone_with_different_hostname
=== RUN   TestAccResourceVSphereVirtualMachine/clone_with_extra_disks
=== RUN   TestAccResourceVSphereVirtualMachine/clone_with_cdrom
=== RUN   TestAccResourceVSphereVirtualMachine/cpu_hot_add
=== RUN   TestAccResourceVSphereVirtualMachine/memory_hot_add
=== RUN   TestAccResourceVSphereVirtualMachine/dual-stack_ipv4_and_ipv6
=== RUN   TestAccResourceVSphereVirtualMachine/ipv6_only
=== RUN   TestAccResourceVSphereVirtualMachine/windows_template,_customization_events_and_proper_IP
=== RUN   TestAccResourceVSphereVirtualMachine/host_vmotion
=== RUN   TestAccResourceVSphereVirtualMachine/resource_pool_vmotion
=== RUN   TestAccResourceVSphereVirtualMachine/storage_vmotion_-_global_setting
=== RUN   TestAccResourceVSphereVirtualMachine/storage_vmotion_-_single_disk
=== RUN   TestAccResourceVSphereVirtualMachine/storage_vmotion_-_pin_datastore
=== RUN   TestAccResourceVSphereVirtualMachine/storage_vmotion_-_block_disk_and_name_mismatch
=== RUN   TestAccResourceVSphereVirtualMachine/storage_vmotion_-_block_linked_clones
=== RUN   TestAccResourceVSphereVirtualMachine/storage_vmotion_-_block_externally_attached_disks
=== RUN   TestAccResourceVSphereVirtualMachine/import
=== RUN   TestAccResourceVSphereVirtualMachine/import_with_multiple_disks_at_different_SCSI_slots
--- PASS: TestAccResourceVSphereVirtualMachine (9196.56s)
    --- PASS: TestAccResourceVSphereVirtualMachine/basic (162.78s)
    --- SKIP: TestAccResourceVSphereVirtualMachine/ESXi-only_test (0.00s)
    	helper_test.go:87: set VSPHERE_TEST_ESXI to run ESXi-specific acceptance tests
    --- PASS: TestAccResourceVSphereVirtualMachine/shutdown_OK (156.40s)
    --- PASS: TestAccResourceVSphereVirtualMachine/multi-device (169.63s)
    --- PASS: TestAccResourceVSphereVirtualMachine/add_devices (185.59s)
    --- PASS: TestAccResourceVSphereVirtualMachine/remove_middle_devices (189.20s)
    --- PASS: TestAccResourceVSphereVirtualMachine/remove_middle_devices,_change_disk_unit (299.05s)
    --- PASS: TestAccResourceVSphereVirtualMachine/high_disk_unit_numbers (167.59s)
    --- PASS: TestAccResourceVSphereVirtualMachine/high_disk_units_to_regular_single_controller (293.23s)
    --- PASS: TestAccResourceVSphereVirtualMachine/cdrom (19.80s)
    --- PASS: TestAccResourceVSphereVirtualMachine/maximum_number_of_nics (172.00s)
    --- PASS: TestAccResourceVSphereVirtualMachine/upgrade_cpu_and_ram (306.03s)
    --- PASS: TestAccResourceVSphereVirtualMachine/modify_annotation (174.47s)
    --- PASS: TestAccResourceVSphereVirtualMachine/grow_disk (168.91s)
    --- PASS: TestAccResourceVSphereVirtualMachine/swap_scsi_bus (297.77s)
    --- PASS: TestAccResourceVSphereVirtualMachine/extraconfig (161.16s)
    --- PASS: TestAccResourceVSphereVirtualMachine/extraconfig_swap_keys (289.47s)
    --- PASS: TestAccResourceVSphereVirtualMachine/attach_existing_vmdk (164.21s)
    --- PASS: TestAccResourceVSphereVirtualMachine/in_folder (160.97s)
    --- PASS: TestAccResourceVSphereVirtualMachine/move_to_folder (175.87s)
    --- PASS: TestAccResourceVSphereVirtualMachine/static_mac (160.02s)
    --- PASS: TestAccResourceVSphereVirtualMachine/single_tag (163.59s)
    --- PASS: TestAccResourceVSphereVirtualMachine/multiple_tags (167.47s)
    --- PASS: TestAccResourceVSphereVirtualMachine/switch_tags (174.45s)
    --- PASS: TestAccResourceVSphereVirtualMachine/orphaned_(renamed)_disk_in_place_of_existing (390.47s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_from_template (125.60s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone,_multi-nic_(template_should_have_one) (133.16s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_with_different_timezone (121.52s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_with_bad_timezone (0.01s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_with_bad_eagerly_scrub_with_linked_clone (3.90s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_with_bad_thin_provisioned_with_linked_clone (4.06s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_with_bad_size_with_linked_clone (4.07s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_with_bad_size_without_linked_clone (4.05s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_-_prevent_accidental_disk_deletion_from_shared_name_variable (124.21s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_with_different_hostname (129.83s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_with_extra_disks (294.58s)
    --- PASS: TestAccResourceVSphereVirtualMachine/clone_with_cdrom (126.46s)
    --- PASS: TestAccResourceVSphereVirtualMachine/cpu_hot_add (138.93s)
    --- PASS: TestAccResourceVSphereVirtualMachine/memory_hot_add (140.23s)
    --- PASS: TestAccResourceVSphereVirtualMachine/dual-stack_ipv4_and_ipv6 (137.34s)
    --- PASS: TestAccResourceVSphereVirtualMachine/ipv6_only (420.70s)
    --- PASS: TestAccResourceVSphereVirtualMachine/windows_template,_customization_events_and_proper_IP (232.73s)
    --- PASS: TestAccResourceVSphereVirtualMachine/host_vmotion (140.77s)
    --- PASS: TestAccResourceVSphereVirtualMachine/resource_pool_vmotion (130.27s)
    --- PASS: TestAccResourceVSphereVirtualMachine/storage_vmotion_-_global_setting (391.94s)
    --- PASS: TestAccResourceVSphereVirtualMachine/storage_vmotion_-_single_disk (259.18s)
    --- PASS: TestAccResourceVSphereVirtualMachine/storage_vmotion_-_pin_datastore (393.07s)
    --- PASS: TestAccResourceVSphereVirtualMachine/storage_vmotion_-_block_disk_and_name_mismatch (255.14s)
    --- PASS: TestAccResourceVSphereVirtualMachine/storage_vmotion_-_block_linked_clones (124.69s)
    --- PASS: TestAccResourceVSphereVirtualMachine/storage_vmotion_-_block_externally_attached_disks (257.30s)
    --- PASS: TestAccResourceVSphereVirtualMachine/import (162.21s)
    --- PASS: TestAccResourceVSphereVirtualMachine/import_with_multiple_disks_at_different_SCSI_slots (170.45s)

Tests specific to this PR:

    --- PASS: TestAccResourceVSphereVirtualMachine/storage_vmotion_-_block_disk_and_name_mismatch (255.14s)
    --- PASS: TestAccResourceVSphereVirtualMachine/storage_vmotion_-_block_linked_clones (124.69s)
    --- PASS: TestAccResourceVSphereVirtualMachine/storage_vmotion_-_block_externally_attached_disks (257.30s)

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM!

@vancluever vancluever merged commit 0ceb91f into master Dec 14, 2017
@vancluever vancluever deleted the b-block-bad-storage-vmotion branch January 18, 2018 05:37
@prakashvv
Copy link

Hey @vancluever

Is the externally attached disk migration limitation still present in the latest release? We're currently doing that via direct VMware API calls and would move to terraform solution if that is available.

@ghost ghost locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants