Skip to content

vagrant destroy with libvirt leaves stale port forwarding around #13838

Description

@lindes

Debug output

I'm not sure you'll need them, as I hope I've provided sufficient information here, but in case you do, I've uploaded the debug files along with some related content here (attempting to paste into gist seems to have overloaded my browser's brain), with contents of several things:

  1. output (and error) of various vagrant commands, in the ?a-* (where ? is 0-4, and * is the command that was run) files, as per the filenames, but with --debug appended.
  2. output of ps -ft $(tty) www for each run, in ?b-ps-after-?a.out, for each of the above
  3. abbreviated output of vagrant ssh -c "ip addr" in 4c-ip-addr-after-4a.out
  4. the Vagrantfile (also below)
  5. the URL for a stack-overflow question mentioned (because copy/paste is still unhappy after the gist thing).
  6. partial output of an strace of vagrant up
  7. output of vagrant --version

Expected behavior

  1. When running vagrant destroy (or vagrant destroy -f), the ssh processes that are used to forward ports should be killed, as it seems to be with vagrant halt.
  2. Later, I expect new invocations of vagrant up to have ports properly forwarded.
  3. If that's not possible, I would expect to see an error generated.

Actual behavior

  1. vagrant up creates an ssh process that seems to fork itself, and vagrant halt and vagrant destroy both kill the parent of these two processes, but for whatever reason, when vagrant destroy does so (perhaps using a different signal?), the child ssh process is not killed, thus locking in a forwarder that ends up having a stale IP address, and
  2. not getting re-started in subsequent vagrant up, because
  3. while an attempt is made to launch a new ssh to forward ports, it silently (from a vagrant user's perspective, and even per the --debug logs) fails... though running vagrant up under strace -f -s 4096 ... shows that bind() is getting EADDRINUSE, because the old process is still around.

Reproduction information

Vagrant version

Vagrant 2.2.19 -- sorry it's not the latest; I'm hoping this is still relevant -- I found it in also existing in a StackOverflow answer from some years ago that hadn't been resolved, so... guessing it's a lingering bug. Unfortunately, I'm hitting this on a system where upgrading is infeasible currently.

Host operating system

Ubuntu 22.04.3 LTS

Guest operating system

Debian 13.5 trixie (debian/trixie64, libvirt, 13.20260519.1)

Steps to reproduce

  1. vagrant up
  2. vagrant destroy -f
  3. vagrant up

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "debian/trixie64"
  config.nfs.verify_installed = false
  config.vm.network "forwarded_port", guest: 80, host: 8080
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