Commit Graph
24 Commits
Author SHA1 Message Date
Hector Ventura 01f64e8a5c fix(docker): let the compat image reach the Docker socket on native Linux (#7378)
USER 1001 made the image start unprivileged, so the entrypoint skipped the branch that adds the socket's group and honours FLOCI_RUN_AS_ROOT. With a socket owned by a non-root group and mode 660, Docker-backed services could not launch containers, and FLOCI_RUN_AS_ROOT=true had no effect.

The image now starts as root like the standard one, and the entrypoint drops to uid 1001. HOME is set to /app because that drop keeps the environment: hooks would otherwise run with HOME=/root, which uid 1001 cannot write to, and pip install would fail.

docker exec now defaults to root on this image, as it does on the standard one.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
2026-11-03 21:23:35 -04:00
soreavis bb6f46c104 fix(docker): recommend label=disable, not :z, when SELinux blocks the Podman socket (#7434)
The Podman docs and the web console's start-failure message told SELinux users to relabel the socket mount with :z. On a rootless podman machine (SELinux enforcing) that recipe fails: the web console cannot start and a Lambda invoke returns "Docker is not reachable (Permission denied)". :z fixes access to the socket file, but SELinux also denies connectto from the Floci container (container_t) to the Podman service (container_runtime_t), which a relabel can't fix; --security-opt label=disable avoids it. With it, the same recipe starts the console and invokes a Python Lambda.
2026-11-03 14:17:49 -04:00
Priamo Germosen b66ee9ecf0 feat(core): make the image pull timeout configurable (#6521)
ImageCacheService gave each attempt at pulling an image a hard-coded
five minutes, and a pull three attempts. An EMR Serverless runtime is
3.5 to 4.3 GB, so on an ordinary connection the first run of a release
Docker did not have yet failed with "Could not pull image" before the
pull could finish.

floci.docker.image-pull-timeout-seconds, or
FLOCI_DOCKER_IMAGE_PULL_TIMEOUT_SECONDS, now sets the limit for each
attempt. Its default, 300, keeps today's five minutes, and it must be
at least 1, checked with the other Docker timeouts in
DockerClientProducer.

Follow-up to #6469.
2026-10-25 14:08:34 -05:00
Aniket Shukla 5787dac5e8 fix(kinesisanalytics): retry Flink configuration uploads (#6020)
Rebuild archive streams for transient daemon failures using the shared tar copier. Preserve required and optional copy handling, and cover consumed streams, retry exhaustion and startup order without sleeping in tests.
2026-10-19 17:48:45 -04:00
Aniket Shukla 2b45288e13 fix(sagemaker): retry model and training archive uploads (#5999)
* fix(sagemaker): retry model and training archive uploads

* test(sagemaker): avoid production backoff in retry tests
2026-10-19 11:23:43 -04:00
Aniket Shukla 241806a4f3 fix(codeartifact): retry Verdaccio configuration uploads (#5982) 2026-10-19 09:16:14 -04:00
Aniket Shukla d951fd532c fix(docker): retry core and EKS archive uploads (#5916)
* fix(docker): retry core and EKS archive uploads

* fix(docker): fail fast on local host archive errors

* test(docker): skip backoff in archive retry regressions

Allow package-private caller entry points to select the archive backoff while production retains the shared defaults. Remove the unused user-data tar builder requested in review.

* test(resourceexplorer2): isolate empty-query count assertions

The shared integration fixture can contain exactly 1000 resources, where a capped total does not imply incomplete results. Search a tracked single-resource view and cover 999, 1000 and 1001 matches with deterministic service tests.
2026-10-18 11:53:50 -04:00
Hector Ventura 98100054a8 feat(core): make the Docker call timeout configurable (#5431)
* feat(core): make the Docker call timeout configurable

Ordinary Docker calls failed after a hard-coded five minutes without a
response. floci.docker.api-timeout-seconds (FLOCI_DOCKER_API_TIMEOUT_SECONDS)
now sets it for both pools, defaulting to 300 so nothing changes by
default; a shorter value bounds how long a hung daemon can hold a request.
Like the connection request timeout, it must be at least 1, because
httpclient5 reads 0 as no limit. Long-lived streams (container waits, exec
and attach output, followed logs, streamed stats, events, image pulls and
builds) stay exempt.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* docs(core): say the Docker call timeout applies to each attempt

The control-plane pool retries a request that is safe to repeat up to six
times, and a response timeout is one of the failures it retries. The docs,
the config Javadoc and the application.yml comment said the setting bounds
a request; it bounds each attempt, so a silent daemon can hold a replayable
request for about six times the limit, plus backoff.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

---------

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
2026-10-11 00:17:11 -04:00
Hector Ventura ddc47a465d fix(core): make Docker read timeouts real on a Unix-socket host, except for long-lived streams (#5294)
* fix(core): make Docker read timeouts real on a Unix-socket host, except for long-lived streams

docker-java's UnixSocket reads through a blocking channel stream that
ignores SO_TIMEOUT, so on the default unix:// Docker host no call ever
timed out: a 2-second response timeout let a container wait run 153
seconds, and a hung daemon blocked its caller forever. It is also why
httpclient5's stale-connection check, a read with a 1 ms timeout, cannot be
enabled there.

FlociDockerHttpClient now connects to a unix:// host through
UnixDomainSocket, which keeps the channel non-blocking and waits on a
selector, so a read with a timeout fails with SocketTimeoutException. Making
the timeout real would cut off streams that are silent while healthy, so
requests that hold a stream open (container wait, exec and attach output,
followed logs, streamed stats, events, image pulls and builds) get no
response timeout on any host, which also keeps a TCP host's container wait
from dying at five minutes. Every other call keeps the 5-minute timeout.

* fix(core): keep the Unix socket's failures IOExceptions on close and interrupt

Closing the socket while another thread waited in a read or write could
end that wait with the selector's unchecked ClosedSelectorException,
since close() may shut the selector between select() and
selectedKeys(); callers expecting an IOException did not handle it. It
is now a SocketException. A thread reading a silent stream with no
timeout spun once interrupted, because select() returns at once while
the interrupt flag is set; it now closes the socket and throws
ClosedByInterruptException, as the blocking channel it replaced did.

The tests wait with a timed get that expects a TimeoutException rather
than a fixed sleep, so an early return fails at once, and cover a close
during a blocked read and an interrupted read.
2026-10-08 07:27:04 -04:00
Hector Ventura 985921c3db fix(core): fail a Docker call after 30 seconds when its connection pool is full (#5285)
* fix(core): fail a Docker call after 30 seconds when its connection pool is full

With no connection-request timeout set, a call that could not lease a
pooled connection waited httpclient5's default three minutes before failing.
A full pool means the emulator is saturated, so the wait is now configurable
through floci.docker.connection-request-timeout-seconds (default 30), applied
to both pools. The transport retry already treats a lease timeout as pool
exhaustion and never replays it, so the call fails once, after the timeout.

* fix(core): reject a Docker lease timeout below one second

httpclient5 reads a zero connection-request timeout as no timeout, so
floci.docker.connection-request-timeout-seconds=0 let a call on a full
pool wait forever, and a negative value reached the client unchecked.
It now has to be at least 1, checked the way the two pool sizes are,
through one helper that names the setting and its environment variable.

The two producer tests that build the beans from a mocked config now
stub the timeout; they ran with zero before. The lease test's socket
list is shared with the acceptor thread, so it is a concurrent list.
2026-10-07 20:59:11 -04:00
Sam Fakhreddine 1531537559 fix(docker): retry transient daemon I/O at the transport seam and split streaming pools (#4614)
Under fan-out load the single Docker socket drops connections mid-call
(Broken pipe, Connection reset) and the operation fails. Split out of #2707.

- Retry transient I/O at the transport: RetryingDockerHttpClient retries
  replay-safe control-plane calls with capped backoff (policy in
  DockerRetry). Interrupted I/O is not retried, except
  SocketTimeoutException, and the interrupt flag is kept.
- Split log-follow streams onto their own @StreamingDocker client and pool
  (floci.docker.streaming-max-connections, default 512) so they cannot
  starve create/start/stop calls. Exec and wait streams stay on the main
  pool for now.
- Adopt the container a replayed named create already made (409 matched by
  a per-attempt label) instead of failing and leaking it. Unnamed container
  creates, network creates, restart and network connect/disconnect are
  never replayed.
- Retry tar copies at the call site with RetryingTarCopier (Lambda
  launcher, EC2 authorized_keys, EKS webhook kubeconfig and registries.yaml,
  MWAA); a local tar-writer failure is reported at once.
- Send Connection: close on control-plane requests, since the Apache
  transport reuses pooled sockets the daemon has already closed (Podman).
  Hijacked requests and the streaming pool are unchanged.
2026-10-03 14:56:35 -05:00
Hector Ventura 2170c89d88 fix(lambda): include the resource namespace in code volume names (#4872)
* fix(lambda): include the resource namespace in code volume names

Code volumes, their completion markers and the populate helper container are
named through prefixedDockerName, so FLOCI_DOCKER_RESOURCE_NAMESPACE follows the
container name prefix as it already does for Lambda containers. Two namespaced
instances on one daemon no longer share a code volume, and one's superseded-volume
cleanup can no longer remove the other's. Names are unchanged without a namespace.

* fix(lambda): keep two resource namespaces from sharing a code volume

Greptile and pgermosen on #4872: a namespace and a function name may both
contain dashes, so namespace ci with function foo-code-bar and namespace
ci-code-foo with function bar spelled the same volume name for the same code,
and the superseded sweep, which works from a per-process map of names, could
remove the other instance's volume. A namespaced code volume name now ends with
a short hash of the namespace (names without a namespace are unchanged), and the
sweep checks the volume's floci_namespace label before deleting, so a volume of
another namespace is left alone however its name parses.

Also imports the Mockito types in ContainerLauncherCodeVolumeReuseTest instead
of qualifying them inline.
2026-10-01 23:00:33 -04:00
Hector Ventura 24c655050f feat(docker): give internal Docker labels io.floci.* names and keep the old keys as aliases (#4871)
* feat(docker): give internal Docker labels io.floci.* names and keep the old keys as aliases

Owner, ECS run, credentials-proxy, security-group and VPC network labels move to
io.floci.owner, io.floci.ecs.run, io.floci.ecs.credentials-proxy,
io.floci.security-group.helper/workload, io.floci.component and the standard
resource-identity keys. The previous keys (floci_owner_port, floci.ecs-run,
floci.ecs-task-role-credentials-proxy, floci.security-group-*, floci.component,
floci_component, floci_vpc_id, floci_vpc_region, floci_vpc_owner_port) are still
written as legacy aliases with the same value.

Readers take the new key first and fall back to the legacy one, label filters
query both key sets, and owner-scoped cleanup leaves an object alone when the two
disagree. All alias keys are reserved from extra-labels.

VPC networks are now owned by ownerIdentity (namespace and port) instead of the
bare API port, so two namespaced instances on the same port no longer reconcile
each other's networks.

* fix(ec2): keep pre-upgrade VPC networks of a namespaced deployment its own

Greptile and pgermosen on #4871: a VPC network created before the owner label
took the resource namespace carries only floci_vpc_owner_port with the bare API
port, so with a namespace set the deployment read its own surviving network as
a CIDR collision and the startup sweep left it behind. Such a legacy-only
network is now this deployment's when it holds this port and its
floci_namespace label names this deployment's namespace, the identity the new
io.floci.owner key encodes. Matching the bare port alone would also claim, and
let the sweep delete, the pre-upgrade networks of another namespace on the same
port.

Also imports List in ContainerStorageHelperTest instead of qualifying it inline.
2026-10-01 22:59:57 -04:00
GoooooooooodyandGoooooooooody 76f8c09341 fix(docker): make the Docker client pool size configurable, default 1024 (#4276)
The shared DockerClient's connection pool was hard-coded to 100. Each live
Lambda container holds two of those connections for its whole lifetime
(the followed log stream and the exit watcher), so about 50 warm
containers exhaust the pool. Create, start, stop and remove then wait for
a free connection, including the idle-container stop that would release
one, and the emulator stalls.

Expose the size as floci.docker.max-connections
(FLOCI_DOCKER_MAX_CONNECTIONS), reject values below 1, and default it to
1024 so that the 500-port Lambda runtime API range, not the Docker pool,
is the ceiling on concurrent Lambda containers.

Refs #2219, #2224

Co-authored-by: Goooooooooody <205637002+Goooooooooody@users.noreply.github.com>
2026-09-28 22:04:05 -05:00
Kurt McAlpine a574a6d01f fix(docker): keep host network mode for containers that publish ports (#4192)
* fix(docker): keep host network mode for containers that publish ports

A spec with port bindings skipped HostConfig.NetworkMode on create and
connected to the network after start, which Docker refuses for host,
none and container:<id>. Such containers silently stayed on the default
bridge with a published port, so an OpenSearch domain under
FLOCI_SERVICES_DOCKER_NETWORK=host stopped listening on the host's :9200
once domains always published a host port (#2798).

Namespace network modes now always go on the HostConfig, their port
bindings are dropped since Docker publishes nothing there, and the
post-start connect is skipped. A host-network container's endpoint
resolves to localhost when Floci itself runs in Docker instead of a
null host.

* fix(docker): resolve container:<id> endpoints through the owning container

resolveEndpoint only special-cased host, so a container sharing another
container's network namespace fell through to resolveContainerIp, which
has no network to read, and Floci stored a null host for it. The
endpoint now follows HostConfig.NetworkMode to the owning container:
localhost when that container is on the host network, otherwise its IP
on the Docker network. Reading the mode from the inspect rather than the
spec also covers adopted containers.

* test(docker): pass portBindingHostIps to the network test spec helper

ContainerSpec gained a 28th component in #4175 after this branch was cut, so the spec(...) helper added here no longer compiled once rebased onto main.
2026-09-23 18:31:09 -04:00
Alexy Grabov d8e7382d5b fix(docker): allow explicit root for restricted sockets (#3558) 2026-09-13 19:35:01 -05:00
Sam Fakhreddine 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 bede98fc1 and
f3837be32). A version could be published in the narrow window between that
decision (finding no live reference) and the actual delete, persisting a
snapshot whose codeLocalPath names a directory that is about to be removed --
its own future invocation would then fail with "Code directory not found".

publishVersion and the reclaim call in extractZipCodeBytes now both take the
same per-function lock deleteFunction already used for this. Proven with a
test that holds the lock externally and asserts publishVersion blocks until
it is released, rather than relying on timing to catch the race in the act.
2026-08-28 10:52:53 -04:00
Matheus Oliveira 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>
2026-08-23 20:47:00 -04:00
floverfelt f8b07a78ff feat(lambda): add the ability to name and label lambda containers, code volumes (#2409) 2026-08-19 14:21:47 -04:00
Olamide Kosile 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.
2026-08-13 00:02:28 -05:00
Stuart Lang 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.
2026-06-24 22:08:27 -05:00
Hector Ventura 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
2026-06-14 20:34:43 -05:00
Fred Peña 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
2026-05-10 13:54:23 -05:00
Hector Ventura 4f0150870a feat(docker): centralize Docker config and add private registry authentication (#549) 2026-04-21 08:45:37 -05:00