-
Notifications
You must be signed in to change notification settings - Fork 30
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
Smb synced folders for Windows "guests" #47
Conversation
@@ -26,21 +26,6 @@ def self.action_up | |||
|
|||
b2.use LinkServer | |||
end | |||
=begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just removing commented out code for cleanliness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! :-) 👍
…use SMB file sharing, rather than the very slow uploading over WinRM. no h in sync Revent ip change used to work around mac vbox routing table issue
e46bf31
to
8a68af1
Compare
Please help me understand: From what I have experienced playing around with automating windows guests, I got the impression that vagrant by default uses WinRM for synced folders too? I'm not 100% sure with that, but it was my impression at least (and I never ran it from an admin shell and I was never prompted for passwords either). Is it right, that the I might be totally wrong, just trying to understand. |
Trying to get an example running, and I see what you mean now with winrm uploads being "painfully slow" ;-) |
However, I have some kind of weird behaviour:
May that be because I am not running from a privileged shell? My example and debug gist follows... |
Were you running this from a Windows or non-Windows host? I also didn't see the output gist, my apologies if I missed something obvious. |
I'm running this from a windows host, using the latest tknerr/bills-kitchen version. It has rsync.exe in the PATH, maybe that makes a difference Didn't come to uploading the gist yet, was interrupted by $dayjob ;-) |
I'm trying to repro using the Vagrantfile in your WIP branch on my Windows host and will report back what I find. |
So, here's my current state:
Haven't had the chance to analyze the log output yet, and will be afk for a while now. Most interesting for me would be if you can reproduce it, or whether it's specific to my env... |
I'll check the gist and see if it differs from what I'm seeing. I was using On Tue, May 19, 2015 at 10:48 AM, Torben Knerr notifications@github.com
|
Update: while trying to debug another, semi-unrelated issue, I was able to repro your case. I'm digging in further now. |
I think I've figured out what was going on - the SMB synced folder action was not def self.action_provision
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use WarnNetworks
b.use Call, IsLinked do |env, b2|
unless env[:result]
b2.use MessageNotLinked
next
end
b2.use Call, IsReachable do |env, b3|
unless env[:result]
b3.use MessageNotReachable
next
end
b3.use Provision
if env[:machine].config.vm.communicator == :winrm
env[:ui].info("Checking if SMB folder sync is usable")
smb_usable = false
begin
smb_synced_folder_class = Vagrant.plugin("2").manager.synced_folders[:smb][0]
smb_usable = smb_synced_folder_class.new.usable?(machine: nil, raise_error: true)
rescue => ex
env[:ui].warn("Unable to use SMB folder sync, falling back to WinRM")
env[:ui].warn(ex.message)
end
if smb_usable
b3.use Vagrant::Action::Builtin::SyncedFolders
else
b3.use SyncFolders
end
else
# Vagrant managed servers custom implementation
b3.use SyncFolders
end
end
end
end
end I still need to handle a few other things, but it would be good to validate this new approach works for you before I invest more time. TODO:
|
@chrisbaldauf let me do some further investigation. I just noted that the initial gist I posted was completely useless, as the remote windows server was not running. Just updated it with the more meaningful log output. Can not see from the logs why it thinks that rsync would be the best option though.... |
After removing
Also updated the gist with debug log output from the without-rsync case |
After telling vagrant explicitly to use "smb": ms_config.vm.synced_folder ".", "/vagrant", type: "smb" I now get a clear error message:
|
Once I run the above from an elevated command prompt to make smb work, vagrant seems to hang after checking the powershell version. Also looks like I have powershell v2 installed, so I would need v3 anyway... Here's where it stalls:
|
Also, once I am in an elevated shell, I no longer need this line in the managed server config:
Even without the config above, it will try to use smb when run from an elevated shell. Still it stalls at the same place as mentioned above |
I was able to reproduce on a windows machine running powershell 2.0. I think I've got enough feedback for now and I'll follow up when I've got something ready. Thanks!
|
@chrisbaldauf thanks, too! I think we'll need both: the existing slow (but most compatible) winrm upload, and if We can try to autodetect what's better, but it would be also nice to have config option to override. I would also be 100% fine with:
That way we would not need any auto-detection at all (but also have no auto-detection ;-)) and would not need to introduce an additional config option. If you say that auto-detection is useful for you, let's add it. You care more about the windows / smb support than I do currently. And you contributed the whole windows support. So the decision should definitely be up to you |
For the sake of documentation and completeness: Without an elevated prompt: not
Within an elevated prompt: aksing if
|
@chrisbaldauf if we wanted to do it really clean and in line with the vagrant philosophy, this would probably mean:
This would be the best / cleanest solution imho, but probably the most effort too. I don't have time to invest for this right now, though :-/. If you have, feel free to go ahead, I'll happily support you with testing. If not, let's make it work first and then make it nice (later, in a second step). |
Thinking again... maybe the above clean approach would not be so much extra work though, guess it could save us some work afterwards, e.g.:
|
On reusing the existing rsync plugin: Just tested: works fine for me on my win7 host, yet I still need to work around hashicorp/vagrant#4073 by appending the "/cygpath" prefix here (which I needed to do anyway if I ever wanted to use rsync shared folders from my win7 host...) |
The problem that I have with setting the I do like the idea of using the built in SyncFolders action, but then we lose the WinRM upload, which seems to be fast enough and pretty reliable for small numbers of files / folders. Do you think a WinRM synced_folder type would have general value to Windows users? Do you think they'd choose it over SMB? Do you have any idea on the turnaround time for submitting features to Vagrant core? |
Hey @chrisbaldauf, I didn't meant to contribute the winrm synced folder to vagrant core. I rather meant to construct it ike the other synced folder plugin implementations, i.e.:
I see the problem with plugins creating synced folders dynamically. And I believe all these plugins (same for Chef I guess) rely on Vagrant to decide which of the available synced folder implementations is the best (if we are using One way to fix it would be to register the "winrm" synced folder implementation with a priority of
Putting the winrm plugin inbetween would mean it would try Btw: I didn't mean to contribute the winrm synced folder to vagrant core, but instead just use the synced folder plugin API as (I believe is) intended. It could still live here in this plugin, but since it's a generally useful addition, it would also justify for a dedicated "vagrant-winrm-syncedfolder" plugin. While my current feeling says this is the right way to do it, I would still be okay with keeping our own |
Ah, I see - not putting WinRM synced folders into the core makes it a much easier sell. I think your proposal is the right way to go and I'll work on pulling something together. I had noticed that there was room to squeeze the WinRM with a priority of 6 in there, but I incorrectly figured it should go into Vagrant core. I think the biggest blocker at this point is the hanging Powershell version check when run on Powershell 2.0. I'm able to reproduce that regularly and I believe we need an answer to that before any of this works, since if you're running PowerShell 2.0, it won't give you an error message about upgrading, it will just hang forever. |
Ah right, the powershell 2.0 issue is indeed annoying. I usually don't run Would be much better if vagrant would just elevate for that specific
|
Just pushed something that I believe should work (save the powershell version check hanging bug). You can test that the new WinRM synced folder plugin works by patching the SMB usable to My intention is to move the winrm folder sync to another repo and publish it as its own plugin, just wanted to check that it worked integrated first. There is still more work to do in cleaning up SMB folders, but it certainly feels cleaner and as if we're making progress. I left the non-winrm implementation as is, since it seems like there is real risk that the behavior could differ between builtin Rsync synced folders and the VMS implementation. If you feel that this is something that is required, let me know. |
mechanism, most notably that file tranfer is slow for large numbers of files. | ||
EOF | ||
|
||
synced_folder("wirnm", 6) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "wirnm" instead of "winrm" ;-)
The WinRM synced folder plugin looks good to me, and works as advertised:
👍 for publishing it as a separate plugin, so that one can benefit from it independently of the VMS plugin As for the VMS specific rsync implementation: yes, let's keep it in for now until we have a clean workaround for hashicorp/vagrant#4073 (which the VMS implementation does not suffer from). My idea was to publish this via a "vagrant-rsync-on-windows-monkey-patch" plugin (probably need to find a better name ;-)) first |
To summarize When provisioning managed Windows servers (more precisely: with
There are still open bugs with SMB, but these are actually vagrant core smb plugin bugs:
I'm fine with releasing the current state, it's not perfect but definitely an improvement. Remaining question about the externalizing the winrm plugin: once we have this as a separate plugin, can we depend on it, so that it always gets installed along with VMS if not present? Are inter-plugin dependencies in Vagrant a good idea or bad idea? |
I've made solid progress in creating the vagrant-winrm-syncedfolders plugin and should have a candidate release today. I agree with your summary above and was just about to ask the question to make sure that you were ok with making the syncedfolders plugin a dependency of vagrant-managed-servers. I found at least one example of inter-vagrant-plugin dependencies, so I believe that it should work without issue, since vagrant plugins are just gems. I think adding a dependency is the right way to go and I'll test it out to make sure it works. |
…vagrant-managed-servers into smb_synced_folders Conflicts: lib/vagrant-winrm-syncedfolders/lib/plugin.rb
I've pushed something that I think lines up with your summary above. Please review and let me know if there is anything else that you think I can do. Thanks so much for all of your help and feedback! One user that is using this for an internal project said that (the patched SMB support that I gave him) took the provisioning time on Windows from 20 minutes to 90 seconds. 👍 |
That is awesome 👍 👍 👍. 20 mins to 90 secs deserves a triple-thumbs-up at mininum! He should definitely buy you some 🍻 for that :-) Thanks for doing all the work and making vagrant a happier place for windows users! I will be giving it a quick test again and probably push out a new VMS release tomorrow. |
Thanks. Before that, I'll add some more info to the readme on the Windows On Thu, May 21, 2015 at 5:43 PM, Torben Knerr notifications@github.com
|
perfect 👍, will hold on for that |
Readme updated. |
Smb synced folders for Windows "guests"
Change default synced_folders behavior on Windows host/guest pair to use SMB file sharing, rather than the very slow uploading over WinRM.
I've tested this on a Win7 host and Windows Server 2008 managed host. You will be prompted for credentials if you don't include them in the Vagrantfile per the docs
FWIW, I'm planning on adding functionality to Vagrant Orchestrate that will prompt you once for credentials and pass them to winrm and SMB.
I assumed that this would be a big enough change to warrant a 0.7 release, but if that isn't the case, let me know and I can turn this into a 0.6.x change.
Meant to address #46
Happy to discuss if you have any feedback.