nix-community / nixops-vbox

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

fix: properly remove destroyed vm known host #29

Closed yajo closed 2 years ago

yajo commented 2 years ago

Calling update is meant to change the IP, not just to remove it.

You can see that because it always adds the new IP.

Here we're inside destroy(), so there's no use for trying to add an IP of a machine that no longer exists.

This was producing the following exception:

Traceback (most recent call last):
  File "/nix/store/7w0556wlj4sl1r8wy0alq6dilyg0dp7n-python3-3.8.9-env/lib/python3.8/site-packages/nixops/parallel.py", line 70, in thread_fun
    work_result = (worker_fun(t), None, t.name)
  File "/nix/store/7w0556wlj4sl1r8wy0alq6dilyg0dp7n-python3-3.8.9-env/lib/python3.8/site-packages/nixops/deployment.py", line 1462, in worker
    if m.destroy(wipe=wipe):
  File "/nix/store/7w0556wlj4sl1r8wy0alq6dilyg0dp7n-python3-3.8.9-env/lib/python3.8/site-packages/nixopsvbox/backends/virtualbox.py", line 617, in destroy
    nixops.known_hosts.update(self.private_ipv4, None, self.public_host_key)
  File "/nix/store/7w0556wlj4sl1r8wy0alq6dilyg0dp7n-python3-3.8.9-env/lib/python3.8/site-packages/nixops/known_hosts.py", line 71, in update
    add(new_address, public_host_key)
  File "/nix/store/7w0556wlj4sl1r8wy0alq6dilyg0dp7n-python3-3.8.9-env/lib/python3.8/site-packages/nixops/known_hosts.py", line 64, in add
    _rewrite(ip_address, True, public_host_key)
  File "/nix/store/7w0556wlj4sl1r8wy0alq6dilyg0dp7n-python3-3.8.9-env/lib/python3.8/site-packages/nixops/known_hosts.py", line 48, in _rewrite
    new.append(ip_address + " " + public_host_key)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

@moduon MT-904

yajo commented 2 years ago

I just noticed this is a duplicate of #27