nix-community / nixops-vbox

NixOps VirtualBox backend [maintainer=@AmineChikhaoui]
GNU Lesser General Public License v3.0
22 stars 15 forks source link

nixops destroy left VDI behind #4

Open davidak opened 5 years ago

davidak commented 5 years ago

I destroyed the VM and tried to deploy again, but the VDI was left behind, so deploy fails.

[davidak@ethmoid:~/code/nixops]$ nixops destroy -d targets
warning: are you sure you want to destroy VirtualBox VM ‘target’? (y/N) y
target> destroying VirtualBox VM...
target> 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

[davidak@ethmoid:~/code/nixops]$ nixops deploy -d targets
target> creating VirtualBox VM...
target> Virtual machine 'nixops-f69eceee-7251-11e9-ae57-02423d929eab-target' is created and registered.
target> UUID: 137482ac-e5ba-4424-9f26-e922bac135f4
target> Settings file: '/home/davidak/VirtualBox VMs/nixops-f69eceee-7251-11e9-ae57-02423d929eab-target/nixops-f69eceee-7251-11e9-ae57-02423d929eab-target.vbox'
target> creating disk ‘disk1’...
target> 0%...
target> Progress state: VBOX_E_FILE_ERROR
target> VBoxManage: error: Failed to clone medium
target> VBoxManage: error: Could not create the clone medium '/home/davidak/VirtualBox VMs/nixops-f69eceee-7251-11e9-ae57-02423d929eab-target/disk1.vdi'.
target> VBoxManage: error: VDI: cannot create image '/home/davidak/VirtualBox VMs/nixops-f69eceee-7251-11e9-ae57-02423d929eab-target/disk1.vdi' (VERR_ALREADY_EXISTS)
target> VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium
target> VBoxManage: error: Context: "RTEXITCODE handleCloneMedium(HandlerArg*)" at line 990 of file VBoxManageDisk.cpp
Traceback (most recent call last):
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/bin/..nixops-wrapped-wrapped", line 991, in <module>
    args.op()
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/bin/..nixops-wrapped-wrapped", line 412, in op_deploy
    max_concurrent_activate=args.max_concurrent_activate)
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1063, in deploy
    self.run_with_notify('deploy', lambda: self._deploy(**kwargs))
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1052, in run_with_notify
    f()
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1063, in <lambda>
    self.run_with_notify('deploy', lambda: self._deploy(**kwargs))
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 996, in _deploy
    nixops.parallel.run_tasks(nr_workers=-1, tasks=self.active_resources.itervalues(), worker_fun=worker)
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/lib/python2.7/site-packages/nixops/parallel.py", line 44, in thread_fun
    result_queue.put((worker_fun(t), None, t.name))
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 969, in worker
    r.create(self.definitions[r.name], check=check, allow_reboot=allow_reboot, allow_recreate=allow_recreate)
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/lib/python2.7/site-packages/nixops/backends/virtualbox.py", line 286, in create
    self._logged_exec(["VBoxManage", "clonehd", base_image, disk_path, "--format", "VDI"])
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/lib/python2.7/site-packages/nixops/backends/__init__.py", line 324, in _logged_exec
    return nixops.util.logged_exec(command, self.logger, **kwargs)
  File "/nix/store/fhhrm6nm71risrkp383nzdx1zviycfq6-nixops-1.7/lib/python2.7/site-packages/nixops/util.py", line 152, in logged_exec
    raise CommandFailed(err, res)
nixops.util.CommandFailed: command ‘['VBoxManage', 'clonehd', '/nix/store/bbdfkkkm0bf0g10qj994g6756lc0mkxn-virtualbox-nixops-19.03.vmdk', '/home/davidak/VirtualBox VMs/nixops-f69eceee-7251-11e9-ae57-02423d929eab-target/disk1.vdi', '--format', 'VDI']’ failed on machine ‘target’ (exit code 1)

I had to remove it manually:

rm -rf ~/VirtualBox\ VMs/nixops-f69eceee-7251-11e9-ae57-02423d929eab-target/