-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Vagrant halt hangs on Debian VMs #10737
Comments
Hey there @termonio - I haven't tried libvirt (which we do not officially support on this repo), but this is not an issue at all with the virtualbox and vmware provider. I tried these debian boxes and they all were successfully halted without issue:
I'm guessing it's possible that it has something to do with the libvirt provider, since the debug message seems to be coming from that plugin:
|
It seems to me that the problem surfaces because in my setup hypervisor and Vagrant are not running on the same machine and communication is done via proxied ssh. To communicate with the VM, the ssh connection uses the hypervisor machine as a jump host. This is handled via a ssh proxy command that uses netcat. This type of setup (similar to the one in connection 1 even with the |
@DanHam: I did ensure that my machines have |
@terceiro I'm seeing this same behavior on CentOS 7 VMs as well, I'm also using proxycommand to start on a remote libvirt server. Did you ever find a solution to this ? |
Background
vagrant 2.2.4
vagrant-libvirt 0.0.45
two Debian 9.8 VMs (one custom build, one provided by Vagrant Cloud) running on a KVM host
I use the following Vagrantfile
Expected behaviour
vagrant halt
shuts down the VM and the command terminates.Actual behaviour
Spinning up the machines (
vagrant up --provider=libvirt
) and connecting via ssh (vagrant ssh
) works as expected.vagrant halt
does shut down the VM (as seen for instance in VirtualMachineManager) but the command hangs and eventually needs actrl-c
.vagrant global-status
shows the instance still as running.vagrant halt --debug
ends with(Note: I also provided this information as a comment on a related issue).
Observations and guesses
From what I have understood after looking into the Vagrant source and the debug log, Vagrant identifies the machine as Debian and uses the
halt
capabilities of a Linux machine and sends ashutdown -h now
as sudo via ssh to the VM. However, this ssh command seems to hang inchannel.wait
in the source code snippet listed below../embedded/gems/2.2.4/gems/vagrant-2.2.4/plugins/communicators/winssh/communicator.rb
:The exception block is never executed and Vagrant logs "Sending SSH keep-alive..." until terminated by
ctrl-c
Even though the machine has shutdown successfully Vagrant does not seem to notice that the ssh connection is closed. There are other issues that go in a similar direction (e.g. here). One recommendation is to ensure that
libpam-systemd
is installed andUsePam yes
is present in/etc/ssh/sshd_config
. My machines meet this recommendation. Moreover, looking at the detailed discussion about not terminating ssh connections on restart / reboot,openssh (1:7.2p2-6)
has provided a fix that serves to terminate ssh sessions cleanly if systemd doesn't do this itself.To verify that ssh connections are indeed cleanly terminated, I connected to the running VM (private IP 192.168.121.29 via ssh
vagrant ssh-config
)-J
option to specify a jump host that is present on recent implementations)After a shutdown connection 2 immediately reports a broken pipe. In contrast, connection 1 hangs (and requires a
~.
to reset).I tried various settings of the
ssh.proxy_command
(-q0
,-N
,-q0 -N
). These settings should quit the connection after receiving EOF. I can't providessh -J ...
viaproxy_command
(or, to be precise, I haven't found a way of doing so). So it seems that the problem could be related to the underlying Ruby SSH library. A workaround is much appreciated as this has impact on important use cases (given the market share of Debian).The text was updated successfully, but these errors were encountered: