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

fix: Better support parallel execution by allowing wget to skip files… #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion infra/terraform/modules/_lambda/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource "null_resource" "download" {
}

provisioner "local-exec" {
command = "test -f ${local.package_directory}/${local.package_filename} || (mkdir -p ${local.package_directory} && wget -P ${local.package_directory} ${var.package_url})"
command = "test -f ${local.package_directory}/${local.package_filename} || (mkdir -p ${local.package_directory} && wget --no-clobber -P ${local.package_directory} ${var.package_url})"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can now remove the call to test -f

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but wouldn't it then download the file unnecessarily if it already existed? But yes, the parallel execution is a real edge case and most of the time it will be running in CI where the file won't exist so I think it is safe to remove and satisfies any concerns that older version will hang around

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --no-clobber would prevent the file being unnecessarily downloaded

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh, yes you are right. I was thinking for some reason that it just prevented wget failing if it already existed, which is what I was originally looking to achieve.

Copy link

@apgrucza apgrucza Nov 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand why the problem was consistently reproducible, because the test -f should usually prevent wget from downloading the file if it already exists. I would have thought it's pretty unlikely for one thread to start downloading the file while another thread is in-between the test -f and wget commands. Using --no-clobber would presumably prevent the problem completely though (depending on how it's implemented in wget).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If TF runs this step in parallel the tests would all run and return false and then wget would run and the first one to download wins and the rest fail. If wget downloads to a temporary file the test won't pick it up until it is has completed (after enough time for all the tests to run). If wget creates the file immediately then yes, it does seem an unlikely coincidence. Would need to see the full TF output to better gauge the order things run in

}
}

Expand Down