diff --git a/docs/services/lambda-web-functions.md b/docs/services/lambda-web-functions.md index f02d0075cf..6ae6dd223f 100644 --- a/docs/services/lambda-web-functions.md +++ b/docs/services/lambda-web-functions.md @@ -71,7 +71,7 @@ The `Host` must match the domain exactly, as on AWS: another case or another por A CloudFront distribution of this Floci can use the endpoint as a custom origin, named by its `domainName` with or without its port. Under an `always-amz-auth` origin access control, CloudFront signs the requests to an `IamAuth` endpoint, and the function's resource policy has to allow `cloudfront.amazonaws.com` when IAM enforcement is on. Its `aws:RequestedRegion` is the region that serves the request, as on AWS. See [CloudFront](cloudfront.md). -An execution environment is a `public.ecr.aws/lambda/nodejs:24` container. The code is the revision's S3 object unpacked into `/var/task`. Node starts `/var/runtime/index.js` with the flags AWS uses, and that runtime imports `index.js` or the file `AWS_LAMBDA_NODEJS_ENTRYPOINT` names. So `require.main` is not the app's module, as on AWS. A `--max-old-space-size` or `--max-semi-space-size` in `NODE_OPTIONS` takes the place of both default heap flags, as on AWS. The container has 2519064576 bytes of memory, the total the process sees on AWS, so Node sizes the heap flag left out as on AWS. Other flags there do not replace a default flag, so `--max-http-header-size` in `NODE_OPTIONS` has no effect, and a flag Node does not allow in `NODE_OPTIONS` fails the start with `502 Runtime.ExitError`, as on AWS. The app sees `AWS_LAMBDA_HTTP_ENDPOINT=0.0.0.0:3000`, `AWS_LAMBDA_INITIALIZATION_TYPE=native-http`, `AWS_EXECUTION_ENV`, `AWS_LAMBDA_FUNCTION_MEMORY_SIZE=2048`, `AWS_LAMBDA_LOG_LEVEL`, `AWS_LAMBDA_METADATA_API`, `AWS_LAMBDA_METADATA_TOKEN`, `AWS_LAMBDA_RUNTIME_API`, `AWS_ACCOUNT_ID`, `AWS_REGION`, `AWS_DEFAULT_REGION`, credentials and `AWS_ENDPOINT_URL` for Floci, `NODE_PATH`, and its own variables. The server has 9 seconds to listen. An environment that sees no request for `floci.services.lambda.container-idle-timeout-seconds` is stopped with `SIGTERM` and one second, as on scale to zero. Node runs under Docker's init, so a server without a `SIGTERM` handler stops at once, as on AWS. A process that exits between requests is replaced by a fresh environment on the next request. +An execution environment is a `public.ecr.aws/lambda/nodejs:24` container for `nodejs24.x` and a `public.ecr.aws/lambda/nodejs:26` container for `nodejs26.x`. The code is the revision's S3 object unpacked into `/var/task`. Node starts `/var/runtime/index.js` with the flags AWS uses, and that runtime imports `index.js` or the file `AWS_LAMBDA_NODEJS_ENTRYPOINT` names. So `require.main` is not the app's module, as on AWS. A `--max-old-space-size` or `--max-semi-space-size` in `NODE_OPTIONS` takes the place of both default heap flags, as on AWS. The container has 2519064576 bytes of memory, the total the process sees on AWS, so Node sizes the heap flag left out as on AWS. Other flags there do not replace a default flag, so `--max-http-header-size` in `NODE_OPTIONS` has no effect, and a flag Node does not allow in `NODE_OPTIONS` fails the start with `502 Runtime.ExitError`, as on AWS. The app sees `AWS_LAMBDA_HTTP_ENDPOINT=0.0.0.0:3000`, `AWS_LAMBDA_INITIALIZATION_TYPE=native-http`, `AWS_EXECUTION_ENV`, `AWS_LAMBDA_FUNCTION_MEMORY_SIZE=2048`, `AWS_LAMBDA_LOG_LEVEL`, `AWS_LAMBDA_METADATA_API`, `AWS_LAMBDA_METADATA_TOKEN`, `AWS_LAMBDA_RUNTIME_API`, `AWS_ACCOUNT_ID`, `AWS_REGION`, `AWS_DEFAULT_REGION`, credentials and `AWS_ENDPOINT_URL` for Floci, `NODE_PATH`, and its own variables. The server has 9 seconds to listen. An environment that sees no request for `floci.services.lambda.container-idle-timeout-seconds` is stopped with `SIGTERM` and one second, as on scale to zero. Node runs under Docker's init, so a server without a `SIGTERM` handler stops at once, as on AWS. A process that exits between requests is replaced by a fresh environment on the next request. Requests with two revisions in `revisionWeights` are split by weight. Each endpoint scales on its own, as on AWS. An environment takes up to the revision's `maxConcurrencyPerEnvironment` requests at once, the least busy one first, so requests rotate over the environments. A request that finds every environment full starts another one, or waits for one that is starting and has room. When the endpoint already runs `maxEnvironments`, an idle environment of another revision makes room, and without one the request is refused with `429` and `Platform.EndpointMaxEnvThrottle`. A `rateLimit` admits a burst of up to `rateLimit` requests that refills at `rateLimit` per second, and refuses the rest with `429` and `Platform.EndpointRequestThrottle`. AWS adjusts the concurrency of each environment under `maxConcurrencyPerEnvironment` from the measured load, so a burst there can spread over more environments than in Floci, and the account quotas are not applied. diff --git a/src/main/java/io/floci/aws/services/lambda/launcher/ImageResolver.java b/src/main/java/io/floci/aws/services/lambda/launcher/ImageResolver.java index f6fed7ad1f..f2b0eaf39c 100644 --- a/src/main/java/io/floci/aws/services/lambda/launcher/ImageResolver.java +++ b/src/main/java/io/floci/aws/services/lambda/launcher/ImageResolver.java @@ -26,6 +26,7 @@ public class ImageResolver { Map.entry("python3.11", "python:3.11"), Map.entry("python3.10", "python:3.10"), Map.entry("python3.9", "python:3.9"), + Map.entry("nodejs26.x", "nodejs:26"), Map.entry("nodejs24.x", "nodejs:24"), Map.entry("nodejs22.x", "nodejs:22"), Map.entry("nodejs20.x", "nodejs:20"), diff --git a/src/main/java/io/floci/aws/services/lambdaweb/LambdaWebService.java b/src/main/java/io/floci/aws/services/lambdaweb/LambdaWebService.java index f734161aa8..95b28a75ff 100644 --- a/src/main/java/io/floci/aws/services/lambdaweb/LambdaWebService.java +++ b/src/main/java/io/floci/aws/services/lambdaweb/LambdaWebService.java @@ -73,7 +73,7 @@ public class LambdaWebService implements Resettable { private static final Logger LOG = Logger.getLogger(LambdaWebService.class); - static final String SUPPORTED_RUNTIME = "nodejs24.x"; + static final List SUPPORTED_RUNTIMES = List.of("nodejs24.x", "nodejs26.x"); static final int MAX_ENDPOINTS_PER_FUNCTION = 10; /** Reported as the quota. AWS deletes unused revisions past it instead of rejecting a create. */ static final int MAX_REVISIONS_PER_FUNCTION = 50; @@ -691,7 +691,7 @@ public class LambdaWebService implements Resettable { private WebFunctionRevision buildRevision(WebFunction fn, JsonNode request) { WebFunctionRevision revision = new WebFunctionRevision(); revision.buildConfig = buildConfigOf(LambdaWebJson.structure(request, "buildConfig")); - if (!SUPPORTED_RUNTIME.equals(revision.buildConfig.runtime)) { + if (!SUPPORTED_RUNTIMES.contains(revision.buildConfig.runtime)) { throw new AwsException("ValidationException", "The runtime " + revision.buildConfig.runtime + " is invalid.", 400); } diff --git a/src/test/java/io/floci/aws/services/lambda/launcher/ImageResolverTest.java b/src/test/java/io/floci/aws/services/lambda/launcher/ImageResolverTest.java index 58f4196da7..255eda8864 100644 --- a/src/test/java/io/floci/aws/services/lambda/launcher/ImageResolverTest.java +++ b/src/test/java/io/floci/aws/services/lambda/launcher/ImageResolverTest.java @@ -35,6 +35,7 @@ class ImageResolverTest { "python3.11, public.ecr.aws/lambda/python:3.11", "python3.10, public.ecr.aws/lambda/python:3.10", "python3.9, public.ecr.aws/lambda/python:3.9", + "nodejs26.x, public.ecr.aws/lambda/nodejs:26", "nodejs24.x, public.ecr.aws/lambda/nodejs:24", "nodejs22.x, public.ecr.aws/lambda/nodejs:22", "nodejs20.x, public.ecr.aws/lambda/nodejs:20", @@ -70,6 +71,7 @@ class ImageResolverTest { "python3.11, my.custom.host/lambda/python:3.11", "python3.10, my.custom.host/lambda/python:3.10", "python3.9, my.custom.host/lambda/python:3.9", + "nodejs26.x, my.custom.host/lambda/nodejs:26", "nodejs24.x, my.custom.host/lambda/nodejs:24", "nodejs22.x, my.custom.host/lambda/nodejs:22", "nodejs20.x, my.custom.host/lambda/nodejs:20", @@ -108,6 +110,7 @@ class ImageResolverTest { "python3.11, my.custom.host/path/lambda/python:3.11", "python3.10, my.custom.host/path/lambda/python:3.10", "python3.9, my.custom.host/path/lambda/python:3.9", + "nodejs26.x, my.custom.host/path/lambda/nodejs:26", "nodejs24.x, my.custom.host/path/lambda/nodejs:24", "nodejs22.x, my.custom.host/path/lambda/nodejs:22", "nodejs20.x, my.custom.host/path/lambda/nodejs:20", diff --git a/src/test/java/io/floci/aws/services/lambdaweb/LambdaWebServiceTest.java b/src/test/java/io/floci/aws/services/lambdaweb/LambdaWebServiceTest.java index 967de393a0..e82d75af79 100644 --- a/src/test/java/io/floci/aws/services/lambdaweb/LambdaWebServiceTest.java +++ b/src/test/java/io/floci/aws/services/lambdaweb/LambdaWebServiceTest.java @@ -318,6 +318,21 @@ class LambdaWebServiceTest { assertEquals(Map.of("BAR", "1"), revision.serviceConfig.environmentVariables); } + @Test + void revisionAcceptsNodejs26AndStillRejectsNodejs22() { + LambdaWebService service = service(); + service.createFunction(REGION, createRequest("app")); + ObjectNode node26 = revisionConfig(30); + ((ObjectNode) node26.path("buildConfig").path("runtimeConfig")).put("runtime", "nodejs26.x"); + assertEquals("nodejs26.x", service.createRevision(REGION, "app", node26).buildConfig.runtime); + + ObjectNode node22 = revisionConfig(30); + ((ObjectNode) node22.path("buildConfig").path("runtimeConfig")).put("runtime", "nodejs22.x"); + AwsException rejected = error(() -> service.createRevision(REGION, "app", node22)); + assertEquals("ValidationException", rejected.getErrorCode()); + assertEquals("The runtime nodejs22.x is invalid.", rejected.getMessage()); + } + @Test void requestRulesRunBeforeTheFunctionLookup() { LambdaWebService service = service();