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

Symlinks are flattened in the layers because of a SAM bug #146

Closed
bubba-h57 opened this issue Jan 9, 2019 · 11 comments
Closed

Symlinks are flattened in the layers because of a SAM bug #146

bubba-h57 opened this issue Jan 9, 2019 · 11 comments
Assignees
Labels
Milestone

Comments

@bubba-h57
Copy link
Contributor

Here is a link to the open issue over at aws/aws-sam-cli#878

The bottom line is that sam invoke local fails to unpackage symlinks properly, which means you can not test anything locally that relies on a layer (or function for that matter) that has symlinks.

This is only an issue for local invokation. Everything unpackages properly in the cloud. However, it is a major aggrevation for anyone who is expecting to test/debug localy with SAM.

@mnapoli mnapoli added the bug label Jan 9, 2019
@mnapoli mnapoli added this to the 0.3 milestone Jan 9, 2019
@mnapoli
Copy link
Member

mnapoli commented Jan 9, 2019

If I recall correctly this is a problem in the new runtime because of the symlinks right? (#132)

On aws/aws-sam-cli#878 they say that files are copied instead of symlinked. Don't the binary still work after being copied? Or maybe they don't work because they cannot load related libraries?

Can you confirm that sam local and the new runtimes are incompatible until they fix the issue in SAM?

@bubba-h57
Copy link
Contributor Author

Confirmed that the new runtim is incompatible with sam local. We have also confirmed that everything works as expected in the cloud.

Technical Details
The unzip they are using flattens the symlink effectively making it nothing more than a text file. This effects us in two ways.

  1. The /opt/bin/* symlinks that should point to /opt/bref/bin/* are flat text files, not binaries nor scripts.
  2. The shared libraries we are building against use symlinks extensively to track versions of the shared object. LIke so:
lrwxrwxrwx 1 sbx_user1051  495      16 Jan  8 17:15 libcurl.so -> libcurl.so.4.5.0
lrwxrwxrwx 1 sbx_user1051  495      16 Jan  8 17:15 libcurl.so.4 -> libcurl.so.4.5.0
-rwx------ 1 sbx_user1051  495  572239 Jan  8 17:15 libcurl.so.4.5.0
lrwxrwxrwx 1 sbx_user1051  495      19 Jan  8 17:17 libsodium.so -> libsodium.so.23.1.0
lrwxrwxrwx 1 sbx_user1051  495      19 Jan  8 17:17 libsodium.so.23 -> libsodium.so.23.1.0
-rwx------ 1 sbx_user1051  495 2457307 Jan  8 17:17 libsodium.so.23.1.0

However, the actualy results on sam local look like:

-rwx------ 1 sbx_user1051  495      16 Jan  8 17:15 libcurl.so
-rwx------ 1 sbx_user1051  495      16 Jan  8 17:15 libcurl.so.4
-rwx------ 1 sbx_user1051  495  572239 Jan  8 17:15 libcurl.so.4.5.0
-rwx------ 1 sbx_user1051  495      19 Jan  8 17:17 libsodium.so
-rwx------ 1 sbx_user1051  495      19 Jan  8 17:17 libsodium.so.23
-rwx------ 1 sbx_user1051  495 2457307 Jan  8 17:17 libsodium.so.23.1.0

Most code is going to link against the base library like libcurl.so or against that major version of the library libcurl.so.4 which are symlinked against a full version like libcurl.so.4.5.0. So when PHP attemts to link to the libcurl.so it finds a text file instead and everything falls over.

@mnapoli
Copy link
Member

mnapoli commented Jan 9, 2019

That will be a big problem unfortunately 🤔

Do you think there is any way we can avoid using symlinks in the (new) runtime you are working on? At least for the first versions of the runtime while we wait for the issue in SAM to be resolved.

(by the way slightly related aws/aws-sam-cli#477 we don't seem to be affected by this given what you said above, but I'm sharing the link just in case)

@bubba-h57
Copy link
Contributor Author

I have the new runtime working with sam invoke local for now. We basically make copies of everything and duplicate (or triplicate) the space used. But I am able to keep it under 100M on disk.

Longterm, that bug will be debilitating is we stick with AWS SAM. Symlinks are our best weapon against bloat in the layer.

FWIW, I do not believe I had the same problems with Serverless.

@mnapoli mnapoli removed this from the 0.3 milestone Jan 19, 2019
@mnapoli mnapoli changed the title Symlink Bug in sam invoke local Symlinks are flattened in the layers because of a SAM bug Jan 19, 2019
@nealio82
Copy link
Contributor

@mnapoli @bubba-h57 can this be closed? (related to / fixed by aws/aws-sam-cli#1140..? / no longer relevant as we're back on serverless...)

@bubba-h57
Copy link
Contributor Author

I do not see any reason to leave it open.

@mnapoli
Copy link
Member

mnapoli commented Jul 30, 2019

Should we remove hard copies now and keep the symlinks? That should make layers much lighter right?

@bubba-h57
Copy link
Contributor Author

@mnapoli Abso-stinking-lutely!!!!!

@mnapoli
Copy link
Member

mnapoli commented Jul 30, 2019

Cool!

@mnapoli
Copy link
Member

mnapoli commented Nov 23, 2019

I have opened #509 to try to address this.

@mnapoli mnapoli added this to the 2.0 milestone Oct 25, 2022
@mnapoli mnapoli added this to Bref 2.0 Oct 25, 2022
@mnapoli mnapoli moved this to Todo in Bref 2.0 Oct 25, 2022
@mnapoli
Copy link
Member

mnapoli commented Dec 1, 2022

Closing this issue, this is no longer an issue in Bref v2.

@mnapoli mnapoli closed this as completed Dec 1, 2022
Repository owner moved this from Todo to Done in Bref 2.0 Dec 1, 2022
@mnapoli mnapoli self-assigned this Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants