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

copilot_build_aws wait loop script POSIX portability #49

Open
doubletwist13 opened this issue Oct 11, 2023 · 0 comments
Open

copilot_build_aws wait loop script POSIX portability #49

doubletwist13 opened this issue Oct 11, 2023 · 0 comments

Comments

@doubletwist13
Copy link

The wait loop script passed into the local-exec provider uses some non-POSIX methods. The provider is ignoring the #!/bin/bash line in the command and is just falling back to the default shell in the environment, which for Debian/Ubuntu is dash, which doesn't support ((count++)) or [[.

This causes the loop to never timeout and finish if the curl command never succeeds.

See:

#!/bin/bash
echo "Waiting for Copilot..."
count=0
until [ "$(curl -ks https://${try(aws_eip.copilot_eip[0].public_ip, "")}/api/info/updateStatus | jq -r '.status')" = "finished" ]
do
sleep 10
((count++))
if [[ $count -eq 60 ]]; then
break
fi
done
echo "Copilot is online."
EOF

The script should be POSIX compliant.

You can do this using:
count=$((count+1)) in line 181
and using a single bracket for the if statement:
if [ $count -eq 60 ]; then in line 182

I'm working on a PR to fix this.

PS. I also wonder if you're aware that (at least in my testing) each attempt at the curl command takes 2 minutes before it times out. As such, each loop takes a total of 130 seconds to complete (120sec curl timeout + 10 second sleep). So that check for 60 loops means it won't timeout for over 2 hours. Is that intentional? You can reduce that by setting a shorter timeout for the curl command, or reducing the number of loops you wait before giving up.

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