-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Golang binary provided as a zip file does not work with v0.3.0 #389
Comments
You should chmod and give your binary executable permissions |
I'm also getting this on a Go project. My reproducible branch is at nzoschke/gofaas#62 |
Turns out, this is a regression from previous version because Python's ZipFile module does not retain file permissions on unzipping - https://bugs.python.org/issue15795. Several folks have fixed it in different ways (ex: https://www.burgundywall.com/post/preserving-file-perms-with-python-zipfile-module). We need to implement a clean solution to this problem. We will prioritize this and get a release out asap |
We did some digging in on the awsdevelopers Slack. With some sleep and debug statements I see that the tmp dir doesn't have any executable bits on the main file:
@sanathkr found this, which points to Python zip library:
|
This problems is specifically only when you bundle the Golang binary as a zipfile and provide to CodeUri. As a workaround, you can set CodeUri to be a path to a folder that contains your binary. This will work. In fact this will be faster because SAM CLI does not have to unzip every time you run the invoke. If you have something like:
Instead, convert it to something like:
Where the |
I can confirm that this is an issue on Linux for a Python project (the issue is not limited to Golang on MacOS).
I just tested this, and it worked properly. Thanks! |
Thanks all! |
Reopening. The root cause of this is not fixed. |
Fixes #389 Zip archive format includes a `external_attr` property on each file that stores file permissions. Most zip programs store permissions as in a format that unix's `chmod` command will accept. I cross-verified this approach with a couple of other libraries: * [Setuptools](https://github.com/pypa/setuptools/blob/89ef5bb7e4812193d6f593d531bad36191517981/setuptools/archive_util.py#L122-L124) * [Golang source](https://github.com/golang/go/blob/161874da2ab6d5372043a1f3938a81a19d1165ad/src/archive/zip/struct.go#L273) Unit tests create a zip archive with different permissions to verify that it does in fact unzip with permissions. This includes integration tests that invoke a function with zip of code for Java & Golang. We can run these automated tests on various platforms (Mac, Linux, Windows) to ensure unzipping works consistently.
* implementation of incremental build strategy * update with hashing utility * - update application_builder - update build_graph with new manifest_md5 param - add & update unit tests * update supported runtimes * address PR comments * update cleanup functions and move them to the wrapper class * update to use dependency hash generator * update to use dependency hash generator * add log messages and don't update source_md5 if it is not present
Description:
After upgrading to 0.3.0 I am now getting the following error while using
sam local start-api
I have tried rebuilding my functions using
but that doesn't seem to be fixing the issue.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Mac/OSX
Output of
sam --version
:SAM CLI, version 0.3.0
Optional Debug logs:
The text was updated successfully, but these errors were encountered: