mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
fc1488d17a8df0340f91ba366a8faf01ec1224ef
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
301ac79c6e |
feat(lambdaweb): write the platform events of Web Function environments (#5936)
* feat(lambdaweb): write the platform events of Web Function environments Each environment now writes the platform.* events AWS writes, filtered by the revision's systemLogLevel. CPU time and memory come from the container's cgroup. The output of an environment that fails before it listens reaches its stream too. Node runs under Docker's init, so a server without a SIGTERM handler stops at once, as on AWS where it is not PID 1. The server has 9 seconds to listen, as the AWS TimeoutListenError message says. * fix(lambdaweb): settle the platform events of an environment that ends early The last reports wait for the requests the exit failed, so they are counted. A periodic summary comes no more after the last report. An exit right after the app listens is handled as an exit. The CPU time counts on a host without memory.peak. The listen failure event is dropped at applicationLogLevel FATAL, as on AWS. |
||
|
|
8067ecf1de |
feat(lambdaweb): send what a Web Function writes to its log groups as AWS does (#5919)
* feat(lambdaweb): send what a Web Function writes to its log groups as AWS does * chore(lambdaweb): write the Web Function runtime as an ES module * fix(lambdaweb): create a log group or stream only when an event finds it missing * fix(lambdaweb): cut a log line by its UTF-8 size after replacing bytes that are not UTF-8 * test(lambdaweb): wait for the last log line instead of a fixed sleep |
||
|
|
5eb4eecf99 |
feat(lambdaweb): enforce IamAuth on Web Function endpoints (#5855)
* fix(lambdaweb): accept role and user ARNs as resource policy principals AWS checks an ARN principal against a pattern that allows a slash, so a role or user ARN passes. Any other AWS principal value is still checked against the pattern without a slash. * feat(lambdaweb): verify SigV4 and InvokeWebFunctionEndpoint on IamAuth endpoints An IamAuth endpoint takes a request signed for the service lambda in the endpoint's region, in the Authorization header or a presigned query. The X-Amz-Content-SHA256 header is required and is the payload hash, as on AWS. A refused request gets the AWS 403 page with no error type. The check runs after the rateLimit 0 page and before the rate limit. Under IAM enforcement the signer also needs lambda:InvokeWebFunctionEndpoint on the endpoint ARN from its identity policy or the function's resource policy, with the auth type and the function tags as condition keys. An Authorization that is an AWS signature is dropped before the app on every endpoint, together with X-Amz-Security-Token. * fix(lambdaweb): give the app the path without dot segments and sign only the normalized path Lambda removes dot segments before the app sees the path, on every endpoint, and keeps repeated slashes and encoded dots. An IamAuth signature counts only over the path as signers normalize it. A signature over the path as sent is refused when the two differ. Floci forwarded the path as sent and took a signature over either form, so a request signed for /a/c could reach the app as /a/./b/../c. * fix(lambdaweb): answer 502 when the caller check fails inside Floci A malformed date or query is still a refused signature. Any other failure, such as in IAM storage, no longer looks like a 403. The endpoint answers it with 502 and no error type, as AWS answers its own failures. * fix(lambdaweb): check a principal against the ARN pattern only under AWS Lambda allows a path only in an ARN under the AWS key. A CanonicalUser or Federated value never matches that pattern. * docs(lambdaweb): MultiRegion SigV4, presigned queries and dot segments on the way to the app * chore(auth): share SigV4 signature parsing and age limits with API Gateway The API Gateway authorizer and Lambda Web IamAuth read a SigV4 signature from the Authorization header or a presigned query, and check its age, in the same way. Both now use one record in core.common.auth. Each still decides which placement wins and where it reads the session token, so neither behaves differently. |
||
|
|
c8de16ffc7 |
fix(lambdaweb): never run a request twice when the app crashes (#5842)
* fix(lambdaweb): retry a failed request only when Floci saw the exit before sending it A request that found its environment dead was retried when Docker's exit time came before the request start. Docker takes that time from the daemon's clock, which can be seconds behind Floci's. So a request the app had received could run a second time. Docker also reports an exit late under load. Until then the dead environment stayed in the pool, and the next request got a 503 too. Floci now follows each environment with an attach stream. The stream ends when the process exits, and Floci notes the time on its own clock. A failed request waits for that, up to one second. It is retried only if the exit came before it was sent. Otherwise it gets the 503 page after the dead environment has left the pool. * docs(lambdaweb): note the short window after an exit in the 503 row * fix(lambdaweb): clean up an exited environment off the reaper thread Docker can take seconds to report an exit status under load. On the reaper this held up the rearm of dropped exit watches and the idle checks. * test(lambdaweb): wait for Floci to see the exit instead of polling for the container |
||
|
|
832f1008bb |
feat(lambdaweb): scale environments per endpoint and apply maxEnvironments and rateLimit (#5785)
* feat(lambdaweb): scale environments per endpoint and apply maxEnvironments and rateLimit Each endpoint keeps its own pool of environments, as on AWS. An environment takes up to the revision's maxConcurrencyPerEnvironment requests at once, the least busy one first so requests rotate, and a request that finds every environment full starts another or waits for one that is starting. At maxEnvironments the request gets the 429 page with Platform.EndpointMaxEnvThrottle. A rateLimit admits a burst of up to rateLimit requests refilled at rateLimit per second and refuses the rest with Platform.EndpointRequestThrottle. Both pages were recorded against AWS. Part of #5699 * fix(lambdaweb): key environment pools by endpoint creation and let a new revision take an idle slot A recreated endpoint gets a new domain, so it no longer reuses the environments of the deleted one. At maxEnvironments an idle environment of another revision is stopped to make room. Empty pools are dropped. The burst in the Docker test now arrives at once, so a slow runner still goes past the rate. * fix(lambdaweb): keep the rate limiter clock monotonic and drop refilled buckets A bucket untouched for a second is full, so it is dropped. A clock read that lands behind the bucket no longer takes tokens back. |
||
|
|
6e01216f88 |
feat(lambdaweb): serve endpoint domains from a Node.js environment per revision (#5760)
* feat(lambdaweb): serve endpoint domains from a Node.js environment per revision A request whose Host is an endpoint's domainName goes over HTTP/1.1 to a container that Floci starts from the revision's S3 code on the first request: public.ecr.aws/lambda/nodejs:24 with the code in /var/task, index.js or AWS_LAMBDA_NODEJS_ENTRYPOINT as the entry file, the node flags and the environment variables AWS sets, ten seconds to listen, SIGTERM and one second when idle, and a fresh environment after the process exits between requests. The forwarded request carries the headers AWS adds and loses the ones AWS drops. The response carries lambda-web-request-id and lambda-web-logstream and streams as the app writes it. Two revisions in revisionWeights split the traffic by weight. The platform pages for an unsupported method, an unknown domain, HTTP/1.0, a server that does not listen, a timeout, a crash and a disabled endpoint are the AWS pages. Part of #5699 * fix(lambdaweb): index endpoint domains and claim only the minted host shapes A request looked its domain up by scanning every stored function across accounts and iterating live endpoint maps outside the function lock. The service now keeps a domain index, filled from storage at start and kept by the create and delete paths, and copies the function under its lock. The data plane claims only hosts shaped like the domains Floci mints, in any case and with any port, so a dotted S3 bucket with a lambda-web label still reaches S3. * fix(lambdaweb): reserve environments against the idle reaper and track exits acquire now reserves the environment under the same lock the idle reaper takes, so a request cannot start on a container the reaper is about to stop. Docker faults in the reaper and in discard are contained so one error does not end the periodic run or skip the removal. The exit watcher records the exit time and arms itself again when its stream drops, and a request that found a dead process is replayed only when that recorded exit came first, never because the container is gone. The unpacked code directory is removed on every path. The container gets the execution role's session credentials when the role exists, and the function account's credentials otherwise, as the Lambda launcher does. * fix(lambdaweb): bound the whole exchange by timeoutSeconds and forward chunked bodies timeoutSeconds is a deadline on the whole request, as recorded against AWS: a response that has not started by then is the 504 page, one that is still streaming is cut, and a slow upload gets its 504 once the body is in, since the edge takes the body before it answers. A body without a Content-Length is sent chunked instead of carrying the client's Transfer-Encoding header. A failure of the upload stream ends the exchange and releases the environment once. * test(compat): probe the unknown Lambda Web domain in the shape Floci mints The data plane claims only hosts shaped like the domains it mints, so the unknown-domain check needs a 16 character id to reach it. |
||
|
|
0492fc9842 |
feat(lambdaweb): CloudFormation types for Lambda Web Functions (#5722)
* feat(lambdaweb): CloudFormation types for Lambda Web Functions AWS::Lambda::WebFunction, AWS::Lambda::WebFunctionRevision and AWS::Lambda::WebFunctionEndpoint provision through the resource registry. Ref of each is its ARN. Every property of a revision is createOnly in the registry schema, so a changed revision mints a new one and the displaced revision is deleted once the update commits. An endpoint keeps its identity while its function, name, type and regions stay the same. Fn::GetAtt on RegionalEndpoints is recorded as a gap. Part of #5699 * fix(lambdaweb): compare a revision against the function's default log group revisionMatches filled a request without a log group with the existing revision's log group, so a template that dropped a custom log group kept the old revision. The default is the function's log group, as when a revision is created. replaceTags returns the updated function. * fix(cloudformation): put a Lambda Web function or endpoint back after a failed stack update A function's tags and an endpoint's mutable configuration are changed in place on update. The provisioner now snapshots them before the change and restores them from rollbackUpdate, as the other in-place provisioners do. The function attributes after a tag update come from the updated function, so UpdatedAt moves with the tag change. * test(cloudformation): roll a Lambda Web stack update back after a failed revision A revision that fails to create after the endpoint moved to a replaced revision rolls the stack back. The endpoint returns to the kept revision and the replacement is deleted. The doc page says that a CloudFormation endpoint is always Disabled with RevisionWeights, since the schema has no AutoDeploymentMode, and that a failed update puts in-place changes back. * fix(cloudformation): refuse AutoDeploymentMode on a Lambda Web endpoint The registry schema has no AutoDeploymentMode property and AWS fails a template that sets it at validation. An endpoint from CloudFormation is always Disabled and routes by RevisionWeights. Floci passed the property through to the service, which accepted LatestRevision. * refactor(lambdaweb): share the create and tag steps between the API and CloudFormation paths createFunction and createFunctionShell both check the name and refuse a duplicate under the function's lock. tagResource and replaceTags both check the tags, lock, write, stamp and persist. Each pair now calls one private helper, so the two paths cannot drift. |
||
|
|
6f78083080 |
feat(lambdaweb): Lambda Web Functions control plane (#5706)
* feat(lambdaweb): Lambda Web Functions control plane The lambda-web service model (apiVersion 2025-03-07) signs as lambda, so it is served under the lambda service at /2025-03-07/... with the AWS wire shapes, state words and error wording of the 20 operations on web functions, revisions, endpoints, tags and the resource policy. Revisions and endpoints converge at once. They are stored Active and an endpoint update is stored Successful, while the create and update responses report the transitional state AWS reports, so a CLI waiter settles on its first poll. Code comes from an S3 object that must exist. IamAuth, the resource policy and the endpoint domain are stored but not served yet. Part of #5699 * fix(lambdaweb): carry the page position in the token The nextToken of a list operation was a UUID keyed into an in-memory anchor map that only grew and was not scoped to the account. The token is now a core Pagination cursor that encodes the request (operation, region, account, function, filters and page size) and the cursor of the item the page ended on. A token reused with other parameters gets the AWS "does not match the request" error and any other token the AWS "invalid or has expired" error. AWS issues UUID tokens and rejects any other shape, so Floci no longer reproduces the pattern error for a malformed token. * fix(iam): resolve a Lambda Web revision or endpoint named by its ARN The route resource for IAM enforcement took the path segment after revisions or endpoints as the id. A revision or endpoint ARN in that position carries slashes, so the resource ARN ended in the ARN's first segment and a policy scoped to the revision or endpoint did not apply. The id is now the last segment of such an ARN. * fix(lambdaweb): add the values of a repeated state filter AWS lists a function when any state filter in the request names its state. A later state filter replaced the earlier one, so a request with state=Active followed by state=Failed listed nothing. * fix(lambdaweb): refuse empty arrays in a resource policy AWS answers an empty Action or Resource array with the policy syntax error and an empty principal array with the invalid principal error, which wins when all three are empty. Floci stored such a policy. * fix(lambdaweb): judge a wildcard principal by the operator and value of its condition A trusted condition key alone kept an Allow for every principal out of the public check. AWS blocks the policy unless a positive operator pins the key: StringNotEquals and the IfExists forms do not count, nor does a wildcard in an account value or in the account field of an ARN value, while a wildcard elsewhere in an ARN and a literal * under StringEquals do. |