Skip to content

Second 'vagrant up' destroys primary disk on hyper-v if it was resized in Vagrantfile #13720

@efussi

Description

@efussi

Debug output

Expected behavior

Second vagrant up succeeds with a resized primary disk.

Actual behavior

Got a stack trace:

Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
    default: Configuring the VM...
    default: Setting VM Enhanced session transport type to disabled/default (VMBus)
==> default: Disk 'vagrant_primary' no longer exists in Vagrant config. Removing and closing medium from guest...
==> default: Configuring storage mediums...
C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/cap/configure_disks.rb:70:in `get_current_disk': undefined method `[]' for nil (NoMethodError)
            current_disk = machine.provider.driver.get_disk(current_disk["Path"])
                                                                        ^^^^^^^^
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/cap/configure_disks.rb:90:in `handle_configure_disk'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/cap/configure_disks.rb:29:in `block in configure_disks'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/cap/configure_disks.rb:27:in `each'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/cap/configure_disks.rb:27:in `configure_disks'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/capability_host.rb:114:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/capability_host.rb:114:in `capability'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builtin/disk.rb:23:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builtin/cleanup_disks.rb:33:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builtin/cloud_init_setup.rb:54:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/action/net_set_mac.rb:18:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/action/net_set_vlan.rb:18:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/action/set_name.rb:22:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/action/configure.rb:110:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builtin/provision.rb:83:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:117:in `block in finalize_action'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builder.rb:183:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/runner.rb:104:in `block in run'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/util/busy.rb:22:in `busy'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/runner.rb:104:in `run'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builtin/call.rb:56:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:117:in `block in finalize_action'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builder.rb:183:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/runner.rb:104:in `block in run'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/util/busy.rb:22:in `busy'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/runner.rb:104:in `run'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builtin/call.rb:56:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:117:in `block in finalize_action'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builder.rb:183:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/runner.rb:104:in `block in run'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/util/busy.rb:22:in `busy'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/runner.rb:104:in `run'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builtin/call.rb:56:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:117:in `block in finalize_action'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builder.rb:183:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/runner.rb:104:in `block in run'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/util/busy.rb:22:in `busy'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/runner.rb:104:in `run'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builtin/call.rb:56:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builtin/config_validate.rb:28:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builtin/handle_box.rb:58:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/action/check_access.rb:22:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/plugins/providers/hyperv/action/check_enabled.rb:20:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/warden.rb:38:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/builder.rb:183:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/runner.rb:104:in `block in run'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/util/busy.rb:22:in `busy'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/action/runner.rb:104:in `run'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/machine.rb:244:in `action_raw'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/machine.rb:213:in `block in action'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/environment.rb:647:in `lock'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/machine.rb:199:in `call'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/machine.rb:199:in `action'
    from C:/Program Files/Vagrant/embedded/gems/gems/vagrant-2.4.9/lib/vagrant/batch_action.rb:88:in `block (2 levels) in run'

Reproduction information

Vagrant version

Vagrant 2.4.9

Host operating system

Windows 11

Guest operating system

Ubuntu 24.04

Steps to reproduce

  1. vagrant up --provider hyperv
  2. vagrant halt
  3. vagrant up --provider hyperv

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "boxen/ubuntu-24.04" # has a 10GB disk
  config.vm.disk :disk, size: "25GB", primary: true
  config.vm.synced_folder ".", "/vagrant", disabled: true
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions