mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
14f99a512304160849e2c1922791bb36850f8708
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c90c5adfcb |
feat(lambda): code-signing endpoints and account settings (#2646)
* feat(lambda): GetAccountSettings with usage-derived account limits Adds the Lambda GetAccountSettings operation. AccountUsage (total code size and function count) is derived from the caller's stored $LATEST functions in the region; AccountLimit reports the configured regional concurrency limit and its unreserved share after per-function reserved concurrency. * fix(lambda): widen the default Runtime API port pool to 12000-12499 One Runtime API port is held for the lifetime of each running Lambda container, so the width of the range is a hard ceiling on concurrent Lambda executions. The old default of 9200-9299 gave 100, which a multi-account AWS Landing Zone Accelerator deployment exhausts: it fans out several custom-resource Lambdas per account and can want well over a hundred at once. Exhaustion did not announce itself as a capacity limit either. The custom resource reported FAILED and CloudFormation rolled the stack back, so an operator saw an apparently unrelated CloudFormation error with no hint that a port pool was the cause. 12000 rather than a widened 9200 because the old range's tail collides with ports floci and its sidecars already use: 9200 is OpenSearch's own REST port, 9400-9499 is the OpenSearch host-binding pool, 9092 is Kafka and 9644 Redpanda's admin port. Both application.yml and the @WithDefault annotation are updated. application.yml is a config source, not a set of defaults, so a value set there wins over the annotation; changing only the annotation would have been a silent no-op (issue #2225). The new test asserts the two agree, so they cannot drift apart again. Refs #2206 * fix(lambda): make the Runtime API port-pool exhaustion error self-describing The old message did not name the pool, its width, or the property that widens it. It also rarely reaches an operator directly: the Lambda failure surfaces as a custom resource reporting FAILED and CloudFormation rolling the stack back, so this text is buried in floci's own log alongside a CloudFormation error that looks unrelated. The message now carries its own diagnosis — which pool ran dry, how many ports it had, that one port is held per running container so this is the concurrent-execution ceiling, and the two properties that widen it. Previously the only way to learn those knobs existed was to find this class in the source. Refs #2206 * feat(lambda): add ListFunctionsByCodeSigningConfig Net-new endpoint, GET /2020-04-22/code-signing-configs/{arn}/functions, always returns an empty FunctionArns list since this codebase has no CodeSigningConfig management (no Create/PutFunctionCodeSigningConfig), so no function can ever actually have one attached. Implemented as its own controller class with its own class-level @Path("/2020-04-22") rather than folding it into the existing LambdaCodeSigningController (/2020-06-30): a JAX-RS class-level @Path is load-bearing for route-matching priority, and stripping it to share one class across two API-version prefixes causes both endpoints to fall through to a more general catch-all route elsewhere in the app. * fix(lambda): scope code storage, publish-version counters, and S3 sync-reload to the owning account CodeStore resolved extracted code to baseDir/<functionName> with no account segment, so two accounts' same-named functions in one region shared a single on-disk directory and overwrote each other's package -- while codeObjectKey already wrote the same package to an account-prefixed S3 key. Cross-account invoke resolves a function by the ARN's own account, so a collision here silently serves one account's code under the other's ARN. The PublishVersion counter was keyed region+"::"+functionName and the delete path removed that same unscoped key; both now key on the owning account, via the shared ownerAccount() helper the S3 key already used. onS3ObjectUpdated runs on the CDI event thread with no RequestContext, so its ambient scan only ever saw the default account's partition and its save wrote back into that partition. It now lists across every account (keeping the region and $LATEST filters) and saves into the function's own account. listAll(), whose only caller is the startup concurrency rehydration, is broadened the same way so a restart no longer drops non-default accounts' reserved concurrency. Recovered from 613db7bd1, re-derived onto upstream's current shape: CodeStore's methods are re-signed rather than overloaded (the unscoped forms had no remaining consumer), and the sync-reload uses a new region-filtered listAllAccounts() instead of widening listAll() at that call site. * fix(lambda): carry persisted version counters across the account-scoped key change The counter map is persisted precisely so a restart cannot re-issue a version number that already names a snapshot. Re-keying it on the owning account made every pre-existing entry unreachable, so the next PublishVersion on an upgraded deployment would have started again at 1 and overwritten the live :1 snapshot. The counter now adopts and clears the pre-account key on a miss, and deleting a function clears both forms. Also covers the widened listAll(): the reserved-concurrency pool is per region and shared across accounts, so the startup rehydration that feeds it has to see every account or a restart silently frees capacity that steady-state PutFunctionConcurrency had already accounted for. * fix(lambda): validate CodeSigningConfigArn on ListFunctionsByCodeSigningConfig The handler took @PathParam("codeSigningConfigArn") and never read it, so any input — including "not-an-arn" — got a 200 with an empty FunctionArns array. It also dropped the modeled Marker/MaxItems query parameters. Botocore models InvalidParameterValueException (400) and ResourceNotFoundException (404) for this operation, and carries a pattern on the CodeSigningConfigArn shape: arn:(aws[a-zA-Z-]*)?:lambda:[a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1} :\d{12}:code-signing-config:csc-[a-z0-9]{17} (max 200 chars). That pattern is now applied verbatim, whole-string. The 404 for a well-formed ARN is a derivation, not an observation against real AWS: ResourceNotFoundException is modeled for this operation, the only resource the path parameter can name is a code-signing config, and Floci implements no CreateCodeSigningConfig / PutFunctionCodeSigningConfig — therefore every well-formed ARN necessarily names a config that does not exist. The previous always-empty 200 asserted the opposite (config exists, has no functions), which is the stronger and false claim. Validation order matches AWS: ARN shape, then MaxItems range (botocore MaxListItems: min 1, max 10000), then resource resolution — so a bad MaxItems is reported as such instead of being masked by the not-found. Marker is accepted and stateless: the result set is always empty, so no NextMarker is ever emitted. The pre-existing test asserted the 200-empty behaviour using an ARN whose csc- suffix was 9 characters, which the model's pattern rejects; it is replaced by six cases covering the two error classes and both MaxItems bounds. docs/services/lambda.md's two "always empty" claims are corrected to match. * docs(lambda): derive the operation count from the routed operations The branch adds two operations (GetAccountSettings and ListFunctionsByCodeSigningConfig) but bumped docs/services/index.md by one, 30 -> 31. Rather than hand-correcting to 32, the count was re-derived from the routes, because 30 could not be reconstructed from anything in the tree. index.md's own preamble states the rule for REST services: "the count reflects distinct AWS SDK operations, collapsing routes where one JAX-RS handler fans out via query-string or header markers". Counting JAX-RS methods across the Lambda controllers on upstream/main gives: LambdaController 24 LambdaConcurrencyController 3 LambdaEventInvokeController 5 LambdaLayerController 5 LambdaTagController 3 LambdaUrlController 4 -- 44 Two collapses applied. LambdaCodeSigningController's /2020-06-30 route and LambdaController's /2015-03-31 route are the same SDK operation (GetFunctionCodeSigningConfig) and count once. LambdaUrlInvocationController (5) and the lambda-package ApiGatewayController (5) are data-plane proxies with {proxy: .*} catch-alls, not Lambda SDK operations, so they are excluded. 44 + GetAccountSettings + ListFunctionsByCodeSigningConfig = 46. Corroboration that 44 is the real base and 30 is drift: docs/services/lambda.md's Supported Operations table lists 34 rows on upstream/main and omits exactly the 5 layer and 5 event-invoke operations — 34 + 10 = 44. Those 10 missing table rows are pre-existing and left alone here; only the count is in scope. * fix(lambda): match the current CodeSigningConfigArn pattern for isolated partitions The inlined regex predated the model's (eusc-)? prefix and widened -iso(b?) alternation, so a well-formed ARN in aws-iso-e/iso-f or the European sovereign cloud was rejected as malformed instead of reaching the modeled 404. * fix(lambda): validate FunctionName length, Role ARN, and Handler on config paths botocore models FunctionName up to 256 chars with dots allowed in the name segment; LambdaArnUtils rejected dots and never bounded length. Also close the gap where UpdateFunctionConfiguration accepted a malformed Role ARN or a whitespace-containing/oversized Handler and stored it verbatim. * fix(lambda): close leaked directory-listing streams and block dot-segment traversal in CodeStore Files.walk/Files.list returned streams that were never closed, leaking file descriptors and making delete() flaky on platforms that refuse to remove an open file. Separately, sanitizeName replaced disallowed characters but let a segment consisting entirely of dots (".", "..") pass through untouched, so an account or function name of exactly ".." resolved outside baseDir via Path.resolve instead of being rejected. * fix(lambda): reclaim pre-account-scoped code directories on delete and update A function created before code storage was account-scoped left its extracted code at <codePath>/<functionName>. DeleteFunction only ever targeted the new <codePath>/<accountId>/<functionName> path, and UpdateFunctionCode re-extracted to the new path without touching the old one, so the legacy directory (and its disk usage) lingered indefinitely after either operation. CodeStore now also clears the legacy path on delete, and re-extraction reclaims it on success. * fix(lambda): reject an explicit null Handler on UpdateFunctionConfiguration validateHandler treated null as "clear the handler", matching how Description is handled, but null is not a string at all -- and unlike Description, Handler names the file AWS invokes. A request with "Handler": null silently cleared it instead of failing with a 400, which would have broken every subsequent invocation of the function instead of the one bad request that caused it. * fix(lambda): do not reclaim a legacy code directory another account's function still uses The pre-account-scoped layout gave every account's same-named function the exact same on-disk directory. CodeStore.delete() and code re-extraction both reclaimed that legacy directory unconditionally once a function migrated to the account-scoped path, so a delete or code update in one account could destroy the legacy directory while another account's never-migrated $LATEST still served invocations from it -- its next cold start would then fail with a missing code directory. CodeStore.delete() no longer touches the legacy path at all; only LambdaService calls deleteLegacy() explicitly, after checking every account's $LATEST functions (via the existing cross-account listAllAccounts) for one still pointing its codeLocalPath at that directory. * fix(lambda): check published versions, not just $LATEST, before reclaiming a legacy code directory publishVersion snapshots codeLocalPath verbatim (required so a version-qualified invoke doesn't launch a container with no code, #1987), so a version published while $LATEST was still on the pre-account-scoped legacy path keeps that directory alive on its own after $LATEST migrates. The unused-check only scanned $LATEST records via listAllAccounts(region), so a later delete or code update reclaimed the directory out from under that published version's own future invokes. Switched to functionStore.listAll(), which has no $LATEST or region filter, matching the fact that the legacy path itself carries neither. * fix(lambda): close a publish-vs-legacy-cleanup race on the code directory publishVersion read codeLocalPath and persisted a snapshot of it with no synchronization against extractZipCodeBytes's/deleteFunction's decision to reclaim the pre-account-scoped legacy code directory (added in |
||
|
|
824701481c |
feat(core): label emulated resource containers with io.floci.* identity (#2497)
* feat(core): add io.floci.* resource-identity labels Introduces ContainerStorageHelper.resourceIdentityLabels(service, resourceId, accountId, region), so a container manager can tag its spawned container with the emulated resource's identity. Additive to the existing floci/floci_emulator/floci_namespace labels. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(rds): label RDS containers with resource identity RDS backing containers now carry io.floci.service=rds, io.floci.resource-id=<instanceId>, io.floci.account, and io.floci.region so a spawned container can be mapped back to the DBInstanceIdentifier it emulates without empirical docker exec probing. Account/region reuse the same ARN parsing already done for log-stream routing; extracted into resolveRuntimeIdentity so both call sites share one source of truth. Closes #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(docdb): label DocDB containers with resource identity DocDB backing containers now carry io.floci.service=docdb and io.floci.resource-id=<clusterId> alongside account/region. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(elasticache): label ElastiCache Redis/Valkey containers with resource identity Backing containers now carry io.floci.service=elasticache and io.floci.resource-id=<groupId> alongside account/region. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(elasticache): label ElastiCache Memcached containers with resource identity Backing containers now carry io.floci.service=elasticache and io.floci.resource-id=<clusterId> alongside account/region. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(memorydb): label MemoryDB containers with resource identity Backing containers now carry io.floci.service=memorydb and io.floci.resource-id=<clusterName> alongside account/region. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(neptune): label Neptune containers with resource identity Backing containers now carry io.floci.service=neptune and io.floci.resource-id=<clusterId> alongside account/region. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(msk): label MSK containers with resource identity Redpanda backing containers now carry io.floci.service=msk and io.floci.resource-id=<clusterName> alongside account/region. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(opensearch): label OpenSearch containers with resource identity Backing containers now carry io.floci.service=opensearch and io.floci.resource-id=<domainName> alongside account/region. RegionResolver is now injected into OpenSearchDomainManager. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(ecs): label ECS task containers with resource identity Backing containers now carry io.floci.service=ecs and io.floci.resource-id=<taskId> alongside account/region. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(eks): label EKS k3s containers with resource identity Backing containers now carry io.floci.service=eks and io.floci.resource-id=<clusterName> alongside account/region. RegionResolver is now injected into EksClusterManager. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(amazonmq): label AmazonMQ containers with resource identity RabbitMQ backing containers now carry io.floci.service=amazonmq and io.floci.resource-id=<brokerId> alongside account/region. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(mwaa): label MWAA containers with resource identity Both the Postgres metadata container and the Airflow container now carry io.floci.service=mwaa and io.floci.resource-id=<environmentName> alongside account/region. RegionResolver is now injected into MwaaEnvironmentManager. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(kinesisanalytics): label Flink containers with resource identity Both the JobManager and TaskManager containers now carry io.floci.service=kinesisanalytics and io.floci.resource-id=<applicationName> alongside account/region. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(batch): label Batch job containers with resource identity Job containers now carry io.floci.service=batch and io.floci.resource-id=<jobId>, using the job's own account/region (already carried on BatchJob) rather than RegionResolver. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(codebuild): label CodeBuild job containers with resource identity Build containers now carry io.floci.service=codebuild and io.floci.resource-id=<buildId> alongside account/region. No new unit test: the container-spawn call site lives inside the private multi-phase runBuild() method, entangled with real filesystem and source-download side effects with no existing seam for unit testing in isolation (CodeBuild's only coverage today is the QuarkusTest-based CodeBuildIntegrationTest, which would need a real Docker daemon and a full build run to assert container labels). Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(lambda): label function containers with resource identity Lambda containers now carry io.floci.service=lambda and io.floci.resource-id=<functionName>, reusing the existing ARN-based region resolution and adding the equivalent account lookup. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(ec2): label EC2 instance containers with resource identity Backing containers now carry io.floci.service=ec2 and io.floci.resource-id=<instanceId>, using the already-passed region parameter and a new RegionResolver dependency for the account id. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * feat(ecr): label the shared registry container with resource identity The registry:2 container carries io.floci.service=ecr with no resource-id, since it is a shared singleton, not a per-resource container. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * docs(core): document io.floci.* resource-identity labels Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * style(tests): use imports instead of inline FQCN in resource-identity label tests Cleans up the Batch, EKS, and OpenSearch label tests added earlier in this branch, which used fully-qualified names inline instead of imports. Relates to #1818 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * fix(kinesisanalytics): restore Mockito import and awsEnv param in Flink label test Silently dropped by the rebase's clean auto-merge; the test no longer compiled without them. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * docs(core): note ECR keeps every identity label except resource-id EcrRegistryManager still passes account/region for the shared registry container; only resourceId is omitted. Docs previously said the opposite. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * test(elasticache): log swallowed IOException in label test cleanup Matches the pattern already used in the DocDB/Neptune/MemoryDB label tests. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> --------- Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> |
||
|
|
f8b07a78ff | feat(lambda): add the ability to name and label lambda containers, code volumes (#2409) | ||
|
|
c48c062117 |
fix(docker): fall back to Windows named pipe when docker-host is at its unix-socket default (#2030)
Floci defaults docker-host to unix:///var/run/docker.sock, which has no equivalent on native Windows. Since this hardcoded default always overrides docker-java's own OS-aware detection, every Docker-backed operation failed at container-start time on Windows with a low-level socket error — including Lambda-invoked CloudFormation custom resources such as CDK's Custom::S3BucketNotifications. When docker-host is still unmodified and DOCKER_HOST isn't set, fall back to Docker Desktop's named pipe (npipe:////./pipe/docker_engine) on Windows, mirroring what docker-java already does correctly on its own. Linux/macOS behavior is unchanged. An explicit docker-host or DOCKER_HOST always takes priority over the fallback. Verified end-to-end: a CDK-shaped stack (S3 bucket + Lambda + Custom::S3BucketNotifications) went from CREATE_FAILED to CREATE_COMPLETE after this fix. Fixes #2006. |
||
|
|
a6c6cf6de9 |
fix(floci-ui): report real sidecar-start failures instead of always blaming the image (#1544)
Pressing 'Open Floci UI' under Podman (docker-socket compat) reports every failure as a missing image and tells the user to 'docker pull floci-ui' — even when the image is present. The real causes (an unreachable Docker/Podman socket, a port clash, a daemon error) are hidden, which is especially confusing on SELinux hosts where the bind-mounted socket connect fails with 'java.net.BindException: Permission denied'. Classify the failure in FlociUiManager.describeStartFailure: - only a genuinely unavailable image (NotFoundException / docker-java's 'Could not pull image: ...' wrapper) keeps the 'docker pull' guidance; - an unreachable runtime (SocketException/BindException/ConnectException) points at the socket mount and SELinux relabeling; - any other daemon error is surfaced as-is (e.g. 'address already in use'). Also fix the Podman docs: use ':z' (shared relabel) rather than ':Z' on the shared Podman API socket, note it applies to the UI sidecar, and mention the '--security-opt label=disable' fallback. Add unit tests for the four classifications. |
||
|
|
3b4e73ca5a |
docs(lambda): document Podman rootless support and Runtime API host override (#1340)
Adds a 'Running on Podman (rootless)' section to the Docker configuration docs with the known-working container config, and documents the existing FLOCI_SERVICES_LAMBDA_DOCKER_HOST_OVERRIDE escape hatch for when Runtime API host auto-detection picks an unreachable address. Closes #876 |
||
|
|
ded329beac |
fix Lambda container networking when Floci runs in Docker (#765)
Automatically detect the Docker network of the running Floci container and use it for spawned containers when no explicit Docker network is configured. This lets Lambda containers reach Floci’s Runtime API in Docker Compose setups without requiring users to manually set FLOCI_SERVICES_LAMBDA_DOCKER_NETWORK. Also update Lambda/Docker docs to clarify the automatic network inheritance behavior. Tested with: ./mvnw -q -Dtest=ContainerBuilderTest,CurrentContainerNetworkResolverTest,DockerHostResolverTest,ContainerLauncherTest test |
||
|
|
4f0150870a | feat(docker): centralize Docker config and add private registry authentication (#549) |