Skip to content

Update ktor to 3.1.0 to support cross platform builds. #6

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

Merged
merged 1 commit into from
Feb 16, 2025

Conversation

zfz7
Copy link
Contributor

@zfz7 zfz7 commented Feb 14, 2025

This is an attempt to fix: #5

Testing ./gradlew build

➜  kotlin-native-aws-lambda-runtime git:(master) ./gradlew build
Type-safe project accessors is an incubating feature.
Project accessors enabled, but root project name not explicitly set for 'convention-plugins'. Checking out the project in different folders will impact the generated code and implicitly the buildscript classpath, breaking caching.
Project accessors enabled, but root project name not explicitly set for 'gradle-plugin'. Checking out the project in different folders will impact the generated code and implicitly the buildscript classpath, breaking caching.

BUILD SUCCESSFUL in 3m 33s
81 actionable tasks: 59 executed, 22 up-to-date

Testing ./gradlew buildLambdaRelease

➜  kotlin-native-aws-lambda-runtime git:(master) ./gradlew buildLambdaRelease
BUILD SUCCESSFUL in 8s
81 actionable tasks: 2 executed, 79 up-to-date
  adding: bootstrap (stored 0%)
  adding: sample.kexe (deflated 67%)
Lambda package created at /Users/daniel/workspace/kotlin-native-aws-lambda-runtime/sample/build/lambda/release/sample.zip. Provide the sample.kexe as a value of --handler argument while configuring the lambda function on AWS


BUILD SUCCESSFUL in 10s
16 actionable tasks: 3 executed, 13 up-to-date

Testing on Lambda

➜  kotlin-native-aws-lambda-runtime git:(master)  aws lambda create-function --function-name Kotlin-Native --handler sample.kexe --zip-file fileb:///Users/daniel/workspace/kotlin-native-aws-lambda-runtime/sample/build/lambda/release/sample.zip --runtime provided.al2 --architecture x86_64 --role arn:aws:iam::<AWS_ACCOUNT>:role/<ROLE_NAME> --tracing-config Mode=Active

➜  kotlin-native-aws-lambda-runtime git:(master) aws lambda invoke --cli-binary-format raw-in-base64-out --function-name Kotlin-Native --payload '{"command": "Say Hi!"}' output.json && cat output.json
{
                 "statusCode": 200,
                 "headers": {
                   "Content-Type": "application/json"
                 },
                 "isBase64Encoded": false,
                 "body": "Hello world"
             }%                 

@zfz7
Copy link
Contributor Author

zfz7 commented Feb 14, 2025

I will add that this change drops support for AL2023, but add support for arm64 on AL2.

Using AL2023 on x86 or arm64 I am getting:

Status: Failed
Test Event Name: (unsaved) test event

Response:
{
  "errorType": "Runtime.ExitError",
  "errorMessage": "RequestId: 3ed6808c-0875-4935-8f87-54dbe8d83986 Error: Runtime exited with error: exit status 127"
}

Function Logs:
INIT_REPORT Init Duration: 18.37 ms	Phase: init	Status: error	Error Type: Runtime.ExitError
./sample.kexe: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory
./sample.kexe: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory
INIT_REPORT Init Duration: 140.26 ms	Phase: invoke	Status: error	Error Type: Runtime.ExitError
START RequestId: 3ed6808c-0875-4935-8f87-54dbe8d83986 Version: $LATEST
RequestId: 3ed6808c-0875-4935-8f87-54dbe8d83986 Error: Runtime exited with error: exit status 127
Runtime.ExitError
END RequestId: 3ed6808c-0875-4935-8f87-54dbe8d83986
REPORT RequestId: 3ed6808c-0875-4935-8f87-54dbe8d83986	Duration: 191.93 ms	Billed Duration: 192 ms	Memory Size: 128 MB	Max Memory Used: 4 MB	
XRAY TraceId: 1-67aeef5a-6d02fe6a16d926fb5bd81a05	SegmentId: 3653b2b456415b1b	Sampled: true

Request ID: 3ed6808c-0875-4935-8f87-54dbe8d83986

Using AL2 and arm64 I get

Status: Succeeded
Test Event Name: (unsaved) test event

Response:
{
  "statusCode": 200,
  "headers": {
    "Content-Type": "application/json"
  },
  "isBase64Encoded": false,
  "body": "Hello world"
}

Function Logs:
[INFO] | Initializing Kotlin Native Lambda Runtime
[INFO] | Runtime is ready for a new event
START RequestId: 74e5b296-637e-40f0-b50a-8df3344d1fa5 Version: $LATEST
[INFO] | StringBodyLambdaHandler invocation started
[INFO] | StringBodyLambdaHandler invocation completed
[INFO] | Runtime is ready for a new event
END RequestId: 74e5b296-637e-40f0-b50a-8df3344d1fa5
REPORT RequestId: 74e5b296-637e-40f0-b50a-8df3344d1fa5	Duration: 120.43 ms	Billed Duration: 187 ms	Memory Size: 128 MB	Max Memory Used: 26 MB	Init Duration: 65.79 ms	
XRAY TraceId: 1-67aef038-4629bc5624c6b3536f5cabe0	SegmentId: 770821113b4604f6	Sampled: true

Request ID: 74e5b296-637e-40f0-b50a-8df3344d1fa5

@trueangle
Copy link
Owner

trueangle commented Feb 16, 2025

Using AL2023 on x86 or arm64 I am getting

The error happens for AL2023 because the image does not include libcrypt library by default, you'll have to include the library yourself as lambda layer. To get libcrypt quickly you can trigger this action then zip it and upload as a layer.

@trueangle trueangle merged commit b513d66 into trueangle:master Feb 16, 2025
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.

Project cannot not build linuxX64 target on M1 mac
2 participants