Skip to content

Commit 8243b6e

Browse files
committed
use runtime client 2.5.1
1 parent a1428b9 commit 8243b6e

File tree

3 files changed

+44
-24
lines changed

3 files changed

+44
-24
lines changed

lambda-exec-wrapper.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,32 @@
4343
# https://github.com/sigpwned/the-lambda-iceberg-dissecting-the-official-java-runtimes
4444

4545
# Dump our env
46-
env
46+
echo "ENVIRONMENT:"
47+
env
48+
echo
49+
50+
# List our runtime libs
51+
echo "RUNTIME LIBS:"
52+
ls -l /var/runtime/lib
53+
echo
54+
55+
# Get our runtime version
56+
echo "RUNTIME VERSION:"
57+
cat /var/runtime/runtime-release
58+
echo
59+
60+
# Detect key library versions
61+
pushd /var/runtime/lib
62+
AWS_LAMBDA_JAVA_CORE_JAR=`ls aws-lambda-java-core-*.jar`
63+
AWS_LAMBDA_JAVA_RUNTIME_INTERFACE_CLIENT_JAR=`ls aws-lambda-java-runtime-interface-client-*.jar`
64+
AWS_LAMBDA_JAVA_SERIALIZATION_JAR=`ls aws-lambda-java-serialization-*.jar`
65+
popd
4766

4867
# Unpack our tmpdump, if we have one
49-
# Remember, /opt/humangraphics is where this custom layer ("humangraphics")
68+
# Remember, /opt/humangraphics is where this custom layer ("humangraphics") will
5069
# be unpacked.
5170
pushd /tmp
52-
/var/lang/bin/java -classpath /var/runtime/lib/aws-lambda-java-core-1.2.3.jar:/var/runtime/lib/aws-lambda-java-runtime-interface-client-2.5.1-linux-x86_64.jar:/var/runtime/lib/aws-lambda-java-serialization-1.1.5.jar:/opt/humangraphics io.humangraphics.backend.lambda.TmpDump "s3://$HUMANGRAPHICS_BUCKET/tmpdump/$AWS_LAMBDA_FUNCTION_NAME.zip"
71+
/var/lang/bin/java -classpath /var/runtime/lib/$AWS_LAMBDA_JAVA_CORE_JAR:/var/runtime/lib/$AWS_LAMBDA_JAVA_RUNTIME_INTERFACE_CLIENT_JAR:/var/runtime/lib/$AWS_LAMBDA_JAVA_SERIALIZATION_JAR.jar:/opt/humangraphics io.humangraphics.backend.lambda.TmpDump "s3://$HUMANGRAPHICS_BUCKET/tmpdump/$AWS_LAMBDA_FUNCTION_NAME.zip"
5372
popd
5473

5574
# Grab our args

pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@
3838
<relocations>
3939
<relocation>
4040
<pattern>org.apache.commons.compress</pattern>
41-
<shadedPattern>io.humangraphics.backend.lambda.thirdparty.org.apache.commons.compress</shadedPattern>
41+
<shadedPattern>
42+
io.humangraphics.backend.lambda.thirdparty.org.apache.commons.compress</shadedPattern>
4243
</relocation>
4344
<relocation>
4445
<pattern>com.sigpwned.aws.sdk.lite</pattern>
45-
<shadedPattern>io.humangraphics.backend.lambda.thirdparty.com.sigpwned.aws.sdk.lite</shadedPattern>
46+
<shadedPattern>
47+
io.humangraphics.backend.lambda.thirdparty.com.sigpwned.aws.sdk.lite</shadedPattern>
4648
</relocation>
4749
</relocations>
4850
<filters>

src/main/java/io/humangraphics/backend/lambda/thirdparty/com/amazonaws/services/lambda/runtime/api/client/AWSLambda.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
import com.amazonaws.services.lambda.runtime.api.client.logging.LambdaContextLogger;
2828
import com.amazonaws.services.lambda.runtime.api.client.logging.LogSink;
2929
import com.amazonaws.services.lambda.runtime.api.client.logging.StdOutLogSink;
30-
import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.LambdaError;
3130
import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.LambdaRuntimeApiClient;
3231
import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.LambdaRuntimeApiClientImpl;
33-
import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.RapidErrorType;
3432
import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.converters.LambdaErrorConverter;
3533
import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.converters.XRayErrorCauseConverter;
3634
import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto.InvocationRequest;
35+
import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto.LambdaError;
36+
import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto.XRayErrorCause;
3737
import com.amazonaws.services.lambda.runtime.api.client.util.LambdaOutputStream;
3838
import com.amazonaws.services.lambda.runtime.api.client.util.UnsafeUtil;
3939
import com.amazonaws.services.lambda.runtime.logging.LogFormat;
@@ -54,8 +54,6 @@
5454
*/
5555
public class AWSLambda {
5656

57-
protected static ClassLoader customerClassLoader;
58-
5957
private static final String TRUST_STORE_PROPERTY = "javax.net.ssl.trustStore";
6058

6159
private static final String JAVA_SECURITY_PROPERTIES = "java.security.properties";
@@ -77,6 +75,8 @@ public class AWSLambda {
7775
private static final String AWS_LAMBDA_INITIALIZATION_TYPE =
7876
System.getenv(ReservedRuntimeEnvironmentVariables.AWS_LAMBDA_INITIALIZATION_TYPE);
7977

78+
protected static ClassLoader customerClassLoader;
79+
8080
private static LambdaRuntimeApiClient runtimeClient;
8181

8282
static {
@@ -215,10 +215,10 @@ private static void startRuntime(String handler, LambdaContextLogger lambdaLogge
215215

216216
runtimeClient = new LambdaRuntimeApiClientImpl(LambdaEnvironment.RUNTIME_API);
217217

218-
String taskRoot = System.getProperty("user.dir");
219-
String libRoot = "/opt/java";
220218
// Make system classloader the customer classloader's parent to ensure any aws-lambda-java-core
221219
// classes are loaded from the system classloader.
220+
// String taskRoot = System.getProperty("user.dir");
221+
// String libRoot = "/opt/java";
222222
//
223223
// customerClassLoader =
224224
// new CustomerClassLoader(taskRoot, libRoot, ClassLoader.getSystemClassLoader());
@@ -236,8 +236,7 @@ private static void startRuntime(String handler, LambdaContextLogger lambdaLogge
236236
} catch (UserFault userFault) {
237237
lambdaLogger.log(userFault.reportableError(),
238238
lambdaLogger.getLogFormat() == LogFormat.JSON ? LogLevel.ERROR : LogLevel.UNDEFINED);
239-
LambdaError error = new LambdaError(LambdaErrorConverter.fromUserFault(userFault),
240-
RapidErrorType.BadFunctionCode);
239+
LambdaError error = LambdaErrorConverter.fromUserFault(userFault);
241240
runtimeClient.reportInitError(error);
242241
System.exit(1);
243242
return;
@@ -259,23 +258,23 @@ private static void startRuntime(String handler, LambdaContextLogger lambdaLogge
259258
try {
260259
payload = requestHandler.call(request);
261260
runtimeClient.reportInvocationSuccess(request.getId(), payload.toByteArray());
262-
// clear interrupted flag in case if it was set by user's code
263-
boolean ignored = Thread.interrupted();
261+
boolean ignored = Thread.interrupted(); // clear interrupted flag in case if it was set by
262+
// user's code
264263
} catch (UserFault f) {
265264
shouldExit = f.fatal;
266265
userFault = f;
267266
UserFault.filterStackTrace(f);
268-
LambdaError error =
269-
new LambdaError(LambdaErrorConverter.fromUserFault(f), RapidErrorType.BadFunctionCode);
267+
268+
LambdaError error = LambdaErrorConverter.fromUserFault(f);
270269
runtimeClient.reportInvocationError(request.getId(), error);
271270
} catch (Throwable t) {
272271
shouldExit = t instanceof VirtualMachineError || t instanceof IOError;
273272
UserFault.filterStackTrace(t);
274273
userFault = UserFault.makeUserFault(t);
275274

276-
LambdaError error = new LambdaError(LambdaErrorConverter.fromThrowable(t),
277-
XRayErrorCauseConverter.fromThrowable(t), RapidErrorType.UserException);
278-
runtimeClient.reportInvocationError(request.getId(), error);
275+
LambdaError error = LambdaErrorConverter.fromThrowable(t);
276+
XRayErrorCause xRayErrorCause = XRayErrorCauseConverter.fromThrowable(t);
277+
runtimeClient.reportInvocationError(request.getId(), error, xRayErrorCause);
279278
} finally {
280279
if (userFault != null) {
281280
lambdaLogger.log(userFault.reportableError(),
@@ -291,16 +290,16 @@ static void onInitComplete(final LambdaContextLogger lambdaLogger) throws IOExce
291290
runtimeClient.restoreNext();
292291
} catch (Exception e1) {
293292
logExceptionCloudWatch(lambdaLogger, e1);
294-
runtimeClient.reportInitError(new LambdaError(LambdaErrorConverter.fromThrowable(e1),
295-
RapidErrorType.BeforeCheckpointError));
293+
LambdaError error = LambdaErrorConverter.fromThrowable(e1);
294+
runtimeClient.reportInitError(error);
296295
System.exit(64);
297296
}
298297
try {
299298
Core.getGlobalContext().afterRestore(null);
300299
} catch (Exception restoreExc) {
301300
logExceptionCloudWatch(lambdaLogger, restoreExc);
302-
runtimeClient.reportRestoreError(new LambdaError(
303-
LambdaErrorConverter.fromThrowable(restoreExc), RapidErrorType.AfterRestoreError));
301+
LambdaError error = LambdaErrorConverter.fromThrowable(restoreExc);
302+
runtimeClient.reportRestoreError(error);
304303
System.exit(64);
305304
}
306305
}

0 commit comments

Comments
 (0)