terraform-aws-modules / terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
885 stars 658 forks source link

fix: Dont raise FileNotFoundError from close() on tmpfile rename #550

Closed jjinno closed 3 months ago

jjinno commented 3 months ago

Description

Allow FileNotFoundError to be ignored on close() to compensate for file already being renamed

Motivation and Context

There appear to be some conditions by which the self._tmp_filename file has already been renamed/moved to self.filename prior to (or racing with) the calling of close().

In this case FileNotFoundError will be thrown, causing the Terraform to fail. But without changing anything, a subsequent run of the Terraform will succeed because the ZIP file already exists. (aka: it was created correctly on the first pass)

Breaking Changes

How Has This Been Tested?

edrjnjdeuh73 commented 3 months ago

Thx. Ad astra!

antonbabenko commented 3 months ago

This PR is included in version 7.2.4 :tada:

lociko commented 3 months ago

It looks like something wrong:

if not os.exists(self._tmp_filename):
            return

It will raise an exception!!! The correct version is: os.path.exists

lociko commented 3 months ago

Fixed in this PR: https://github.com/terraform-aws-modules/terraform-aws-lambda/pull/554/files

pdecat commented 3 months ago

I'm going to add python lint checks to CI to catch this sort of mistakes.

github-actions[bot] commented 2 months ago

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.