The Kubernetes Lambda executor built every pod without a nodeSelector or tolerations, so on a cluster whose node groups are all tainted the pods stayed Pending until the cold-start timeout. FLOCI_SERVICES_LAMBDA_KUBERNETES_NODE_SELECTOR takes key=value entries with label syntax for spec.nodeSelector, and an invalid entry fails the cold start rather than letting the pod land on nodes it was meant to avoid. FLOCI_SERVICES_LAMBDA_KUBERNETES_TOLERATIONS takes the tolerated taints in kubectl taint syntax (key=value:Effect, key:Effect, or a key alone for every effect), and an invalid entry is dropped with a warning, as an invalid label is. A repeated key now logs which value replaced which. The Helm chart, now 0.2.0, renders both from floci.lambda.kubernetes.nodeSelector and tolerations.
Closes#8992
* feat(docker): count open Docker streams per service and add a saturation harness
* fix(docker): match container routes at the start of the path, and tidy the harness
* test(docker): drop the saturation harness's quiet-stream sleep
* fix(docker): open long-lived exec streams on the streaming Docker pool
CodeBuild build phases, SSM run commands, ECS Exec sessions, the EKS audit log follower, ECR garbage collection, EC2 and EKS user data scripts and EMR bootstrap actions held a control-plane connection for as long as their exec ran, so enough of them could leave the short Docker calls waiting for a lease. Their exec starts now use the @StreamingDocker client: ContainerLifecycleManager exposes getStreamingDockerClient(), CodeBuildRunner and SsmDirectCommandExecutor inject it, and UserDataPipeline and ContainerExec take it beside the control-plane client. Neither transport replays an exec start and both exempt it from the response timeout, so only the pool changes; creating, inspecting and resizing an exec stay on the control plane. The connection pool docs, the environment variable tables, the application.yml comment and the javadocs now name these streams.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* fix(codebuild): close a timed-out phase's output stream, and drop the test-only constructor
runPhase discarded the callback of its exec start, so a phase that timed out or was interrupted left its output stream open, now holding a streaming connection for as long as the command ran on; it is now closed. ContainerLifecycleManager's public four-argument constructor existed only so tests could pass one client for both pools; it goes, and those tests name both clients through the injected constructor.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* test(docker): give the reachability test the streaming client the constructor now takes
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
#8951 added ContainerLifecycleManagerReachabilityTest with the four-argument constructor this branch removes, so the two no longer compiled together on main.
---------
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
api-timeout-seconds bounded each attempt, and the control-plane transport retries a replayable request up to six times, so a silent daemon held a call for about six times the setting plus backoff. DockerRetry now takes one deadline across attempts and backoffs, counted from the first attempt, and checks it again after each backoff so an overslept sleep starts no attempt past it. The producer gives it to the control-plane client only: a silent daemon fails the call after one attempt, fast transient failures are still retried within the limit, and long-lived streams (image pulls, container waits), which have no response timeout, keep their retries. A running attempt is not cut short. DockerRetry.call takes the clock and the backoff wait, so the tests advance a test clock instead of sleeping.
FLOCI_SERVICES_IAM_SEED_DEPLOYER_ACCESS_KEY_ID (floci.services.iam.seed-deployer-access-key-id) chooses the seeded deployer's access key ID. The default stays floci, so setups signing with floci / floci keep working; any other value must be 16 to 128 word characters, as IAM requires of an AccessKeyId, or startup fails naming the setting. With such an ID the deployer's key can be deactivated and deleted, and then the floci-deployer user. Under persistent storage, seeding deletes the deployer's key seeded under an earlier ID, the one signing with the public floci secret, and keeps keys made with CreateAccessKey. The EKS token webhook refuses the seeded credential by that public secret rather than by its access key ID.
Closes#8624
FIS's aws:fis:inject-api-internal-error, -throttle-error and
-unavailable-error actions were recorded as running and never did
anything. A running one now fails the calls it impairs: calls signed
with a session of one of its target roles, to one of the operations it
names in its service namespace, at its percentage.
- FisApiFaultFilter runs after IAM enforcement and reads the operation
from the route that serves the call, through RequestOperationResolver,
for every protocol. Only the accounts and Regions where such an
experiment runs are looked into, so any other request costs a set
lookup and leaves nothing cached, whatever account ID it names.
- EC2 answers with InternalError, RequestLimitExceeded or Unavailable,
from its error code list. Kinesis answers with the common errors
InternalFailure, ThrottlingException or ServiceUnavailable, in JSON or
CBOR to match the request.
- Templates must give service as ec2 or kinesis, a percentage from 1 to
100, comma-separated operations and a duration from one minute to 12
hours. A template stored before these checks is checked again when an
experiment starts from it.
- An inject-api action completes once its duration runs out, worked out
on each read rather than on a timer, and an action that starts after
it then starts. The experiment completes when every action has
completed or been skipped.
- floci.services.fis.inject-api-any-service, off by default, lets the
actions target any namespace, named by its IAM namespace or by the
name it signs under. Those services answer with the common errors in
their protocol's envelope, a Query or REST-XML ErrorResponse in the
service's own XML namespace; Route 53's catalog entry now carries its
namespace, as its own errors do.
The error bodies a filter answers with move into ProtocolErrorResponses,
which IamEnforcementFilter, AwsQueryController and ServiceEnabledFilter
now share instead of each building its own Query ErrorResponse.
The fault injection carries over the design of dchakrav-github's #4591.
Refs #4623
Co-authored-by: dchakrav-github <42748809+dchakrav-github@users.noreply.github.com>
Seeing what a client sent, and what Floci answered, meant reading
service logs. floci.request-log.enabled (FLOCI_REQUEST_LOG_ENABLED), off
by default, appends one JSON object per request and response to
floci.request-log.file (./floci-requests.jsonl by default). Each line is
shaped like a HAR 1.2 entry and carries callerAccessKeyId, the access
key id the request was signed with, so every call can be tied to the
caller that made it.
The request is captured pre-matching, ahead of every other filter, so a
request another filter aborts is still logged. Its body is read on the
worker thread by a post-matching filter, only when its declared length
is within 256 KiB, and handed back whole to the resource; a chunked
body is not read, so a slow upload never holds a worker. A body that is
not valid UTF-8 is stored base64, a response is cut at 256 KiB with its
full size kept, and a response streamed to the client is never read.
Signature, session-token, credential and cookie headers and presigned
query parameters are redacted, matched by decoded name in the URL too.
Lines are written by a thread of their own from a bounded queue, so a
stalled file never holds a response. The file is created readable by
its owner only, and only a regular file is written: a symbolic link, a
named pipe or a directory at the path is refused.
This is the request-log half of #4623, carried over from #4591.
Refs #4623
Co-authored-by: dchakrav-github <42748809+dchakrav-github@users.noreply.github.com>
Floci serves each RDS database through a proxy in the 7001-7099 range,
and Endpoint.Port and DBCluster.Port reported that proxy port even when
the request set Port=5432. The Terraform AWS provider sets port from
those fields, so every aws_db_instance and aws_rds_cluster with a
conventional port planned port 7001 -> 5432 on each run.
floci.services.rds.advertise-requested-port
(FLOCI_SERVICES_RDS_ADVERTISE_REQUESTED_PORT), off by default, makes
DBInstance.Endpoint.Port and DBCluster.Port report the requested Port,
while the proxy keeps listening in its range. A cluster member without
its own Port reports its cluster's. The managed master-user secret and a
CloudFormation secret target attachment keep the connectable proxy (or
published) port. The requested port is stored, so a restart or a backend
retry rebuilds the same advertised endpoint, a stopped database follows
the setting if it changed across a restart, and a blue/green switchover
moves the requested port with the endpoint it belongs to.
Closes#4575
Co-authored-by: Allen Sanborn <allen.sanborn@gmail.com>
On Fargate the containers of an awsvpc task share one network namespace
and reach each other on localhost. Floci gave each container a namespace
of its own unless security-group enforcement was on, and enforcement
needs rootful Docker, so a sidecar task definition (nginx in front of
php-fpm on 127.0.0.1:9000) could not run unchanged on rootless Docker or
Podman.
floci.services.ecs.shared-task-network (FLOCI_SERVICES_ECS_SHARED_TASK_NETWORK),
off by default, gives such a task one namespace while enforcement is off.
A helper container holds it, as the ECS agent's pause container does. The
firewall manager starts it from the same code as a protected helper, with
no nftables table and no rootful requirement, and every container in the
task joins it. The helper holds what the task has once rather than per
container: its published ports, the link-local address its containers
reach the task-role credential endpoint from, and its ENI address on the
VPC's Docker network. FireLens's FLUENT_HOST is 127.0.0.1, the value the
ECS agent sets for awsvpc. The helper is removed once the task's
containers are, before its link-local address is handed on, and a helper
a previous run left behind is swept at startup with the task's other
containers. A helper Docker keeps is marked pending on the task's handle,
which the service keeps to retry the removal; its address stays reserved
until then, and it is taken off the VPC network so the ENI address is free
when the ENI is released. Launch cleanup removes a helper by name even when
its start failed part way, and now also covers the VPC attachment, so a
failed attachment no longer leaves the task's containers running. With
enforcement on, nothing changes.
The helper image now builds from docker.io/library/alpine: Podman refuses
a short name it cannot prompt about, and the task-role credentials proxy
builds from the same Dockerfile.
Closes#4331
* fix(elbv2): apply regional ALB zone defaults with overrides
* fix(elbv2): restore legacy subnet snapshots during stack rollback
* fix(elbv2): require two ALB zones for the AWS default
* fix(elbv2): simplify explicit ALB zone rules
The embedded DNS server only started when Floci ran in Docker, so a
natively running Floci left <service>.<namespace>, Route 53 private
zone records and its own names unresolvable, both for the containers it
launches and for the host.
Natively it now starts up to two listeners. On a host with a docker0
bridge it listens on that bridge's address, port 53, the address
host-gateway points at, and hands it to the containers it launches as
their resolver, as it does from Docker. Port 53 needs root or
CAP_NET_BIND_SERVICE; without it Floci logs how to grant it and the
containers keep resolving through Docker. floci.dns.bridge-listener-enabled
turns it off. With floci.dns.host-port set it also listens on 127.0.0.1
at that port for the host's own resolver; that listener is never handed
to containers, and it refuses names Floci does not hold rather than
forwarding them, so a host resolver that routes a domain to Floci cannot
get a lookup back. Each listener answers Floci's own names with its own
address.
Startup now waits, up to five seconds, for the listener containers are
given to bind or fail, in Docker as well as natively, so a container
launched right after startup is not created without Floci's resolver.
Closes#2556
A Lambda extension's exec and the container's exit watcher each hold a
Docker connection for the container's whole lifetime, and both still ran
on the control-plane client. Enough warm containers, especially with
extensions, could fill that pool and stall every create, start, stop and
remove call, the failure the streaming split was made to prevent.
Both now use the @StreamingDocker client. The exit watcher's inspect is
a short call and stays on the control-plane client, with its retries.
The streaming transport now replays a container wait that fails before
the daemon answers, as the control-plane one does, so a stale socket
does not spend one of the watcher's re-arms. Exec starts and log and
attach streams are still never replayed.
Each live Lambda container now holds its log follow, its exit watcher and
one exec per extension on the streaming pool, so its default rises from
512 to 2048 to cover the 500 containers the runtime API port range allows
with two extensions each. The control-plane default stays at 1024.
Closes#2224
Health at /_floci/health, /_localstack/health and /health gains status UP
and cloud aws from one shared body. GET /_floci/tls-cert serves the same
PEM as ca.pem, as application/x-pem-file, and answers the shared 404
{tlsEnabled, error, message} when TLS is off.
A path under /_floci or /_localstack that no route serves answers a JSON
404 from ControlPlaneNotFoundFilter instead of falling through to S3, and
S3VirtualHostFilter leaves those paths alone, so a virtual-hosted request
can no longer address a key under _floci/ or _localstack/. The endpoints
are documented on one page.
With floci.docker.image-registry-base set, ContainerBuilder.resolveImage put
the base in front of every image, so an ECR image Floci had rewritten to its
loopback registry (localhost:<port>/<account>/<region>/<repo>), or a
repositoryUri it handed out, became <base>/localhost:<port>/...: a reference
Docker refuses, and no image a mirror holds. An ECS task, an image-backed
Lambda function or an EMR Serverless application with a custom image could not
run from Floci's ECR with the base set.
- An image in a registry on the Docker host's loopback (localhost, a
.localhost name, Floci's localhost.floci.io alias or a loopback address in
any spelling, checked with NetworkExposureGuard.isLoopback, with or without
a port) is launched as it is; every other image still goes under the base.
- The setting's Javadoc, its environment variable row and the ECR page say so.
* feat(sns): trust FLOCI_TLS_EXTRA_CA_PATH for HTTPS subscriptions
SnsService built its delivery HttpClient without an SSLContext, so an
HTTPS subscription whose endpoint has a certificate from a private CA
never got the SubscriptionConfirmation or any notification. Floci only
logged "Failed to reach SNS endpoint".
The @Inject constructor now passes ContainerCaBundle.sslContext(config)
down to the constructor that builds the client, as EventBridgeInvoker
does. The SubscriptionConfirmation and notification delivery share that
one client. It stays pinned to HTTP/1.1, and hostname verification
stays on. The other constructors build the client as before.
Closes#8033
* test: share the /hook HTTPS endpoint between the extra CA delivery tests
LocalHttpsServer.hook starts a localhost HTTPS server that passes each
request to /hook to a callback and answers 200, and hookUrl gives its
URL. EventBridgeInvokerApiDestinationTest and the new SNS test use them
instead of each writing the endpoint out.
Add floci.tls.extra-ca-path (FLOCI_TLS_EXTRA_CA_PATH): a PEM file of CA
certificates that Floci's own outbound HTTPS clients trust on top of the
JVM's default roots, and Floci's CA when TLS is on. It applies whether or
not TLS is enabled.
ContainerCaBundle.sslContext(config) merges the extra CAs and is now also
built with TLS off. floci-ca-bundle.pem and its .p12 are unchanged, so
containers Floci launches are unaffected in both modes. EventBridge API
destination delivery uses the context, and JwtSignatureVerifier already
shares it, so HTTP API JWT authorizers and AppSync OIDC providers trust
the extra CAs too.
TlsExtraCaStartupValidator refuses to start when the file is missing,
unreadable, or holds no certificate, from any config source. A private
key in the file is ignored.
Closes#5259
With floci.tls.extra-ca-path set and TLS on, a bundle that could not be
read or parsed made outboundTrustAnchors throw. sslContext(config) then
logged the extra CA file as the unreadable one, fell back to the bundle
alone, failed on it again and returned empty, so the valid extra CAs
were dropped.
The bundle is now read on its own: on failure Floci warns with the
bundle's path and trusts the JVM roots plus the extra CAs, as the
sslContext(config) Javadoc already describes.
ContainerCaBundle builds every SSL context and trust manager array from a
KeyStore, so sslContext(Path), trustManagers(Path) and the extra-CA
context no longer repeat the JCA calls.
Tests share LocalHttpsServer in testing for the localhost HTTPS server
issued by a CA, the two JWT issuer-trust cases share one helper, and the
JVM roots check in ContainerCaBundleTest is written once.
outboundTrustAnchors and trustStore(Path) now read a certificate file
through one method, which also refuses a file with no certificate.
In the tests added for the extra CA file, the certificate-and-key file
comes from one helper in TlsTestSupport, the two missing-file cases are
one parameterized test, and the refused EventBridge delivery is checked
by one helper.
TlsExtraCaStartupValidator now calls ContainerCaBundle.certificates
instead of reading the file and checking for a certificate on its own.
outboundTrustAnchors reads the bundle through the same method, and
ContainerCaBundle.extraCaFile is the one place that decides whether the
setting is set, for both the SSL context and the startup check. The
startup message still names the path and gives the reason.
Both EventBridgeInvoker constructors now get the API destination
HttpClient from one method, which adds Floci's outbound SSL context
when there is one.
Expose backend keep-alive and idle-pool timeout controls while retaining the existing defaults. Preserve target failures without replaying uncertain requests, and document target timeout hints and local transport limits.
Validate negative idle timeouts with a Floci-specific error before creating clients, and attempt every fixture cleanup step while preserving aggregated failures. Cover negative, zero and positive configuration values and real-listener connection behavior.
Closes#7524
test(elbv2): replace timer-dependent backend checks
Move the Java sources from io.github.hectorvent.floci to io.floci.aws, matching io.floci.gcp, io.floci.az and io.floci.oci. Generated by tools/rename/rename_package.py apply on the base commit, with no other edits.
Logger categories and the arn.fail-on-blank-region property move to the io.floci.aws prefix. The pom groupId becomes io.floci; the artifactId stays floci.
Refs #6589
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* fix(apigateway): report the published regional hosted zones
A regional custom domain reported the invented Z2FDTNDATAQYL2 everywhere outside
GovCloud, so a Route 53 alias built from it pointed at a zone AWS does not have.
Vendor the data plane table of the API Gateway General Reference page into
region-facts.json, with the GovCloud guide kept as a cross-check. A region with no
row keeps the placeholder, now documented as one. Stored domains keep their id.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* test(apigateway): read the regional hosted zone through the SDK clients
Create and read the custom domains with ApiGatewayClient and ApiGatewayV2Client, so the test also shows both SDKs parse the zone fields.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
---------
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
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>
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.
* fix(storage): propagate buffered WAL failures before publication
Rebase the focused WAL correction onto official main after the independent SQS rollback and snapshot fix merged as #7008. Retain buffered ordinary writes, atomic batch sync, safe rollback and exception propagation before publication.
* fix(storage): reject an unavailable buffered WAL path
Retain the existing unavailable-log and closed-writer fault controls while reconciling the signed WAL contribution with the merged SQS rollback dependency. No WAL behavior change from the previously validated contribution.
With TLS on, Floci writes its CA bundle as a Java trust store too, but
only EMR's containers got it: a launcher had to copy it in with
ContainerLifecycleManager.copyJavaTrustStore and point its JVMs at it
with a shell line. So a Java Lambda function, ECS task, Batch job or
Flink application calling Floci over HTTPS still failed with "PKIX
path building failed" unless it brought a trust store of its own.
ContainerBuilder now has withJavaTrustStore(). For a container whose
spec asks for it, the lifecycle manager copies the trust store in
beside the CA bundle as it creates the container, and sets
JAVA_TOOL_OPTIONS to Floci's -Djavax.net.ssl.trustStore ahead of the
value the spec gives it, or the image's own when the spec sets none,
so a trust store the workload names itself still replaces Floci's. A
copy that fails creates the container again without any of the trust
variables, as a failed bundle copy already did, so JAVA_TOOL_OPTIONS
never names a file that is not there.
Lambda functions on a Java runtime or from a container image, ECS task
containers, Batch jobs, and Flink's JobManager and TaskManager ask for
it, and so do EMR steps and EMR Serverless job runs, whose
spark-submit starts directly again. The bootstrap actions' container
keeps the separate copy and the shell line, since it is kept as the
steps' image, which would keep a JAVA_TOOL_OPTIONS set at its
creation. Other containers are unchanged.
With TLS on, every container Floci launches gets the CA bundle and the
SSL_CERT_FILE family of variables, but the JVM reads none of them. So
in the docker runner mode a Spark job's own SDK clients that ignore
AWS_ENDPOINT_URL, the AWS SDK for Java 1.x's or an older 2.x's,
failed with "PKIX path building failed" against Floci's HTTPS, even
with FLOCI_DNS_SPOOF_AWS_ENDPOINTS sending AWS's endpoint names to
Floci. A job could only reach Floci over its HTTP endpoint.
Floci now also writes the bundle's certificates as a PKCS12 trust
store at boot, floci-ca-bundle.p12 beside the bundle. A launcher whose
workload is Java can copy it into a container before the container
starts (ContainerLifecycleManager.copyJavaTrustStore) and point the
container's JVMs at it through JAVA_TOOL_OPTIONS, with a shell line
that does so only when the file is there. The store has no password
and the line gives only its path, so a trust store a job or an image
names itself replaces Floci's, with that store's own type and
password. EMR Serverless job runs and EMR steps copy it into the
driver's container ahead of spark-submit or the step's command, and
the bootstrap actions' container gets it for its actions, then drops
it before the image is kept. Other services' containers are unchanged.
JAVA_TOOL_OPTIONS rather than spark.driver.extraJavaOptions, since
setting that key would replace what the image's spark-defaults.conf
gives it, and a job's own value would drop Floci's. Each JVM prints
"Picked up JAVA_TOOL_OPTIONS: ..." on its standard error, as the docs
now say.
Select runtime images with the effective Docker platform while preserving runtime-wide defaults, explicit platform precedence and code-volume helper platform.
Signed-off-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* feat(lambda): make reactive S3 sync toggleable and optionally async, reporting LastUpdateStatus while it runs
* fix(lambda): run async reactive S3 syncs as the uploader's account, keep InProgress continuous, and queue the latest source per function
* fix(lambda): clear a failed reactive sync's LastUpdateStatus on UpdateFunctionConfiguration, and test async syncs from a second account
* test(lambda): share LambdaCodeSourcesProfile for the async reactive sync test, reuse LambdaWebZips, and extract the failed-sync setup
* docs: document the standalone floci-aws binary
#5844 publishes a standalone floci-aws binary with every release but no
page says so. The installation guide gains a Native binary section: the
asset per platform, download and checksum, cosign and attestation
verification, the glibc 2.34 floor and the macOS quarantine, which
services need Docker and what happens without it, where persistent state
goes and the host-<port> container namespace, configuration, and running
it under systemd or launchd.
It also says the state directory is shared across ports, so two
persistent binaries need their own FLOCI_STORAGE_PERSISTENT_PATH, and a
persistent binary should restart on the port it used before.
The README points at the section, and the Docker images page no longer
says the arm64 baseline build is image-only.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* docs: say where the image listens and which binaries the image ships
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* fix: report EC2 as metadata only without Docker, and create ~/.local/bin on install
Without a Docker daemon an EC2 launch does not fail by default:
Ec2ContainerManager marks the instance running as metadata only, and
fails the launch only when security-group enforcement is on. The startup
warning listed EC2 with the services that fail on use, and the binary
page did the same. EC2 now joins the metadata-only group, and moves to
the fail-on-use group when enforcement is enabled.
The install steps create ~/.local/bin before installing into it and run
the binary by its full path, and the namespace note says that binaries
on separate hosts sharing a port and a remote daemon need their own
FLOCI_DOCKER_RESOURCE_NAMESPACE.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
---------
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
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.
* feat(lambda): add init-timeout-seconds so a cold runtime gets its own init budget
* fix(lambda): count the init budget from container start, apply it only until the first /next poll, and cover it in SQS visibility
* test(lambda): check the dispatch wait directly instead of on the clock, and correct the init budget docs
* feat(sqs): publish AWS/SQS queue metrics to CloudWatch
Every active queue now reports the AWS/SQS metrics once a minute on the
QueueName dimension: the depth gauges, ApproximateAgeOfOldestMessage, the
send, receive, delete and empty-receive counters, SentMessageSize, and for
FIFO queues the in-flight groups and deduplicated sends. The samples follow
what SQS sends on AWS, so alarms, GetMetricData and GetMetricStatistics see
queue metrics without PutMetricData.
The CloudWatch metric store is now journaled under persistent mode, as the
CloudWatch Logs event store is, since it takes a write per metric per active
queue every minute.
Closes#6275
* fix(sqs): stamp queue metrics with the minute that ended
The publisher now ticks just after each minute boundary and stamps its
samples with the minute that ended, so a call counts in the minute it was
made instead of the minute of a startup-relative tick. A queue whose write
fails no longer stops the others, and the log names it. A queue deleted and
created again between the snapshot and the lookup is skipped instead of
reporting the old queue's depth under the new one.
* fix(sqs): bound AWS/SQS metric history and finish the tick on shutdown
The publisher now drops AWS/SQS datapoints older than the 15 days AWS keeps
one-minute data, once an hour, so the history it generates for an active
queue stays bounded. On shutdown it stops before the storage flush and waits
for a running tick, so the last minute is not written after the store closed.
* test(sqs): keep the scheduled metrics tick out of the test run
The acceptance test publishes its own ticks, but the scheduled one could
still stamp the test queue's depth into a complete period newer than them,
since a tick stamps the minute that just ended. floci.services.sqs.
cloudwatch-metrics-enabled now turns the tick off, and the test
configuration does, as it does for the S3 lifecycle sweep. It also lets a
user opt out of the AWS/SQS metric volume.
* test(sqs): build the metrics test's queue service with SqsServiceFactory
* feat(dynamodb): opt-in per-table item files, split into shards
Every table's items live in one dynamodb-items.json, and any item write
rewrites all of them. A small table that changes often, such as a node
heartbeat table, then keeps rewriting every large table beside it.
Add an opt-in item layout. With item-layout: per-table, items are stored
under dynamodb-items/ as item-shards files per table, and a write saves
only the items it touched:
- persistent rewrites the one shard file that holds the item before the
write returns, and fails the write when that file cannot be written
- hybrid marks the shard dirty and writes dirty shards on the flush
interval; an explicit flush or shutdown reports shards it could not
write
- wal keeps the single-file layout for now and logs a warning
The default, single-file, is unchanged.
On first start, an existing dynamodb-items.json, or a wal snapshot and
log, is migrated through a staging directory moved in place in one step
and then renamed .migrated; a failed migration stops startup and leaves
the old files untouched. DynamoDbService writes single items through the
new MapEntryWriter, and the TTL sweeper removes each item under its item
lock.
Part of #6293
* test(storage): skip read-only directory tests where POSIX permissions are missing
Close admission during drain and retain failed removal ownership. Retry late releases within a separate bounded cleanup attempt, validate drain configuration at startup, and safely reopen after reset.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
With floci.protocols.strict-claiming off, the default, a request that no wire protocol claims is
logged and served by whatever route it matches. The checks after routing read the claim, so they
saw a request of no protocol:
- IAM enforcement served it unsigned. The MissingAuthenticationToken refusal applies only to a
JSON, CBOR or Query claim. An unsigned SQS ListQueues over JSON or Query, or a Kinesis
ListStreams over CBOR, was served when it carried a Smithy-Protocol header Floci does not serve
that path by: an unknown value, or rpc-v2-cbor outside the rpcv2 path. An X-Amz-Target call with
no Content-Type reached the CBOR endpoint the same way.
- IAM enforcement checked a signed REST request as the action its X-Amz-Target header named, not
its route's. A user allowed only s3:GetObject deleted an object by sending the DELETE with
X-Amz-Target: AmazonS3.GetObject and any Smithy-Protocol header. A signed JSON call it refused
got the REST status, 403, rather than JSON's 400 AccessDeniedException.
- A call to a disabled service was served when only its claim would have named the service, as for
an unsigned JSON or rpcv2 call.
- A REST JSON service request that fell through to S3's wildcard routes was not rejected, and a
REST request signed for a service Floci lacks skipped the guard that refuses it before routing,
so S3's routes answered it with a misleading error.
The new AwsRouteClaimFilter runs after route matching and before every filter that reads the
claim, AccountContextFilter's unknown-Region refusal and the signature check among them. It claims
such a request by the route it reached, through ProtocolClaimer.routeClaim:
- the JSON 1.0, JSON 1.1 and CBOR endpoints by X-Amz-Target;
- the rpcv2 route by its path;
- the Query endpoint's POST by the form;
- every other route as REST.
Those routes serve the request the same way whatever Smithy-Protocol header it carries, so the
claim names the call that runs. A request claimed as REST also gets the unknown-service-scope
check a claimed one gets before routing, which AwsProtocolClaimFilter now exposes for it. A
claimed request is left as it was, and strict claiming still rejects an unclaimed one before
routing.
An X-Amz-Target post with a content type no protocol uses, the third kind of request the
strict-claiming docs list, matches no route at all, and got a 500 rather than its 415, as any root
POST in a content type no endpoint consumes did. Several resource methods share POST /, so RESTEasy
Reactive routes it to a placeholder with no method of its own that picks one by content type, and
answers 415 from there when none consumes it. The ResourceInfo producer then returns the
placeholder's missing method, and CDI refuses the null with IllegalProductException.
AwsRestJsonErrorHeaderFilter and S3CorsFilter read ResourceInfo on every response, so each failed
on it. Both now read it through the new RoutedResource, which gives null when routing chose no
method.
docs/services/iam.md and the strict-claiming setting's docs say how such a request is handled.
IamEnforcementFilter builds its rpcv2 route claim through the same ProtocolClaimer helper.
* feat(sqs): opt-in AWS QueueUrl form via endpoint strategy
FLOCI_SERVICES_SQS_ENDPOINT_STRATEGY=standard returns queue URLs in the AWS
form, https://sqs.<region>.<dnsSuffix>/<account>/<name>. The default, path,
keeps the current form. Every input form resolves under either setting.
* fix(sqs): endpoint strategy accepts path or standard
* refactor(sqs): queue URL forms are floci and aws, with shared round-trip tests
* test(sqs): strategy names in tests and config comments read floci and aws
* docs(sqs): list endpoint-strategy on the application.yml page
The yml block and the env var table both list the setting, and the base-url comment names the aws strategy.
* fix(ec2): assign mock public addresses and displace earlier Elastic IPs
In mock mode an instance never received a public IPv4 address, whatever
its subnet's MapPublicIpOnLaunch or its launch's AssociatePublicIpAddress
said, and an associated Elastic IP never reached DescribeInstances.
- A mock instance that asks for a public address gets one when it reaches
running, whether DescribeInstances, DescribeInstanceStatus or
StartInstances completes the launch. Stop and termination release it.
An associated Elastic IP replaces it and survives a stop; disassociating
it gives a running instance a new automatic address when its launch
asked for one.
- AssociateAddress disassociates the Elastic IP an instance already has,
including one a retained interface carried onto it, as the
AssociateAddress reference describes.
- Launches from a template take AssociatePublicIpAddress from its
device-index-0 interface (RunInstances, CreateFleet, Auto Scaling), and
RunInstances and CreateFleet also take that interface's subnet.
- RunInstances refuses an instance-level SubnetId combined with network
interfaces, on the request or in its launch template, with
InvalidParameterCombination.
Split out of #5671 at review.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): scope Elastic IP displacement and automatic addresses as AWS does
- AssociateAddress ignored PrivateIpAddress, so an Elastic IP meant for
a secondary private address displaced the one on the primary. The
address is now recorded on the private address it names, only an
address already on that private address is displaced, the interface
shows it there, and in mock mode only the primary's address becomes
the instance's public address.
- An instance launched on an existing network interface got an
automatic public address; AWS assigns one only to an interface the
launch creates.
- A released automatic address was replaced while a second interface
was attached; AWS does not replace it then.
- An Elastic IP that a retained interface carried to a new instance
stayed without an instance. It now names that instance, which shows
the address and keeps it across a stop.
- A mock launch could complete over a concurrent stop or termination,
and DescribeAddresses could write back an address disassociated
meanwhile; both now re-check under the instance's lock.
The tests also cover a request's own network interfaces with an
instance-level SubnetId, and the template interface docs now say which
launches take the subnet.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): settle second-review findings on mock public addresses
- DescribeAddresses re-points associated addresses under the allocation
lock, and a mock launch, start or stop reads the instance's Elastic IP
under it, so none of them acts on an association written halfway or
changed meanwhile.
- An Elastic IP that a retained interface carries is found through that
interface, also when it is disassociated, instead of being rebound to
the next instance at launch, which left a dead InstanceId behind when a
container launch failed.
- StartInstances leaves a running mock instance alone.
- In container mode too, an address on a secondary private address no
longer becomes the instance's public address.
- The second-interface test associates its address before attaching the
interface, since AssociateAddress by InstanceId needs exactly one.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): keep terminated mock instances down and address reads unblocked
- StopInstances leaves a terminated or shutting-down mock instance as it
is, re-checked under the lock, so terminate, stop and start no longer
revives it with a public address.
- DescribeAddresses waits for the allocation lock only when an address
is associated with an instance, and the container re-point no longer
rewrites an unchanged instance.
- A mock start treats a state without a name as settled instead of
throwing.
Tests now cover the terminated instance and, with a reachable container
address, an Elastic IP on a secondary private address leaving the
instance's public address alone.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): settle Qodo findings on mock public addresses
- AssociateAddress refuses a PrivateIpAddress that is neither the
instance's primary private address nor a secondary address of its
primary interface, with InvalidParameterValue and before any
association changes, instead of treating it as the primary and
displacing the Elastic IP already there.
- RunInstances from a launch template whose device-index-0 interface
names an existing NetworkInterfaceId launches on that interface, in
its subnet and without an automatic public address, as a request
naming it would, instead of on a new interface in the default subnet.
- The SubnetId-with-interfaces refusal test now launches against a real
subnet and checks that the refused request leaves no instance or
interface behind.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): accept a container instance's launch address in AssociateAddress
In container mode without AWS-faithful private addresses, the container
manager replaces the instance's reported private address with its Docker
bridge address once the container runs, and nothing keeps the subnet
address RunInstances returned. The new PrivateIpAddress check therefore
refused that address with InvalidParameterValue, though callers may still
name it. Only mock mode and the AWS-faithful mode, which keep the launch
address, now refuse a stray PrivateIpAddress; elsewhere any value means
the primary address, as before.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): decide automatic public addresses the same way with containers
The public IPv4 rules were applied to mock instances only. A
container-backed instance kept its address after a stop and a
termination, got one on an existing network interface, kept its
reachable address after its Elastic IP was disassociated even when the
launch never asked for one, and had a released address replaced while
a second interface was attached.
One rule, AutomaticPublicAddress, now decides whether an instance has
an automatic address in both modes: the launch asked for one on an
interface the launch created (recorded when the instance is built), a
stop, a termination or a disassociated Elastic IP releases it, and a
replacement is held back while a second interface is attached. An
Elastic IP on the primary private address still takes precedence. Only
the value differs by mode: the container's reachable address, or an
invented one where there is no container.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): settle review findings on the shared public address rule
- DisassociateAddress decides by the association, not by comparing
addresses: only an Elastic IP on the instance's primary private address
gives way to another one left there, or to an automatic address when
one is due. With a container, every Elastic IP points at the one
reachable address, so disassociating a secondary one no longer clears
the instance's public address, and one a restart moved no longer
survives its disassociation.
- StartInstances on a stopped container instance releases an automatic
address that a stop outside StopInstances, such as Floci's shutdown,
left in place, so the start decides afresh.
- With a container, these writes no longer wait on the instance's lock
while holding the allocation lock, since the port-forward manager holds
that lock across Docker calls.
- A start test case now keeps an address distinct from the one it
expects, and two comments describe the flag as it now is.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): release only the primary interface's Elastic IP on disassociation
- DisassociateAddress treats an Elastic IP as the instance's public one
only when it sits on the primary interface, not on a retained
interface attached at another device index, so disassociating that one
no longer clears the instance's automatic address.
- With a container, DescribeAddresses no longer writes a re-pointed
address back onto a terminated or shutting-down instance.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): show a carried Elastic IP on a container instance's launch
- An instance launched on a retained interface that still carries an
Elastic IP records that address at RunInstances, and the container
launch re-points it once the container runs. With containers, such an
instance had no public address until a stop and start, since the
shared rule gives an existing interface no automatic address.
- With a container, TerminateInstances clears the public address under
the allocation lock, so a DescribeAddresses re-point already under way
cannot write it back onto the terminated instance.
- The secondary-interface disassociation test checks the address was
still associated before the call and is not after it.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): re-point a carried Elastic IP at its new instance
- DescribeAddresses re-points an Elastic IP that a retained interface
carries at the instance that interface is now the primary interface
of. With containers, the address otherwise kept the previous
container's address for good, since termination clears its instance
id.
- With a container, StopInstances leaves a terminated or shutting-down
instance alone, as mock mode does, instead of stopping it into a
startable state and writing its Elastic IP back.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): give mock instances no invented public address by default
Mock instances due an automatic public IPv4 address got a random
54.x.x.x one, a real AWS range, so a tool that connected to it reached
someone else's host. The new floci.services.ec2.mock-public-addresses
setting (FLOCI_SERVICES_EC2_MOCK_PUBLIC_ADDRESSES) chooses the address:
none (the default) gives none, documentation draws distinct addresses
from 203.0.113.0/24 as Lightsail and EMR do, and fixed gives every
instance mock-public-address (default 127.0.0.1), an address the caller
can reach.
Only the value changes. The launch still records whether it asked for
an address, so the shared rule and Elastic IP precedence work as before,
and instances with containers keep reporting their reachable address.
Elastic IP allocation still draws from 54.x.x.x, as on main.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): settle review findings on the mock public address setting
A configured mock-public-address with surrounding spaces was reported
as is; it is now stripped. The docs and the AutomaticPublicAddress
Javadoc no longer describe every mock instance as getting an address,
and the test configurations that launch mock instances name the
setting instead of leaving it null.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): allocate Elastic IPs from the documentation range
AllocateAddress handed out random 54.x.x.x addresses, a real AWS range,
and this branch shows an associated Elastic IP as a mock instance's
public address, so even with mock-public-addresses at none a client
could reach someone else's host through one. Elastic IPs now come from
203.0.113.0/24 in every mode, distinct from the account's other
Elastic IPs and its instances' public addresses; once all 254 are taken
AllocateAddress fails with AddressLimitExceeded rather than repeat one,
since callers name an Elastic IP by its address.
Under mock-public-addresses: fixed, an Elastic IP on a mock instance's
primary private address is re-pointed at the configured address, as one
on a container instance is at the container's reachable address, and
disassociation restores the allocated address.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(ec2): settle review findings on documentation-range Elastic IPs
An Elastic IP re-pointed at the fixed address kept it after a restart
under another setting; the next read now shows its allocated address
again. The re-point Javadoc and the Elastic IP docs no longer claim a
54.x.x.x allocation or addresses that never repeat, the docs say that
earlier allocations keep their address until released, and a test now
proves an allocation skips the addresses instances hold.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
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.