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

The file provisioner hangs in WindowsServer 2016 Datacenter image #5006

Closed
harryluo91 opened this issue Jun 12, 2017 · 9 comments
Closed

The file provisioner hangs in WindowsServer 2016 Datacenter image #5006

harryluo91 opened this issue Jun 12, 2017 · 9 comments

Comments

@harryluo91
Copy link

I am building an image using azure-arm with the WindowsServer 2016 Datacenter image from the market place. Everything runs well until packer tries to execute the file provisioner to copy over my application folders to the image. The same script works for a WindowsServer 2012 R2 image.

Debug Output:

2017/06/12 18:49:47 ui: ==> azure-arm: Uploading ./dist => C:\test
==> azure-arm: Uploading ./dist => C:\test
2017/06/12 18:49:47 packer: 2017/06/12 18:49:47 Uploading dir './dist' to 'C:\test\dist'
2017/06/12 18:49:49 packer: #< CLIXML
2017/06/12 18:49:52 packer: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>#< CLIXML
2017/06/12 18:49:55 packer: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>#< CLIXML
2017/06/12 18:50:01 packer: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>#< CLIXML
2017/06/12 18:50:12 packer: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>#< CLIXML
2017/06/12 18:50:16 packer: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>#< CLIXML
2017/06/12 18:50:36 packer: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>#< CLIXML

Script:

"builders": [{
    "type": "azure-arm",

    "client_id": "{{user `client_id`}}",
    "client_secret": "{{user `client_secret`}}",
    "resource_group_name": "{{user `resource_group_name`}}",
    "storage_account": "{{user `storage_account`}}",
    "subscription_id": "{{user `subscription_id`}}",
    "object_id": "{{user `object_id`}}",

    "capture_container_name": "images",
    "capture_name_prefix": "packer",

    "os_type": "Windows",
    "image_publisher": "MicrosoftWindowsServer",
    "image_offer": "WindowsServer",
    "image_sku": "2016-Datacenter",

    "communicator": "winrm",
    "winrm_use_ssl": "true",
    "winrm_insecure": "true",
    "winrm_timeout": "3m",
    "winrm_username": "packer",

    "location": "Canada East",
    "vm_size": "Standard_A2"
  }],
  "provisioners": [{
      "type": "windows-shell",
      "inline": ["cd C:\\", "mkdir test"]
  },
  {
      "type": "file",
      "destination": "C:\\test",
      "source": "./dist"
  },
  {
      "type": "powershell",
      "inline": [
        "if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
        "& $Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /shutdown /quiet"
      ]
    }]
}

Packer version: Packer v1.0.0
Host Platform: MacOSX Sierra
Debug Log: https://gist.github.com/harryluo91/2275bbd53ff9298842316e82de5ba875
Script executed: https://gist.github.com/harryluo91/e208d62f795d662f08816d9e0075bf0a

@mwhooker
Copy link
Contributor

Please add your entire debug log.

how long does it hang for? your debug log shows 45 seconds, which isn't long enough to consider this a bug. winrm can be abysmally slow.

@harryluo91
Copy link
Author

hi @mwhooker thanks for the response. Yeah I did not save the report for the original run, but it will just keep showing the same thing for over an hour. I can run it again today for half an hour if you want. Below is a more detailed report I got from this run, I can update it later today for the full run.

As you can see it hangs on Line 75 before I terminated the build:

2017/06/12 18:24:11 packer: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>#< CLIXML

In my previous run it will just keep doing this step over and over again.
Debug Log: https://gist.github.com/harryluo91/2275bbd53ff9298842316e82de5ba875

@harryluo91
Copy link
Author

Ok so I confirmed that this issues is caused by the file provisioner trying to upload an entire directory. Apparently it takes a long long time to upload a folder with many files, however the size of the folder is not so big, only 60MB. The script ran without problems if I zip that folder, but it still took about 15 mins to upload that 30MB zip file.

@mwhooker
Copy link
Contributor

yeah, winrm isn't very fast right now unfortunately. see #4806 for example.

sorry, there's not much we can do about that right now

@nebffa
Copy link

nebffa commented Sep 22, 2017

Hey @mwhooker, you're right that fixing this isn't really your problem. However, it would probably be a really good idea to add some documentation somewhere about this, and that it would be a good workaround to use http_directory in order to serve files instead.

@mwhooker
Copy link
Contributor

@nebffa I agree. I'll add that to the file provisioner docs

@mwhooker mwhooker added the docs label Sep 25, 2017
@mwhooker
Copy link
Contributor

done in 0608fe4

@nebffa
Copy link

nebffa commented Oct 12, 2017

Thanks @mwhooker - you're a legend.

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants