Skip to content

Conversation

Kavindu-Dodan
Copy link
Contributor

@Kavindu-Dodan Kavindu-Dodan commented May 7, 2025

What does this PR do?

Adds simple Make commands to package lambda zip locally. This is in addition to existing dev corner local testing guide [1]

To build lambda zip - make package
To clean it up - make clean

The zip is named local_esf.zip

Why is it important?

This allows developers to package lambda without the need of extra tools.

[1] - https://github.com/elastic/elastic-serverless-forwarder/tree/main/dev-corner/how-to-test-locally

Copy link

github-actions bot commented May 7, 2025

Minimum allowed coverage is 100%

Generated by 🐒 cobertura-action against c8b72aa

@Kavindu-Dodan Kavindu-Dodan force-pushed the chore/improve-build-exp branch from 922dc9f to b69ad53 Compare May 7, 2025 19:43
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
@Kavindu-Dodan Kavindu-Dodan force-pushed the chore/improve-build-exp branch from b69ad53 to 897879a Compare May 7, 2025 20:05
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
@Kavindu-Dodan Kavindu-Dodan force-pushed the chore/improve-build-exp branch from 74a9cd3 to 9ecdce9 Compare May 7, 2025 20:57
@@ -1,4 +1,4 @@
elastic-apm==6.19.0
elastic-apm==6.23.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zmoog I had to bump this dependency to get everything working end to end. I think this is due to python 3.12 bump

Copy link
Contributor

Choose a reason for hiding this comment

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

What kind of error did you get?

@kaiyan-sheng
Copy link
Contributor

Thanks for adding this! Do we need to also update the local testing guide to include this?

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
@Kavindu-Dodan
Copy link
Contributor Author

Thanks for adding this! Do we need to also update the local testing guide to include this?

I have updated our documentation with commit 5d8c56b :)

zmoog
zmoog previously approved these changes May 9, 2025
Copy link
Contributor

@zmoog zmoog left a comment

Choose a reason for hiding this comment

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

Thanks, this help building the .zip file on non linux/amd64 machines.

Once merged, the PR #886 will probably fix the CI failure.

@zmoog zmoog requested a review from Copilot May 9, 2025 14:57
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the local testing guide by adding Makefile commands that allow developers to package and clean the ESF Lambda zip locally.

  • Added Makefile instructions for building (make package) and cleaning (make clean) the Lambda zip.
  • Updated the README headings and text to clearly separate build and deployment steps.
Files not reviewed (1)
  • Makefile: Language not supported

kaiyan-sheng
kaiyan-sheng previously approved these changes May 9, 2025
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng left a comment

Choose a reason for hiding this comment

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

Thanks for updating the doc!

@Kavindu-Dodan Kavindu-Dodan dismissed stale reviews from kaiyan-sheng and zmoog via c8b72aa May 9, 2025 15:23
@Kavindu-Dodan Kavindu-Dodan enabled auto-merge (squash) May 9, 2025 15:24
@zmoog
Copy link
Contributor

zmoog commented May 9, 2025

@Kavindu-Dodan, here's a quick test run:

➜ make package
[....]

➜ unzip -l local_esf.zip | grep '.so$'     
   270976  05-05-2025 11:32   orjson/orjson.cpython-312-darwin.so
    86960  05-05-2025 11:32   wrapt/_wrappers.cpython-312-darwin.so
   115744  05-05-2025 11:32   charset_normalizer/md.cpython-312-darwin.so
   482040  05-05-2025 11:32   charset_normalizer/md__mypyc.cpython-312-darwin.so
   361928  05-05-2025 11:32   yaml/_yaml.cpython-312-darwin.so
   240064  05-05-2025 12:31   orjson/orjson.cpython-312-aarch64-linux-gnu.so
   188792  05-05-2025 12:31   wrapt/_wrappers.cpython-312-aarch64-linux-gnu.so
   321960  05-05-2025 12:31   charset_normalizer/md__mypyc.cpython-312-aarch64-linux-gnu.so
    69856  05-05-2025 12:31   charset_normalizer/md.cpython-312-aarch64-linux-gnu.so
  2402440  05-05-2025 12:31   yaml/_yaml.cpython-312-aarch64-linux-gnu.so
   244680  05-09-2025 17:28   orjson/orjson.cpython-312-x86_64-linux-gnu.so
   221464  05-09-2025 17:28   wrapt/_wrappers.cpython-312-x86_64-linux-gnu.so
    16120  05-09-2025 17:28   charset_normalizer/md.cpython-312-x86_64-linux-gnu.so
   280856  05-09-2025 17:28   charset_normalizer/md__mypyc.cpython-312-x86_64-linux-gnu.so
  2481784  05-09-2025 17:28   yaml/_yaml.cpython-312-x86_64-linux-gnu.so

And here's the latest .zip file from the release v.19.0:

➜ curl http://esf-dependencies.s3.amazonaws.com/lambda-v1.19.0.zip --output lambda-v1.19.0.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16.7M  100 16.7M    0     0  23.4M      0 --:--:-- --:--:-- --:--:-- 23.4M


➜ unzip -l lambda-v1.19.0.zip | grep '.so$'                                                   
  2371056  12-13-2024 11:41   yaml/_yaml.cpython-39-x86_64-linux-gnu.so
   189200  12-13-2024 11:41   wrapt/_wrappers.cpython-39-x86_64-linux-gnu.so
   277160  12-13-2024 11:41   charset_normalizer/md__mypyc.cpython-39-x86_64-linux-gnu.so
    16064  12-13-2024 11:41   charset_normalizer/md.cpython-39-x86_64-linux-gnu.so
   237872  12-13-2024 11:41   orjson/orjson.cpython-39-x86_64-linux-gnu.so
➜ du -sh local_esf.zip lambda-v1.19.0.zip
 20M    local_esf.zip
 17M    lambda-v1.19.0.zip

The updated local_esf.zip is larger because it includes more extensions targeting additional OS/arch.

We could target Linux only. I would keep x86_64 and aarch64 architectures because we'll probably add aarch64 deployment support in ESF.

@Kavindu-Dodan
Copy link
Contributor Author

Kavindu-Dodan commented May 9, 2025

@zmoog thanks for the detailed analysis. I used --platform as guided by AWS documentation [1] . Besides, given this is build for testing, do you think we need further fine tuning of the build ?

Also, I think when building on Mac, pip by default include darwin dependencies 🤔

[1] - https://docs.aws.amazon.com/lambda/latest/dg/python-package.html#python-package-native-libraries

Copy link
Contributor

@zmoog zmoog left a comment

Choose a reason for hiding this comment

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

LGTM

@Kavindu-Dodan Kavindu-Dodan merged commit 1aae716 into elastic:main May 9, 2025
6 checks passed
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 this pull request may close these issues.

3 participants