Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Allow status and ssh to run without a lock #457

Merged
merged 1 commit into from
Jul 3, 2016

Conversation

Sharpie
Copy link
Contributor

@Sharpie Sharpie commented Apr 11, 2016

Prior to this patch long running operations, such as provisioners, would
prevent vagrant status or vagrant ssh from being run due to Vagrant
action locking. Attempting such actions would result in an error message. This
is inconvienant as shelling into a VM is a common debugging step in figuring
out why a provisioner is taking longer than usual.

Vagrant 1.7 introduced the ability to mark certain actions as not requireing a
lock. This patch adds lock: false to the get_state and get_ssh_info calls
which allows both vagrant status and vagrant ssh to function while a
long-running action is executing in another process. Vagrant 1.6 will ignore
the unknown lock option and fail as usual.

Prior to this patch long running operations, such as provisioners, would
prevent `vagrant status` or `vagrant ssh` from being run due to Vagrant
action locking. Attempting such actions would result in an error message. This
is inconvienant as shelling into a VM is a common debugging step in figuring
out why a provisioner is taking longer than usual.

Vagrant 1.7 introduced the ability to mark certain actions as not requireing a
lock. This patch adds `lock: false` to the `get_state` and `get_ssh_info` calls
which allows both `vagrant status` and `vagrant ssh` to function while a
long-running action is executing in another process. Vagrant 1.6 will ignore
the unknown `lock` option and fail as usual.
@Sharpie
Copy link
Contributor Author

Sharpie commented Apr 11, 2016

Simple reproduction case:

Vagrant.configure('2') do |config|

  config.vm.provider :aws do |p, o|
    # AWS configuration.
  end

  config.vm.define :test do |node|
    # Some long-running provisioner
    node.vm.provision :shell, inline: 'sleep 300'
  end

end

Run vagrant provision test in one terminal. Open a separate terminal and attempt vagrant status or vagrant ssh test. Both will fail with:

An action 'get_state' was attempted on the machine 'test',
but another process is already executing an action on the machine.
Vagrant locks each machine for access by only one process at a time.
Please wait until the other Vagrant process finishes modifying this
machine, then try again.

If you believe this message is in error, please check the process
listing for any "ruby" or "vagrant" processes and kill them. Then
try again.

@Sharpie
Copy link
Contributor Author

Sharpie commented Apr 18, 2016

@rtyler Any thoughts on this patch? It's a small change that eases a lot of pain.

@rob1256
Copy link

rob1256 commented Apr 20, 2016

👍 This fix would save me a lot of hassle when working with AWS instances. Some of my provisioning scripts fail because of it.

@rtyler rtyler added this to the 0.7.1 milestone Jul 3, 2016
@rtyler rtyler merged commit 3036c8a into mitchellh:master Jul 3, 2016
@Sharpie Sharpie deleted the dont-lock-for-ssh branch July 5, 2016 21:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants