-
Notifications
You must be signed in to change notification settings - Fork 20
Description
In https://github.com/packer-community/packer-windows-plugins/blob/master/provisioner/powershell/provisioner.go, line 460, the generateElevatedRunner function uploads the script to create the scheduled task immediately.
However, it does so without any retry logic (e.g. the way non-elevated scripts are wrapped in p.retryable, line 277). This means that if an elevated script is being run after a reboot, there is a risk that it will attempt to upload before the winrm connectivity is available again and will fail. We can extend pause_before massively (for safety) but we have found mixed results with this, with intermittent failures. It would be nice if this upload step could be wrapped in p.retryable as well to give it a better chance of succeeding.
This is the first time I've looked at the provisioner.go source, so feel free to ignore if I've misunderstood how it's working :)
An example of the error we get:
--> amazon-windows-ebs: Error processing command: Error preparing elevated shell script:
Error uploading file to $env:TEMP\winrmfs-5639a93e-af78-be60-787c-4bf1fe44f7f0.tmp:
Couldn't create shell: unknown error
Post http://ec2-<ipaddress>.ap-southeast-2.compute.amazonaws.com:5985/wsman: dial tcp <ip address>:5985:
ConnectEx tcp: A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because connected host
has failed to respond.