Skip to content
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

WinRM file sync sometimes fails with a SEC_E_INVALID_TOKEN transiently #43

Closed
chrisbaldauf opened this issue Apr 29, 2015 · 1 comment
Closed

Comments

@chrisbaldauf
Copy link
Contributor

We randomly see the error below and often when we try the vagrant provision on a linked managed server again, it works just fine.

==> managed-win: Uploading with WinRM: d:/dev/vagrant-orchestrate/puppet/modules
 => /tmp/vagrant-puppet/modules-34e3fe2c92b739fa22c1db405d418a59
==> managed-win: Unlinking from managed server server1.domain.com
==> managed-win:  -- Server: server1.domain.com
==> managed-win: Removing hosts
An error occurred executing a remote WinRM command.

Shell: powershell
Command:           $dest_file_path = [System.IO.Path]::GetFullPath('/tmp/vagrant
-puppet/modules-34e3fe2c92b739fa22c1db405d418a59/stdlib/CHANGELOG.md')

          if (Test-Path $dest_file_path) {
            $crypto_provider = new-object -TypeName System.Security.Cryptography
.MD5CryptoServiceProvider
            try {
              $file = [System.IO.File]::Open($dest_file_path, [System.IO.Filemod
e]::Open, [System.IO.FileAccess]::Read)
              $guest_md5 = ([System.BitConverter]::ToString($crypto_provider.Com
puteHash($file))).Replace("-","").ToLower()
            }
            finally {
              $file.Dispose()
            }
            if ($guest_md5 -eq '362393816214b80a8a741e0e1662b928') {
              exit 0
            }
          }
          Write-Host "should upload file $dest_file_path"
          exit 1

if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1
 } }
Message: Error: SEC_E_INVALID_TOKEN

I'll propose that we simply add a retryable around the comm.upload https://github.com/tknerr/vagrant-managed-servers/blob/master/lib/vagrant-managed-servers/action/sync_folders.rb#L42

                # When syncing many files, we've see SEC_E_INVALID_TOKEN errors
                # that appear to be transient (try again and it goes away). Let's
                # retry a few times to add some robustness.
                retryable(tries: 3, sleep: 1) do
                  comm.upload(hostpath, guestpath)
                end

I'm working up a PR now.

@tknerr
Copy link
Owner

tknerr commented Apr 30, 2015

fixed via #45

@tknerr tknerr closed this as completed Apr 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants