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

User-data script has erroneous newline breaking shebang, incompatible with Cloud-init versions on AL2023 #1167

Open
AdamMcAdamson opened this issue Jun 11, 2024 · 1 comment

Comments

@AdamMcAdamson
Copy link

Summary

The resulting user-data script from cluster up has an erroneous newline which results in an invalid user-data script being sent to the EC2 instance. Older versions of Cloud-init ignored the issue (19-?, seen in AL2), but newer versions (22.2.2, seen in AL2023) correctly parse shell-scripts, causing the provided script to fail.

Description

Bug is here:

joinClusterUserData := `
#!/bin/bash
echo ECS_CLUSTER=%s >> /etc/ecs/ecs.config
`

Golang's MIME multipart writer already inserts a newline, leaving the resulting script with an erroneous newline at the start of the file:
https://github.com/golang/go/blob/master/src/mime/multipart/writer.go#L120

Expected Behavior

/var/lib/cloud/instance/scripts/part-001:

#!/bin/bash
echo ECS_CLUSTER=cluster-name >> /etc/ecs/ecs.config
...

Observed Behavior

/var/lib/cloud/instance/scripts/part-001:


#!/bin/bash
echo ECS_CLUSTER=cluster-name >> /etc/ecs/ecs.config
...
@AdamMcAdamson
Copy link
Author

Fixed with #1168

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

1 participant