Skip to content

cannot execute binary file #1

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

Closed
zerkowsm opened this issue Apr 29, 2022 · 8 comments · Fixed by #2
Closed

cannot execute binary file #1

zerkowsm opened this issue Apr 29, 2022 · 8 comments · Fixed by #2

Comments

@zerkowsm
Copy link

Hello there!

This is really good stuff!

I have an issue while trying it - apparently missing some setup... I have just tried it and getting {"message": "Internal server error"} as an outcome from executing ./provision-infrastructure.sh with detailed CloudWatch error as below:
/var/task/bootstrap: line 4: /var/task/jre18-slim/bin/java: cannot execute binary file

Running ./provision-infrastructure.sh on macOS, if that matters.

Can you please advice what do I miss here?

@maschnetwork
Copy link
Contributor

Hi @zerkowsm,

thanks for reaching out.

Unfortunately I can't reproduce the error - I just retried with a fresh version of the repo and it is working as expected on macOS. Can you confirm that the build.sh worked and check the resulting runtime.zip file if the file permissions are correctly set? Do you see any additional information in the logs (e.g. an error code)?

@zerkowsm
Copy link
Author

zerkowsm commented May 2, 2022

Hello @maschnetwork

Thanks for the update!
Yeah, this is quite strange.
Build worked fine, runtime.zip created, permissions set:

-rwxr-xr-x   1 staff      217 May  2 09:35 bootstrap
-rw-r--r--   1 staff  8977881 May  2 11:58 function.jar
drwxr-xr-x   7 staff      224 May  2 11:58 jre18-slim

But still getting the same error which is followed by:
Error: Runtime exited with error: exit status 126

But, I run it on a different machine and it worked (?!). The only difference I can see is the chip M1 (the one I struggle) vs i7 (working fine) is that is something that can affect the provisioning in any way (build is done in a container anyway)?

@zerkowsm
Copy link
Author

zerkowsm commented May 3, 2022

Hello again,

It is not provisioning, it's build. Dockerfile yum depends on the underlining architecture and on aarch64, installed package is: java-18-amazon-corretto-devel.aarch64 1:18.0.1.10-1 (vs java-18-amazon-corretto-devel.x86_64 1:18.0.1.10-1).

@maschnetwork
Copy link
Contributor

maschnetwork commented May 3, 2022

Hi @zerkowsm,

thanks a lot for reproducing the issue.
Can you please try to change the first line of the Dockerfile to:

FROM --platform=linux/amd64 amazonlinux:2

and let me know if that works on the M1?

Best,
Max

@zerkowsm
Copy link
Author

zerkowsm commented May 4, 2022

Np, sure!

It helped, builds ends with the warning confirming what happened:
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
but it works.

Thanks for the hint here!

BTW: I was wondering if some other tweaks would also help here - to match the platform --platform=linux/arm64/v8 with the function config: AWS::Serverless::Function.Properties.Architectures set to arm64, would that be something worth considering as well?

I was also thinking about extracting jre18-slim together with the bootstrap as a Function Layer - layer.zip:

  • dist
    • bin
    • conf
    • legal
    • lib
      release
  • bootstrap

dist is just the jre18-slim but I have some doubts what to put in bootstrap file. I assume I would need to find substitute for path prefix used in current setup (runtime.zip having everything together) - $LAMBDA_TASK_ROOT/. I think the dist is being put in /opt/dist folder... - can you give a hint here?

@maschnetwork
Copy link
Contributor

I'm glad we could resolve the issue - I'll fix the Dockerfile to support it out of the box.

Yes you can definitely do that and also use the arm architecture, but I would not make that automatically dependend on the platform you are building because you might still want to deploy it to another architecture.

For having a custom runtime on a layer you can find an example here: https://github.com/msailes/lambda-java17-layer

@maschnetwork
Copy link
Contributor

Added the platform to the Dockerfile. Closing the issue now. Thanks for reporting and reproducing!

@zerkowsm
Copy link
Author

zerkowsm commented May 9, 2022

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants