-
-
Notifications
You must be signed in to change notification settings - Fork 351
Description
Describe the bug
On Windows workers, user-data does not run, because the module uses base64gzip and Windows does not accept gzip only zip.
To Reproduce
- Setup a runner using the example
examples/runner-windows - Enable SSM Access by setting
runner_worker.ssm_accesstotrue - Set the variable
runner_worker_docker_autoscaler_instance.start_scriptto:<powershell> New-Item -ItemType Directory -Force -Path "C:\test-dir-to-prove-script-ran" </powershell>
- Run a CI Job on that runner (something that takes some time)
- While that runs, access the instance that gets created via SSM
- Check the directory "C:\test-dir-to-prove-script-ran" -> it is not created.
- Check the EC2 Launch Log file
C:\ProgramData\Amazon\EC2Launch\log\agent.log
It ends with:Warning: No XML or YAML user-data detected. If XML or YAML user-data is intended, check for typos or refer to documentation (https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch-v2-settings.html#ec2launch-v2-example-user-data):
%!w(*fmt.wrapError=&{Failed to unmarshal user-data as YAML: yaml: control characters are not allowed 0xc00010f610})
Additional context
I tracked it down to the fact that the module uses gzip to compress the user-data, and Windows cannot handle gzip compressed user-data.
According to the AWS Docs EC2Launch supports zip.
See docker_autoscaler.tf line 13: the variable runner_worker_docker_autoscaler_instance.start_script is passed to the function base64gzip which is the culprit.
I performed a second test with some click-ops:
- Took the user-data and zipped them with 7-zip (standard Zip deflate)
- Then base64 encoded that zip file (
cat userdata.zip | base64 > userdata.zip.b64) - Set the resulting content as user-data in the launch template
- Changed the Auto Scaling Group to use the new version of the launch template
- Triggered a CI job
- -> The user-data ran.