Compare commits

...

47 Commits

Author SHA1 Message Date
Josh Siviour a52b078678 refactor: move the ECR /v2 bridge out of the gateway (#1350)
* test: pin the ECR /v2 pipeline through the gateway handler

* feat: rehydrate a principal from an access key id in credverify

Adds credential.Rehydrator and CallerARN on Principal, implemented beside Authenticate and Resolve on the same key, session and user lookups, with a parity table against the gateway's ECR rehydrate.

* refactor: share the credverify key and session lookups with Rehydrate

Authenticate, Resolve and Rehydrate now call one lookup per credential kind, so the checks cannot drift. The parity table also asserts the gateway and credverify caller ARN builders agree.

* refactor: move registry host matching to ingress/http

The matcher takes its service labels from the caller and exposes the parsed account and region through accessors, so ingress names no service.

* refactor: extract the identity-policy evaluator into policyauth

The SigV4 gateway path and the ECR registry authorize through one evaluator and one set of request condition keys, over the credential principal.

* refactor: extract account admission into accountadmission

The SigV4 gateway path asks one Admitter for account status, with the ACTIVE-only cache moved with it, so the ECR registry can use the same capability.

* refactor: move the ECR /v2 bridge out of the gateway

The bridge, token exchange and per-operation authorization now live in
domains/ecr/registry behind registry-owned Principal, Rehydrator and
Authorizer types, so the package imports no ingress code. The awsgw role
adapts credverify, policyauth and host matching to them, and the gateway
keeps only a RegistryHandler mounted at /v2. The bridge refuses to
compose without a verifier, issuer, rehydrator, authorizer or admission,
so the open-registry mode for a nil verifier is gone.

* test: carry the retired ECR principal parity rows into credverify

Global root, a verifier with no IAM, a record with no principal type and
the gone, replaced and legacy session verdicts for user and role sessions
were only exercised by the gateway tests that went with the old path.

* docs: record the ECR /v2 bridge move in the package boundary migration

* docs: record the ECR /v2 bridge PR number
2026-10-30 15:57:37 +10:00
Josh Siviour 26d53602a3 fix: accept AWS-format IRSA trust-policy condition keys (#1349)
* test: cover AWS-form IRSA condition keys and StringLike on web identity

* fix: match AWS-form IRSA condition keys and allow StringLike on web identity

* fix: keep the provider ARN host-path unnormalised for web identity

* feat: log the reason a web identity trust policy denies

* fix: satisfy errname, modernize and gofmt on the denial error

* test: cover the stock AWS IRSA trust policy in the EKS e2e

* test: make the IRSA denial prove the policy was evaluated
2026-10-30 14:34:08 +10:00
Josh Siviour 060204514e refactor: register ECS and EKS through the ingress seam with shared PassRole (#1348)
* test: pin ECS and EKS dispatch through the SigV4 pipeline

* refactor: register ECS and EKS on the ingress seam

EKS resolves the cluster and nodegroup role through passrole.Check with the
IAM role resolver, in the order it had. Responses and check order are unchanged.

* fix: match AWS role handling for ECS and EKS PassRole cases

ECS refuses a foreign task role before PassRole, accepts a role that is not an ARN or does not exist after PassRole, and reports a RunTask override role it cannot assume. EKS CreateCluster and CreateNodegroup refuse a foreign or non-role ARN with AccessDeniedException before PassRole.

* test: cover ECS and EKS awsapi registration dispatch

* fix: report EKS parameter faults as InvalidParameterException

* docs: record ECS and EKS gateway migration and EKS divergences
2026-10-30 14:18:53 +10:00
Josh Siviour 12cea4f6f7 feat: add IAM role resolution and the shared iam:PassRole flow (#1347)
* test: pin the current role-resolution gaps in EC2, ECS and EKS

* feat: add the shared iam:PassRole flow with classified role resolution

* feat: resolve same-account roles for iam:PassRole in domains/iam
2026-10-30 12:54:44 +10:00
Josh Siviour 099a69b23b refactor: register IAM and STS through the ingress seam (#1346)
* docs: point the /admin migration row at spinifex#1345

* test: characterise IAM and STS dispatch through the SigV4 pipeline

* refactor: register IAM through the ingress seam

* refactor: register STS through the ingress seam

* docs: point the IAM and STS migration rows at spinifex#1346
2026-10-30 12:08:15 +10:00
Josh Siviour 6462ccc41f refactor: serve the /admin operator API from the spinifex registration (#1345)
* refactor: move the /admin handlers and wire types into operator/admin

* refactor: serve /admin through the spinifex registration

* docs: record the /admin move into the spinifex registration
2026-10-30 10:50:47 +10:00
Josh Siviour ae8ee1e5fe refactor: register RDS through the ingress seam (#1344)
* refactor(gateway): register RDS through the ingress seam

RDS dispatch moves from gateway/rds.go to domains/rds/awsapi.NewRegistration, composed by awsgw and the integration harness.
The caller comes from dispatch.Actor and the principal-class gate still runs before the policy check.

* docs: point the RDS migration row at spinifex#1344

* chore: group the imports merged in the actor projection test
2026-10-30 09:59:15 +10:00
Josh Siviour 488f1c7bf9 feat: SQS store guest on a prepared cold-attached EBS volume (not wired) (#1343)
* feat: build a separate SQS store microVM image

Package the go.mod-pinned nats-server, ext4 support and a clean ACPI
power-down into a microVM kernel and initramfs of their own. The build
checks the packed archive's contents and refuses a nats-server whose
version differs from the pin. The image does not start the store and
nothing installs or releases it; the LB image is unchanged.

* fix: publish the SQS store image only after its gates pass

Stage the kernel and initramfs and move them into place only once the
content, size and guest-RAM gates pass, so a failed build cannot leave a
pair make takes as up to date. The old initramfs is removed first and the
new one lands last, so an interrupted publish never leaves a mixed pair.
Check the module list without piping into grep -q, which under pipefail
reported a present module as missing.

* feat: start the SQS store guest on its checked data disk

The SQS store image now prepares, runs and stops a dedicated JetStream
server. It reads a narrow fw_cfg contract (data disk serial, listen
address, one user NKey public key), refuses anything absent, malformed
or ambiguous, has the pinned server test the config, then checks and
mounts exactly one matching ext4 disk. It never formats and has no
ephemeral fallback. The server listens only on the supplied guest NIC
address, admits only that NKey and syncs every write.

Shutdown stops the recorded run process first, whether it is the server
or a start not yet exec'd, and runs the generic read-only remount only
once it is gone. A store that survives SIGKILL leaves every mount alone.

* fix: report the SQS store as prepared, not listening, before it starts

* feat: launch the SQS store guest on its own versioned subject

An explicit SQS store kind carries an existing system-account data volume
and the one NATS user public key the store accepts. It is served only on
system.LaunchSQSStore.v1, so a daemon without this code has no responder
and the launch fails instead of booting a load balancer without its disk;
the legacy launch path refuses the kind on both send and receive.

Every refusal happens before capacity, an ENI or a VM record exists. The
volume goes through the normal EBS mount and terminate detach and is
never deleted on termination. The store boots its own image with CPU
mitigations on, gets only its network, disk serial, listen address and
key, and cannot be relaunched after a host restart yet.

* feat: ship the SQS store microVM image in releases and installs

Release builds now build the SQS store image and stage it beside the load
balancer's as microvm-sqs-store/, so an older installer that copies
microvm/* without -r still works. setup.sh installs it to
/usr/share/spinifex/microvm/sqs-store/, where the daemon looks for it.

A release without a complete image never leaves an older one usable:
staging drops a previously staged image, and the installer removes an
earlier installed pair before warning (missing) or failing (incomplete).
Only the two image files are removed. The initramfs is installed last, so
an interrupted install leaves no bootable mismatched pair.

* feat: restart the SQS store guest on its launching node

Persist the non-secret guest config of an SQS store instance (launching
node, data volume, listen address, client public NKey and rendered
network config) in the instance record, and rebuild its fw_cfg files
from it on relaunch. The relaunch refuses on any other node, or when the
record is missing or malformed, before writing any file; the data volume
is remounted through the normal EBS path and kept on terminate.

Cross-node recovery now never selects or claims an SQS store record, so
no other node spends retry budget on it or relaunches it. Same-node
restore is unchanged, as are load balancer restarts. Older daemons know
neither the exclusion nor the record field, so this does not prevent a
cross-node relaunch by a mixed-version cluster.

* feat: hold prepared system volumes in creating until released

Add an internal CreateVolumeForPreparation path that writes a new
volume's first record as creating, and CompleteVolumePreparation to
release an unattached creating volume in the caller's account to
available. Ordinary CreateVolume is unchanged.

Attach and delete already refuse a creating volume. ModifyVolume,
ForceDetachVolume and CreateSnapshot now refuse it with IncorrectState
so nothing can expand, release or capture a volume mid-preparation.

* feat: prepare fresh SQS store volumes with an ext4 filesystem

The SQS store guest never formats a disk, so a new volume gets its
filesystem on the host. The preparer checks for mkfs.ext4 and qemu-img,
builds an ext4 image in private scratch, creates the volume in
"creating", publishes it on this node, copies the image with the NBD
import helper, unpublishes, and only then releases it as available.

It never writes a volume it did not just create. A volume is deleted
only when no export can still be live: after a confirmed unpublish, or
when the export was not NBD. Any publish error, a failed or ambiguous
unpublish, or a failed release retains the volume and reports its ID.
A publish refused as in-use or already-exists sends no unpublish, since
another export may exist. Cleanup ignores caller cancellation but is
bounded at 30s.

The raw-image copy moves to runtime/compute/nbd unchanged, and the
domain receives it as an injected writer. The volume service gains a
discard path for an unattached volume still in "creating".

* fix: report unknown state and match qemu-img lookup in volume prep

A failed release may still have made the volume available, so the
retained-volume error now says its state is unknown rather than
claiming it is still creating.

The copy runs qemu-img by name through PATH, so the pre-allocation
check now uses a PATH lookup for it too. mkfs.ext4 keeps the sbin
fallback because it runs from the resolved path.

* docs: describe the unwired SQS store system instance

Records what the guest image, versioned launch, same-node restart and
fresh-volume preparation provide, that nothing calls them, and what is
untested or missing before production use.
2026-10-30 08:16:43 +10:00
Ben Duncan 3617e4a045 fix: log an expected outcome at its own level, not ERROR (#1342)
A dispatch failure was logged at ERROR whatever the caller was about to
be given, so DryRunOperation, which AWS documents as the success answer
to a dry run, read as a fault of ours along with every NotFound and
malformed parameter. The level now comes from the status the caller
receives, resolved the way ErrorHandler resolves it.

QEMU announces its own exit on stderr, so a guest stopping on the
SIGTERM the daemon sent it was logged at ERROR too.
2026-10-29 14:38:41 -05:00
Josh Siviour 24281cb860 fix: count volume lease validity from the write, not its reply (#1340)
* fix: count volume lease validity from the write, not its reply

The server starts a lease entry's TTL when it applies the write, but the
holder started its validity window when the acknowledgement arrived, so a
slow reply stretched validity past the server's expiry and a peer could
acquire the volume while the holder still considered it valid.

Validity now counts from when each create, generation publish and renewal
was sent. An acquisition acknowledged after validity lapsed is refused as
retryable, and a lost or lapsed lease still awaiting its fence is no
longer shared with another open on the same node. A renewal that lands
after the lease was given up, or after its validity elapsed, cannot revive
it: the lapse check and the update run under the lease lock, and fencing
runs once. The renew loop also fences at the validity deadline itself
rather than at the next check, which could consume the whole margin.

This bounds local validity only; it is not backend-enforced fencing, and a
paused host can still write after its validity ends.

* docs: describe volume lease validity, fencing and their limits
2026-10-29 21:38:22 +10:00
Josh Siviour e58838bc67 refactor: verify SigV4 credentials through an ingress capability (#1339)
* refactor(gateway): verify SigV4 credentials behind a CredentialVerifier

The authenticator no longer imports the IAM and STS domains. It hands the
signature check to a verifier as a callback, so the secret never leaves the
adapter, and runs the account-active check between Authenticate and Resolve.
A nil verifier fails every request closed.

The adapter lives in runtime/roles/awsgw/credverify. ResolveCallerUser and the
principal-type constants move from domains/sts/awsapi to domains/sts so the
adapter can use them without importing an awsapi package.

* fix(gateway): guard a nil credential verifier and tighten its tests

A typed-nil credverify.Verifier now fails closed instead of panicking.
The session verdict test goes through the real verifier into the lockout boundary.
Test setups build the verifier from the same mock as the gateway services.

* test(gateway): commit the verifier test helper
2026-10-29 21:30:06 +10:00
Josh Siviour f0e4ffe70c refactor: give seam services the verified caller's identity facts (#1338)
* test: pin the caller facts the gateway gives a registered service per principal kind

* refactor(gateway): seal the verified caller into one request-context value

* feat(dispatch): give registered services the caller's principal ARN, user ID, user name and session name

Actor gains PrincipalARN, UserID, UserName and SessionName, filled from the
sealed principal, and RoleName(), which keeps the account-checked role ARN
rule in one place. No consumer reads them yet.

* refactor(gateway): read the caller from dispatch.Actor in the RDS, EKS, STS, IAM and admin handlers

callerActor builds the Actor the seam hands services, and the seven readers that
took fields off the sealed principal now take them from it. RDS and EKS take the
role name from Actor.RoleName(). No behaviour change.
2026-10-29 16:13:41 +10:00
Josh Siviour 18adea9486 refactor: register the spinifex operator service through the ingress seam (#1337)
* test: characterize the spinifex Query and /admin surfaces through the full gateway pipeline

* refactor: register the spinifex Query service from operator/admin

* docs: point the spinifex registration migration row at the PR
2026-10-29 14:55:50 +10:00
Julian Sommer f06def6894 chore: update operation count 2026-10-29 13:50:59 +10:00
Julian Sommer ef7d30578f chore(awsmodel): sync AWS models to api-models-aws e10d6a1c (2026-10-28)
Seven models changed and add 26 unimplemented operations. The request sweep gains 33 requests with no new findings.
2026-10-29 13:35:39 +10:00
Julian Sommer b76679e571 fix(integration): restore ELBv2 to the request conformance sweep
The ELBv2 move to the ingress seam added its inventory to the coverage tool but not to TestRequestConformance, so 36 operations and 45 findings dropped out while the suite passed. A served service with no implemented operations now fails the sweep.
2026-10-29 13:34:12 +10:00
Josh Siviour d7d922e963 refactor: register Tagging and ELBv2 through the ingress seam (#1336)
* test: characterize Tagging dispatch, authorization and GetResources responses through the gateway pipeline

* refactor: register Resource Groups Tagging through the ingress seam

* test: characterize ELBv2 through the full gateway pipeline

* refactor: register ELBv2 through the ingress seam

* test: cover the ELBv2 registration, query parser and load balancer limit

* test: characterize RDS through the full gateway pipeline

* docs: point the Tagging and ELBv2 migration rows at the PR

* test: register Tagging and ELBv2 on the integration harness gateway
2026-10-29 13:27:43 +10:00
Julian Sommer 64e3711893 fix(awsmodel): accept InvalidGatewayID.NotFound in the EC2 error catalog
AWS's EC2 error reference documents it, and DeleteEgressOnlyInternetGateway and ReplaceRoute answer it, so the integration suite reported two false violations.
2026-10-29 13:27:09 +10:00
Josh Siviour ad9568a6c6 refactor: move gateway/spx, admin wire types and EKS OIDC discovery out of gateway (#1334)
* refactor: move gateway/spx to operator/admin

* test: pin the admin wire types and method list in golden JSON

* refactor: move the admin wire types and method list to contracts/operator/v1

* refactor: serve EKS OIDC discovery and JWKS from the EKS domain

* refactor: assert the EKS OIDC publisher satisfies the gateway interface

* docs: cite the pull request in the gateway root-move rows
2026-10-29 12:22:16 +10:00
Josh Siviour dedb3d8d75 ci: keep the E2E WAN packet captures only for runs that did not pass (#1335)
The captures are about 90% of each E2E artifact and nothing reads them unless
a run failed, so a clean single-node or multi-node pass drops them before the
artifact upload.
2026-10-29 12:21:30 +10:00
Julian Sommer cc1186fa48 fix: grant the build user passwordless sudo for the appliance build when it lacks it, and remove the grant at seal 2026-10-29 11:10:51 +10:00
Julian Sommer dbdb827a69 fix: install tar on a minimal Oracle Linux build system before copying the appliance payload 2026-10-29 11:05:35 +10:00
Josh Siviour c94b0f22f6 feat: accept EnaSupport on RegisterImage, report it on instances, and name refused parameters (#1332)
* feat: accept EnaSupport on RegisterImage and name the refused parameter in its errors

EnaSupport true and false are stored on the image record, returned by DescribeImages when set and carried through CopyImage. Every validation error in ValidateRegisterImageInput keeps its code and now says which parameter and value it refused.

* feat: set EnaSupport on images created from an instance

AWS takes an image's EnaSupport from the instance it was made from, and every instance here reports it, so the source AMI's value is not inherited.

* docs: record RegisterImage EnaSupport support and the refused parameters

* fix: report EnaSupport on DescribeInstances and RunInstances
2026-10-29 10:53:30 +10:00
Julian Sommer 71567d0998 fix: show the appliance password rules before the first-login change 2026-10-29 10:51:06 +10:00
Josh Siviour 11e8b68ddc refactor: remove the unused host SQS message store service (#1333)
* refactor: remove the host SQS store systemd unit

The SQS message store will run inside system-owned instances rather than
as a host daemon, so spinifex.target no longer starts it. Bump the target
to version 4 and drop the unit from the embedded set and its invariants.

* refactor: remove host SQS store config provisioning

The SQS store will run in system-owned instances, so admin init and join
no longer generate or distribute a host store token, routes or config,
and the formation join payload drops the store token field.

* refactor: remove host SQS store service command and role

The SQS store will run in system-owned instances, so drop the unused
spx service sqs-store command, its service registration and the host
sqsstore role. The domains/sqs/message JetStream store is unaffected.

* refactor: remove host SQS store provisioning from install scripts

The SQS store will run in system-owned instances, so setup no longer
creates the spinifex-sqsstore user, its directories or the 4223/4249
peer firewall ports, and install, reset and uninstall stop handling the
retired unit, user and data directory.

* docs: drop the host SQS store from firewall and connection tables

Spinifex no longer ships a host SQS store service, so remove its ports
from the host firewall and network connection references and say in
DESIGN.md that no host service, unit, user or firewall rule exists for it.
2026-10-29 10:48:05 +10:00
Julian Sommer 8f4754da13 fix: install the appliance with the setup.sh from the release tarball, since install.mulgadc.com serves the stable one 2026-10-29 10:30:48 +10:00
Julian Sommer 8b965d24ce fix: refuse Route 53 requests that break the model's bounds with InvalidInput (#1329) 2026-10-29 11:29:45 +11:00
Julian Sommer ac2620df58 fix: report an SSH failure in build-oracle-appliance.sh as one, not as missing sudo 2026-10-29 10:26:09 +10:00
Julian Sommer 2feb264863 feat: Oracle Linux multi-node clusters with OVN IPsec (#1327) 2026-10-29 11:17:22 +11:00
Josh Siviour ddadfa2812 chore: remove unused e2e suite-selection manifest and drift lints (#1331)
The targeted suite selector (select-suites) has not run in CI since its shadow-mode step was removed in #556.
The service-interfaces manifest, manifest-check and manifest-lint existed only to feed it, so they go too.
Also drops the now-meaningless e2e:allow-create markers, keeping their rationale as plain comments.
2026-10-29 10:04:31 +10:00
Josh Siviour 5923143062 feat: set X-Forwarded-For, -Proto and -Port on ALB requests (#1330)
* feat: render X-Forwarded-For, -Proto and -Port headers in ALB HAProxy frontends

Append joins every client X-Forwarded-For line and adds the client address as AWS does, preserve and remove follow the load balancer attribute, and Proto and Port are always overwritten.

* feat: validate the ALB forwarding attributes and re-render config when they change

ModifyLoadBalancerAttributes rejects bad xff_header_processing.mode and xff_client_port.enabled values with ValidationError before storing anything, and regenerates the stored config when either key changes.

* test: assert the ALB X-Forwarded headers and the remove mode in the lb e2e

The app instances echo the request headers on /__headers. The internal ALB is driven from the probe client and the HTTPS ALB from the runner, covering the caller address, a client value, spoofed Proto and Port, mode remove and a rejected mode.

* test: let the lb probe client trigger accept a null header list

* docs: document the ALB forwarding headers and their attributes
2026-10-29 09:33:39 +10:00
Julian Sommer 46ca3dfba1 chore: comment 2026-10-29 09:13:32 +10:00
Julian Sommer 596b5b1733 fix: refuse DeleteVpc while an egress-only internet gateway is attached (#1325) 2026-10-29 09:53:48 +11:00
Josh Siviour 1c5eaaf852 fix: use canonical OCI header names in the ECR registry (#1328) 2026-10-29 08:53:39 +10:00
Julian Sommer 49117cf7b0 fix: return InvalidIPAddress.InUse when releasing an associated elastic IP (#1326) 2026-10-29 09:53:31 +11:00
Julian Sommer 3a9985c79d fix: return ResourceNotFoundException from EKS DeleteCluster for a nonexistent cluster (#1324) 2026-10-29 09:53:16 +11:00
Josh Siviour c42a352064 feat: add store-neutral SQS message store with a JetStream adapter (#1323)
* feat: add the store-neutral SQS message store contract and conformance suite

Defines message.Store over opaque shard and queue ID namespaces with no
create call, plus a reusable conformance runner exercised against a
test-only in-memory reference store.

* feat: add the SQS message store's JetStream layout, append and state CAS

Provisions the fixed set of shared message streams and state buckets,
publishes each queue on sqs.m.<shard>.<queue>, dedupes idempotent appends
with a queue-scoped Nats-Msg-Id, and maps state revision CAS onto KV.

* fix: give each SQS queue immutable message and state shard allocations

A changed stream or bucket count applies only to new queues: the namespace
names its message shard and state shard directly, retained streams and
buckets stay addressable, and the store refuses cluster sizes other than
one node (R1) or three (R3).

* fix: enumerate complete SQS namespaces and backstop state buckets

Enumeration now returns each namespace with both allocations, so a
state-only namespace can be counted and cleaned without its queue record,
and state buckets expire records after 14 days plus 1 hour.

* feat: add the SQS JetStream store's reads, counts and cleanup

Get and Delete are scoped to the namespace's subject, DeleteThrough and
DeleteNamespace are subject-filtered purges that leave shard neighbours
intact, and Count reads the per-subject message total and live state keys.

* fix: count distinct SQS state keys and validate before namespace purge

The key lister can repeat a key under concurrent writes, so Count tallies
distinct names; DeleteNamespace resolves both the message stream and the
state bucket before purging either, so a wrong state shard deletes nothing.

* feat: add the SQS JetStream store's ordered message-shard feed

Append records the namespace's state shard in an internal header that is
never returned as metadata. Feed reads one shared message stream through
an ephemeral, headers-only ordered consumer with no acknowledgement state,
rebuilds each change's complete namespace, refuses a malformed header with
ErrCorruptRecord, and deletes its consumer on Close.

* feat: enumerate SQS namespaces and run conformance on the JetStream store

Namespaces joins per-subject body counts, whose internal header names the
state shard, with live state keys from every state bucket that exists,
found by listing so a historical bucket counts and none is created. An
allocation conflict is reported as ErrCorruptRecord. The store now
implements message.Store and runs the conformance suite on R1, per case
with crash reopen and on one shared instance.

* fix: check every SQS body's state shard when enumerating namespaces

Sampling the first and last body let a middle body naming another state
shard pass. Namespaces now reads every body's header in one headers-only
ordered pass over the shard's stream, counting each queue's bodies from
that pass, and deletes its consumer when done.

* test: run SQS store conformance on R3 and guard against consumer state

TestR3Conformance runs the conformance suite on a real three-node
JetStream cluster in process, with Reopen restarting every node over the
same data, and a check that every stream and state bucket is R3.
TestS5_NoConsumerDeliveryStateInSQS fails on any acknowledgement,
redelivery, durable-consumer or ack-retention mechanism in SQS source.

* test: bar legacy NATS acknowledgement helpers from SQS source

Adds AckSync, ManualAck, AckAll and AckExplicit to the ADR-0011:S5
consumer-state guard.

* feat: add a bounded SQS store scan and the tombstoned-body sweeper

Store gains Scan: a paginated, headers-only pass over a message shard,
bounded at the shard's last position when it starts, skipping deleted
positions and never returning a later append. The conformance suite and
fake cover continuation, deleted runs and the bound.

The JetStream adapter reads every bounded range (scan, body enumeration
and state keys) through one reader whose completion rests on a direct get
of the next match, not on consumer state; the client's key lister and
pending counts are no longer trusted to end a pass.

message.Sweep walks a shard with Scan and, for each body whose record the
domain reports terminal, deletes the body then the record by revision.

* test: add an opt-in SQS store conformance run on an external R3 cluster

TestR3ExternalConformance runs the conformance suite against the
dedicated three-node SQS JetStream cluster named by SQS_STORE_R3_URLS,
checks every stream is R3 with two peers, and uses SQS_STORE_R3_RESTART
to restart every node for the crash cases. It skips when unset.

* test: run the SQS sweeper against the reference store fake

Covers live records kept, tombstones swept, another shard untouched, a
no-op rerun, and a retry after the body delete succeeds and the state
delete fails.

* test: harden the SQS store R3 harnesses against restart and placement races

The external R3 harness reused one connection across restarts, so a case's
cleanup closed it for every later case; each case and restart now opens its
own connection and waits for stream leaders.

The in-process cluster released its free ports before the servers bound them,
and R3 placement can fail until the meta leader has every peer's config and
stats. Client ports are now server-chosen, route ports are reserved together,
and provisioning retries the idempotent New until placement succeeds.

* fix: stop the SQS store feed idling for a whole pull expiry

Under load an ordered feed on a three-node cluster sat for nats.go's 30s
default pull expiry, once 60s, with stored changes pending and no pull
waiting on its consumer, both on feeds opened after a full restart and on
feeds kept open across one. Feed now sets a 2s pull expiry.

Adds restart tests for a feed opened after a full-cluster restart and one
open across it, each replaying a shared-shard backlog then a live append and
failing on any 5s gap. The in-process cluster keeps client ports across
restarts so open connections reconnect, and can write node logs.

* fix: read SQS message state from the stream leader

GetState used nats.go's KV Get, which switches to a direct get whenever
the bucket allows it. On a replicated bucket a follower can answer that
from state it has not applied yet, so a record the leader had already
deleted or purged could still be returned.

Read the key's last message with a stream message get instead, which
only the stream leader answers, and apply KV Get's delete and purge
marker rules to the result. Bucket configuration is unchanged. Missing,
deleted and purged records still return ErrNotFound; values, revisions,
context errors and the API prefix or domain of the caller's JetStream
context are preserved.

* docs: narrow the SQS GetState leader-read comment to what it avoids

* fix: enumerate SQS state keys from the stream leader

Count and Namespaces found live state keys with a direct-get probe and a
headers-only ordered consumer on the state bucket's stream. On a
replicated bucket a follower can answer either from state it has not
applied, so keys the leader had already deleted could still be counted.

Walk the key prefix with stream message gets by next subject, which
only the stream leader answers, through the stream's last sequence at
the call. Delete and purge markers drop a key, as GetState reads them.
This costs one leader request per record under the prefix. Bucket
configuration, historical state shards, the message-body scans and the
feed are unchanged.

* test: keep SQS API recorder deliveries in arrival order

The recorder fed API subjects and its sentinel to two async
subscriptions, which nats.go delivers on separate goroutines, so drain
could return before the last request was recorded. Both now share one
channel that the connection fills in arrival order.

* fix: read SQS body enumerations from the stream leader

Namespaces and Scan read bodies through an ephemeral ordered consumer,
which the server may place on a follower that has not applied a purge,
so a deleted queue could still be listed or scanned. Each stored match
through the bound is now a leader stream message get. That transfers
every full body, where the consumer read headers only.

* test: stop the SQS API recorder goroutine with its test

The recorder ranged over a caller-owned ChanSubscribe channel, which
nats.go never closes, so its goroutine outlived every test. Cleanup now
unsubscribes both subscriptions, then signals the goroutine and waits
for it to return; the sentinel send also watches that signal.

* fix: recover a stalled SQS feed from its cursor

An ordered feed was seen to idle with stored changes pending after a
cluster restart. Next now waits at most an idle check on the consumer,
then asks the stream leader whether a change follows the cursor; if one
does, the consumer is deleted and reopened just after the cursor, so no
change is skipped or repeated. The root cause of the stall is unknown.

* fix: make closing an SQS feed terminal and safe against Next

Close now marks the feed closed under a lock, cancels any in-flight
Next, stops the iterator and deletes the consumer. A later or in-flight
Next returns ErrFeedClosed and never opens a consumer; one opened by a
recovery racing Close is deleted rather than adopted. Repeated Close
returns nil.

* fix: define SQS feed close in the store contract

message.Feed now documents one Next reader with Close callable at any
time and more than once, and message.ErrFeedClosed replaces the
adapter's own error. Once Close has begun, Next returns ErrFeedClosed
and withholds any change it had received; a feed from the last cursor
still delivers it. Shared conformance cases and the reference fake
enforce this.

The JetStream feed's Close also waits, within a bound, for a consumer
open already in progress, so a consumer created during Close is deleted
before Close returns nil; past the bound, or if that delete fails, Close
returns an error and a repeated Close waits again.

* fix: track SQS feed consumer cleanup until Close succeeds

Every consumer open and release is now tracked work recorded under the
lock that takes the consumer, and a delete that fails is kept for Close
to retry. Close returns nil only once no such work is in progress and no
failed delete remains, waiting within a bound and otherwise returning an
error; concurrent and repeated Close calls wait the same way.

Next claims a change under that lock and advances its cursor there, so a
change is either returned before Close begins or withheld for a feed
resumed from the last cursor.

A consumer create no longer inherits the caller's cancellation, which
was seen to leave most cancelled creates on the server with no owner;
it has its own timeout, and the name of one that fails is deleted and
kept for Close to delete again.

* fix: release SQS feed consumers opened after the caller's context ends

Feed and recovery now check the caller's context before starting a
consumer open and after it completes. A create that finishes after the
context ended is released as tracked work and the context's error is
returned, or ErrFeedClosed when Close won; no change is returned.

The feed contract and adapter docs now describe cleanup as complete for
consumers the feed knows of, with the server's one-minute inactive
threshold removing one an ambiguous create lands after its last delete.

* fix: report cancellation when an SQS feed open fails after it

A first consumer open that fails after the caller's context ended now
returns the context's error joined with the failure, so cancellation
stays detectable. The feed contract's cancellation text is narrowed to
opening and reopening, whose cleanup is best effort.

* docs: describe the internal SQS message store and its limits

DESIGN.md gains a section on the store-neutral SQS message store, its
JetStream adapter and conformance suite: an internal primitive with no
service wired to it, its shared stream and bucket layout, leader-directed
reads and their full-body cost, feed recovery and its best-effort
consumer cleanup, and the absence of end-to-end or multi-host
validation. The Scan contract says metadata only, not headers only.
2026-10-29 08:43:00 +10:00
Josh Siviour 61686f2530 test: run the LB health suites serially after the parallel internal group on multi-node (#1320) 2026-10-29 07:53:49 +10:00
Josh Siviour d5f4d48956 feat: serve the OCI referrers API for ECR repositories (#1319)
* feat: record manifest subject and artifactType and return OCI-Subject on push

* fix: resolve the manifest media type once so a parameterised Content-Type cannot misclassify an index

* feat: index referrers per subject and serve them through the metadata service

* feat: serve the OCI referrers API for ECR repositories

* test: cover the ECR referrers route in the gateway authorization matrices

* feat: delete a subject image's referrers with it

* fix: satisfy nilerr in the referrers manifest parser

* fix: return the manifest parse error and format the referrers code

* docs: describe the ECR OCI referrers API and cosign support

* docs: name oras cp and crane copy as the way to carry v3 signatures to an ECR mirror

* docs: present oras cp and crane copy as one remedy for copied v3 signatures
2026-10-28 22:52:47 +10:00
Josh Siviour acfa078586 fix: take an EKS control plane out of rotation when its gateway is down (#1318)
* feat: add a gateway readiness endpoint to the EKS token webhook

* feat: serve token webhook readiness beyond loopback and admit it to the control-plane SG

* feat: health-check the EKS apiserver target group on the token webhook readiness port

* style: order the strconv import

* fix: export the readiness listener address to the EKS token webhook

* docs: regenerate the ELB coverage README

* docs: describe EKS control plane readiness and what happens when a gateway stops

* test: range over SplitSeq in the webhook initd guard
2026-10-28 21:12:29 +10:00
Josh Siviour 17dd3f325b fix: stop routing to unhealthy load balancer targets and apply health-check changes (#1317)
* feat: add routableTargets helper that skips unhealthy targets and fails open

* fix: drop unhealthy targets from the NLB nginx upstream, failing open when none are healthy

* fix: re-render load balancer config when a target health state changes

* fix: write load balancer config and heartbeat fields under CAS so a re-render is never rolled back

* fix: write live load balancer modifications under CAS so they cannot roll back a re-rendered config

* fix: let ALB backends fail open to unchecked backup servers when every target is down

* test: cover NLB unhealthy-target routing and ALB fail open in the lb e2e suite

* test: flip ALB backend health per instance and log how long each health phase takes

* style: gofmt haproxy backend struct and the attributes fetch table

* fix: re-render load balancer config when a target group's health check changes

* fix: return the health-target marshal error instead of discarding it

* test: mark the health-check target group create as an intentional create-path test

* docs: describe target health, fail open and time to effect in the ELBv2 guide
2026-10-28 19:54:49 +10:00
Josh Siviour d2b02414b5 feat: direct-boot microvm data volumes and refused hot-attach (#1316)
* feat: render a data volume as an MMIO virtio-blk-device

A package-private helper reuses the PCI volume device's id, drive,
iothread, serial and stop-on-error options, without a PCI bus.

* feat: cold-boot microvm data volumes on MMIO without a PCI hot-plug port

microvm has no PCIe root ports, so its data volumes render as
virtio-blk-device and take no hot-plug port; a recorded port is kept.
NBD and host-block exports and q35 PCI allocation are unchanged.

* feat: compose a launch-only microvm config with EBS data volumes

directBootLaunchConfig copies a clean direct-boot base and appends the
mounted data volumes after its devices, rejecting boot and EFI volumes
and non-microvm bases. Neither input is modified, so repeated launches
never accumulate entries or keep a stale endpoint.

* feat: launch direct-boot microvms with mounted data volumes from a launch-only config

startQEMU composes the direct-boot command from the saved base and one
snapshot of the mounted requests, which also feeds the readiness probes,
so the launched endpoint is the one checked and is never saved.

* fix: refuse volume hot-attach on direct-boot microvms before any mount

A microvm's MMIO bus has no PCIe root port to hot-plug into, so
AttachVolume returns ErrHotAttachUnsupported before mounting the volume
or changing instance or volume state.

* fix: return UnsupportedOperation for microvm volume hot-attach

AttachVolume's ErrHotAttachUnsupported is a caller-fixable refusal, so
the attach/detach error boundary maps it to a 400 UnsupportedOperation
instead of a generic server error.

* docs: describe direct-boot microvm data volumes and refused hot-attach
2026-10-28 19:45:47 +10:00
Julian Sommer af3fe610f9 refactor: enable eslint no-use-before-define in spinifexui
Enables the rule with functions: false, since hoisted declarations are safe, and defines CONDITION_FIELD_TEXT and the handoff message listener before their first use.
2026-10-28 15:30:07 +10:00
Julian Sommer c8092975c2 refactor: enable eslint complexity in spinifexui and split the components that exceeded it (#1315)
Turns on oxlint's eslint/complexity rule (max 20) and brings the 18 offending functions under the limit by extracting helpers, hooks and subcomponents with no behaviour change.
Shares the RDS subnet and parameter group option builders through rds-form-fields, and rebuilds dist.
2026-10-28 16:18:57 +11:00
Josh Siviour 49a4a07e00 fix: trust every gateway's ECR registry host on EKS workers (#1314)
* refactor: share the ECR registry address precedence in domains/ecr

* feat: expose every gateway's ECR registry host to the EKS service

* fix: skip wildcard peer hosts when listing ECR registry hosts

* feat: trust every gateway's ECR registry host on EKS workers

* docs: describe how EKS workers trust every gateway's ECR registry host

* docs: split the ECR gateway limits to one sentence per line

* refactor: format the registry URI host in domains/ecr so the daemon avoids the awsapi adapter

* docs: state that a refused gateway fails over at once and record the 3-node ECR measurements
2026-10-28 14:28:12 +10:00
Julian Sommer 02fd49be7e fix: block DeleteSubnet when an ENI record in the account cannot be decoded (#1313) 2026-10-28 14:14:25 +11:00
Josh Siviour 2aac488fa7 fix: stop TCP stalling through the VPC gateway by setting gateway MTU and clamping MSS on the host hop (#1312)
* fix: add GatewayMTU capping the gateway MTU at the internet path MTU

* fix: set gateway_mtu on the VPC gateway router port so oversized packets get ICMP frag-needed

* fix: wire the gateway MTU into vpcd and cover reconcile convergence

* feat: add host MSS clamp tables for the veth and routed uplinks

* fix: shorten MSS clamp comments and log the periodic ensure at debug

* feat: run the host MSS clamp loop in vpcd

* fix: run nft under the ambient CAP_NET_ADMIN instead of sudo

* docs: describe the gateway MTU and the host MSS clamp for the internet path
2026-10-28 12:01:50 +10:00
623 changed files with 37005 additions and 13345 deletions
+22
View File
@@ -223,5 +223,27 @@
"runner": "ci-single",
"extra": "nat-single",
"suite": ""
},
{
"cell": 37,
"install": "binary",
"topo": "real-multi",
"net": "dhcp",
"host": "oracle-10",
"arch": "x86_64",
"runner": "ci-multi",
"extra": "",
"suite": ""
},
{
"cell": 38,
"install": "binary",
"topo": "real-multi",
"net": "nat",
"host": "oracle-10",
"arch": "x86_64",
"runner": "ci-multi",
"extra": "nat-multi",
"suite": ""
}
]
+2 -2
View File
@@ -102,9 +102,9 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
- name: Build microVM artifacts (lb-agent + kernel + initramfs + qboot)
- name: Build microVM artifacts (lb-agent + kernel + initramfs + qboot + SQS store image)
if: steps.version.outputs.exists != 'true'
run: cd spinifex && make build-microvm-image
run: cd spinifex && make build-microvm-image build-sqs-store-microvm-image
- name: Build amd64 Tarball
if: steps.version.outputs.exists != 'true'
+1 -1
View File
@@ -10,7 +10,7 @@ on:
workflow_dispatch:
inputs:
cells:
description: "Comma-separated cell numbers to run, no spaces (blank = all). 1-3, 8-10, 17-19 tofu permutation matrix, 34-36 Oracle Linux single node (basic, reboot, routed NAT), 20 baremetal, 21-22 ISO, 23 predastore throughput, 24 predastore fault injection, 25-27 service suites (eks, ecs, rds), 28 guest disk performance, 29 storage fault injection, 30 routed NAT on three nodes, 31 instance recovery on three nodes, 32 load balancer recovery on three nodes, 33 KV bucket quorum under node loss on three nodes"
description: "Comma-separated cell numbers to run, no spaces (blank = all). 1-3, 8-10, 17-19 tofu permutation matrix, 34-36 Oracle Linux single node (basic, reboot, routed NAT), 37-38 Oracle Linux on three nodes (multi-node subset with IPsec, routed NAT), 20 baremetal, 21-22 ISO, 23 predastore throughput, 24 predastore fault injection, 25-27 service suites (eks, ecs, rds), 28 guest disk performance, 29 storage fault injection, 30 routed NAT on three nodes, 31 instance recovery on three nodes, 32 load balancer recovery on three nodes, 33 KV bucket quorum under node loss on three nodes"
required: false
permissions:
+14
View File
@@ -536,6 +536,13 @@ jobs:
log-dir: ${{ env.ARTIFACT_DIR }}
title: "E2E failure analysis"
# The WAN capture is most of the artifact and only matters when a run
# failed. Anything short of a clean pass (suite rc, a failed setup or
# collect step, a missing rc) keeps it.
- name: Drop the packet capture from a passing single-node run
if: always() && steps.e2e.outputs.rc == '0' && job.status == 'success'
run: rm -f "${ARTIFACT_DIR}"/net-diag/wan.pcap
- uses: actions/upload-artifact@v7.0.2
if: always()
with:
@@ -990,6 +997,13 @@ jobs:
log-dir: ${{ env.ARTIFACT_DIR }}
title: "Multi-Node E2E failure analysis"
# The WAN captures are 90% of the artifact and only matter when a run
# failed. Anything short of a clean pass (suite rc, a failed setup or
# collect step, a missing rc) keeps them.
- name: Drop the packet captures from a passing multi-node run
if: always() && steps.e2e.outputs.rc == '0' && job.status == 'success'
run: rm -f "${ARTIFACT_DIR}"/net-diag-node*/wan.pcap
- uses: actions/upload-artifact@v7.0.2
if: always()
with:
+2 -2
View File
@@ -57,8 +57,8 @@ jobs:
go-version-file: spinifex/go.mod
cache: false
- name: Build microVM artifacts (lb-agent + kernel + initramfs + qboot)
run: cd spinifex && make build-microvm-image
- name: Build microVM artifacts (lb-agent + kernel + initramfs + qboot + SQS store image)
run: cd spinifex && make build-microvm-image build-sqs-store-microvm-image
- name: Build amd64 Tarball
env:
-3
View File
@@ -119,9 +119,6 @@ jobs:
- name: Build Spinifex
run: make -C spinifex build
- name: Manifest check + drift lint
run: make -C spinifex manifest-check manifest-lint
- name: Run Tests with Coverage
env:
SPINIFEX_REQUIRE_CONFORMANCE_TOOLS: "1"
+3
View File
@@ -21,6 +21,9 @@ build/microvm/vmlinuz
build/microvm/initramfs.cpio.gz
build/microvm/qboot.rom
build/microvm/qboot.LICENSE
build/microvm/sqs-store/vmlinuz
build/microvm/sqs-store/initramfs.cpio.gz
build/microvm/sqs-store/.stage.*/
build/qboot/
!spinifex/runtime/roles/spinifexui/frontend/dist/
tmp/
+31 -24
View File
@@ -140,6 +140,23 @@ $(MICROVM_ARTIFACTS) &: $(MICROVM_INPUTS)
bin/lb-agent:
$(MAKE) build-lb-agent
# The SQS store microVM image: a separate artifact from the LB image above, not
# installed or released by any target yet.
SQS_STORE_MICROVM_OUT_DIR := $(MICROVM_OUT_DIR)/sqs-store
SQS_STORE_MICROVM_ARTIFACTS := $(SQS_STORE_MICROVM_OUT_DIR)/vmlinuz $(SQS_STORE_MICROVM_OUT_DIR)/initramfs.cpio.gz
SQS_STORE_MICROVM_INPUTS := scripts/build-sqs-store-microvm-image.sh scripts/lib/sqs-store-microvm-publish.sh $(SQS_STORE_MICROVM_OUT_DIR)/init.sh $(SQS_STORE_MICROVM_OUT_DIR)/inittab $(addprefix $(SQS_STORE_MICROVM_OUT_DIR)/,sqs-store-lib.sh sqs-store-prepare sqs-store-run sqs-store-stop) bin/nats-server
$(SQS_STORE_MICROVM_ARTIFACTS) &: $(SQS_STORE_MICROVM_INPUTS)
./scripts/build-sqs-store-microvm-image.sh
# The dedicated SQS store server, built from the go.mod-pinned module so the
# image ships exactly the reviewed version. Static for the musl guest.
bin/nats-server: go.mod go.sum
@mkdir -p bin
GOWORK=off CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags '-s -w' -o $@ github.com/nats-io/nats-server/v2
build-sqs-store-microvm-image: $(SQS_STORE_MICROVM_ARTIFACTS) ## Build the SQS store microVM kernel and initramfs
# qboot is the microvm firmware. The source tarball ships with each release
# because qboot is GPL-2.0.
QBOOT_COMMIT := $(shell sed -n 's/^QBOOT_COMMIT="\(.*\)"$$/\1/p' scripts/build-qboot.sh)
@@ -151,6 +168,12 @@ $(QBOOT_ARTIFACTS) &: scripts/build-qboot.sh
build-microvm-image: $(MICROVM_ARTIFACTS) $(QBOOT_ARTIFACTS) ## Build microVM kernel, initramfs and qboot firmware (incremental — skips when up to date)
install-sqs-store-microvm: $(SQS_STORE_MICROVM_ARTIFACTS) ## Install the SQS store microVM image to /usr/share/spinifex/microvm/sqs-store/
sudo install -d /usr/share/spinifex/microvm/sqs-store
sudo rm -f /usr/share/spinifex/microvm/sqs-store/initramfs.cpio.gz
sudo install -m 0644 $(SQS_STORE_MICROVM_OUT_DIR)/vmlinuz /usr/share/spinifex/microvm/sqs-store/vmlinuz
sudo install -m 0644 $(SQS_STORE_MICROVM_OUT_DIR)/initramfs.cpio.gz /usr/share/spinifex/microvm/sqs-store/initramfs.cpio.gz
install-microvm: $(MICROVM_ARTIFACTS) $(QBOOT_ARTIFACTS) ## Install microVM artifacts to /usr/share/spinifex/microvm/
sudo install -d /usr/share/spinifex/microvm
sudo install -m 0644 $(MICROVM_OUT_DIR)/vmlinuz /usr/share/spinifex/microvm/vmlinuz
@@ -158,15 +181,14 @@ install-microvm: $(MICROVM_ARTIFACTS) $(QBOOT_ARTIFACTS) ## Install microVM arti
sudo install -m 0644 $(MICROVM_OUT_DIR)/qboot.rom /usr/share/spinifex/microvm/qboot.rom
sudo install -m 0644 $(MICROVM_OUT_DIR)/qboot.LICENSE /usr/share/spinifex/microvm/qboot.LICENSE
# the pre-commit gate: manifest checks, lint, vuln, and the unit and e2e-harness tiers.
# the pre-commit gate: lint, vuln, and the unit and e2e-harness tiers.
# integration and race tests skipped to keep quick, they run in CI.
#
# -j2 overlaps the only two heavy gates, lint and test-cover: alone each leaves
# most of the machine idle, so pairing them cuts a cold run by about a quarter.
# -Otarget keeps each gate's output in one block instead of interleaving them.
# manifest-check manifest-lint test-package-check removed, can add back later
preflight:
@$(MAKE) --no-print-directory -j2 -Otarget QUIET=1 lint govulncheck test-cover diff-coverage test-harness test-build-scripts manifest-check manifest-lint
@$(MAKE) --no-print-directory -j2 -Otarget QUIET=1 lint govulncheck test-cover diff-coverage test-harness test-build-scripts
@echo -e "\n ✅ Preflight passed — safe to commit."
# Shell suites + shellcheck for build/scripts/, the systemd-unit helpers that
@@ -178,7 +200,7 @@ preflight:
# reason: between them they install the software, wire OVN, erase the state and
# remove the install, so a shellcheck warning in one is an outage or a wrong
# deletion, not a style note.
NODE_SCRIPTS := scripts/setup.sh scripts/setup-ovn.sh scripts/install-node.sh scripts/smoke-test.sh scripts/node-reset.sh scripts/uninstall-spx.sh scripts/lib/distro.sh
NODE_SCRIPTS := scripts/setup.sh scripts/setup-ovn.sh scripts/install-node.sh scripts/smoke-test.sh scripts/node-reset.sh scripts/uninstall-spx.sh scripts/lib/distro.sh scripts/lib/stage-sqs-store-microvm.sh
test-build-scripts:
@echo -e "\n....Running build/scripts/**/*_test.sh...."
@@ -186,13 +208,14 @@ test-build-scripts:
echo "-- $$t"; \
sh "$$t" || exit 1; \
done
@echo -e "\n....Running scripts/*_test.sh and scripts/lib/*_test.sh...."
@for t in $$( (find scripts -maxdepth 1 -name '*_test.sh'; find scripts/lib -name '*_test.sh') | sort); do \
@echo -e "\n....Running scripts/*_test.sh, scripts/lib/*_test.sh and scripts/appliance/*_test.sh...."
@for t in $$( (find scripts -maxdepth 1 -name '*_test.sh'; find scripts/lib scripts/appliance -name '*_test.sh') | sort); do \
echo "-- $$t"; \
sh "$$t" || exit 1; \
done
@echo -e "\n....Running shellcheck over build/scripts/**/*.sh + the node scripts...."
shellcheck -S warning $$(find build/scripts -name '*.sh' | sort) $(NODE_SCRIPTS)
shellcheck -S warning -x scripts/build-oracle-appliance.sh $$(find scripts/appliance -name '*.sh' | sort)
@echo " test-build-scripts ok"
# E2E harness unit tests. Build-tagged `e2e` so they're skipped by the
@@ -239,23 +262,6 @@ test-segscan-oracle:
@echo -e "\n....Running segscan storage oracle test...."
$(_Q)LOG_IGNORE=1 go test -tags=integration,segscanoracle -timeout 120s ./tests/integration/... -run TestSegscanOracle $(_RACEQ)
# Validate docs/service-interfaces.yaml. Schema check + cross-reference
# of services/suites/fixtures + on-disk path existence.
manifest-check:
@echo -e "\n....Checking service-interfaces.yaml...."
@go run ./tests/e2e/manifest-check/cmd/manifest-check -repo-root . -manifest docs/service-interfaces.yaml
# Drift guards: direct-create fixture lint + NATS subject lint,
# ratcheted against tests/e2e/manifest-lint/baseline.txt. Fails only on NEW
# drift beyond the baseline.
manifest-lint:
@echo -e "\n....Linting manifest drift (fixtures + subjects)...."
@go run ./tests/e2e/manifest-lint/cmd/manifest-lint -repo-root .
# Accept current drift into the baseline. Run after an intentional change.
manifest-lint-update:
@go run ./tests/e2e/manifest-lint/cmd/manifest-lint -repo-root . -update
# Run unit tests
test:
@echo -e "\n....Running tests for $(GO_PROJECT_NAME)...."
@@ -468,6 +474,7 @@ distro-amd64:
echo "[distro-amd64] WARNING: microvm artifacts missing — tarball will not include them"; \
echo "[distro-amd64] run 'make build-microvm-image' before 'make distro-amd64'"; \
fi
./scripts/lib/stage-sqs-store-microvm.sh $(SQS_STORE_MICROVM_OUT_DIR) dist/amd64
tar -czf dist/spinifex-$(VERSION)-linux-amd64.tar.gz -C dist/amd64 .
sha256sum dist/spinifex-$(VERSION)-linux-amd64.tar.gz > dist/spinifex-$(VERSION)-linux-amd64.tar.gz.sha256
@@ -486,7 +493,7 @@ distro-arm64:
distro-clean:
rm -rf dist/
.PHONY: test-package-check build build-ui build-installer build-lb-agent build-ecs-agent build-system-image build-eks-node-image import-eks-node-image publish-eks-node-image build-ecs-node-image import-ecs-node-image build-rds-postgres-image import-rds-postgres-image build-rds-mariadb-image import-rds-mariadb-image build-microvm-image install-microvm go_build preflight test test-cover test-race diff-coverage bench fuzz test-actions test-images test-build-scripts test-harness test-integration generate-aws-model-coverage aws-model-coverage test-segscan-oracle manifest-check manifest-lint manifest-lint-update \
.PHONY: test-package-check build build-ui build-installer build-lb-agent build-ecs-agent build-system-image build-eks-node-image import-eks-node-image publish-eks-node-image build-ecs-node-image import-ecs-node-image build-rds-postgres-image import-rds-postgres-image build-rds-mariadb-image import-rds-mariadb-image build-microvm-image build-sqs-store-microvm-image install-microvm install-sqs-store-microvm go_build preflight test test-cover test-race diff-coverage bench fuzz test-actions test-images test-build-scripts test-harness test-integration generate-aws-model-coverage aws-model-coverage test-segscan-oracle \
deploy reinstall clean \
install-system install-go install-aws quickinstall \
lint fix govulncheck nilaway \
+3 -1
View File
@@ -54,7 +54,7 @@ For Terraform, start from the [example workbooks](https://docs.mulgadc.com/docs/
## Services
The platform serves **392 AWS API operations** across the services below. See exactly which ones in the [coverage report](https://docs.mulgadc.com/coverage).
The platform serves **405 AWS API operations** across the services below. See exactly which ones in the [coverage report](https://docs.mulgadc.com/coverage).
| Service | What it is | Built on | Status |
| --- | --- | --- | --- |
@@ -68,8 +68,10 @@ The platform serves **392 AWS API operations** across the services below. See ex
| **ECR** | Container registry | Predastore, deduplicated per account | Available |
| **ECS** | Container service | Spinifex instances | Available |
| **RDS** | Databases | PostgreSQL and MariaDB, with automated backups | Available |
| **Route 53** | DNS | [Northstar](https://github.com/mulgadc/northstar): authoritative DNS with hosted zones | Available |
| **Bedrock** | AI deployment | vLLM for text generation and Hugging Face TEI for embeddings and reranking | Q4 2026 |
| **Lambda** | Serverless functions | | Q1 2027 |
| **SQS** | Message queues | | Q1 2027 |
Roadmap services ship under the same AWS API surface, so code written for AWS today works the moment they land. [Track what's shipped in the release notes](https://github.com/mulgadc/spinifex/releases).
+9 -10
View File
@@ -29,9 +29,15 @@ var allowlist = []allowance{
{From: "agents/rds/agent", To: "domains/rds/instance", Debt: "agents/rds/agent (dependency, narrowed)", Reason: "command protocol, wire and record types; needs a guest/controller wire contract"},
{From: "cmd/aws-model-coverage", To: "domains/acm/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared ECR/ACM/Route 53 inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/ecr/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared ECR/ACM/Route 53 inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/route53/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared ECR/ACM/Route 53 inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/acm/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared service inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/ecr/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared service inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/route53/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared service inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/elbv2/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared service inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/rds/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared service inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/ecs/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared service inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/eks/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared service inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/iam/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared service inventories; named exception, must not construct a registration"},
{From: "cmd/aws-model-coverage", To: "domains/sts/awsapi", Debt: "cmd/aws-model-coverage", Reason: "reads declared service inventories; named exception, must not construct a registration"},
{From: "runtime/daemon", To: "domains/ec2/awsapi/instance", Debt: "Instance adapter consumers outside EC2", Reason: "runtime/daemon/eks_cp_control.go and rds_deps.go call the instance adapter; needs an EC2 capability"},
@@ -122,12 +128,7 @@ var allowlist = []allowance{
{From: "domains/sts/awsapi", To: "domains/iam", Debt: "IAM implementation consumers in STS, Ochre and ELBv2", Reason: "GetCallerIdentity takes IAMService; needs an IAM capability"},
{From: "gateway", To: "domains/eks/awsapi", Debt: "gateway (service registration)", Reason: "IAM, STS, EKS and RDS dispatch stays in gateway until the ingress registration seam"},
{From: "gateway", To: "domains/iam/awsapi", Debt: "gateway (service registration)", Reason: "IAM, STS, EKS and RDS dispatch stays in gateway until the ingress registration seam"},
{From: "gateway", To: "domains/rds/awsapi", Debt: "gateway (service registration)", Reason: "IAM, STS, EKS and RDS dispatch stays in gateway until the ingress registration seam"},
{From: "gateway", To: "domains/sts/awsapi", Debt: "gateway (service registration)", Reason: "IAM, STS, EKS and RDS dispatch stays in gateway until the ingress registration seam"},
{From: "gateway", To: "domains/ecs/awsapi", Debt: "gateway (service registration)", Reason: "ECS and ELBv2 dispatch stays in gateway until the ingress registration seam"},
{From: "gateway", To: "domains/elbv2/awsapi", Debt: "gateway (service registration)", Reason: "ECS and ELBv2 dispatch stays in gateway until the ingress registration seam"},
{From: "domains/ecs", To: "domains/ec2/ebs/metadata", Debt: "close-out: handlers/ecs (ADR-0004 blocked-dependency list; inventory-ecs boundary imports)", Reason: "legacy ECS calls another domain's implementation as an internal API"},
{From: "domains/ecs", To: "domains/ec2/eip", Debt: "close-out: handlers/ecs (ADR-0004 blocked-dependency list; inventory-ecs boundary imports)", Reason: "legacy ECS calls another domain's implementation as an internal API"},
{From: "domains/ecs", To: "domains/ec2/instancetypes", Debt: "close-out: handlers/ecs (ADR-0004 blocked-dependency list; inventory-ecs boundary imports)", Reason: "legacy ECS calls another domain's implementation as an internal API"},
@@ -160,6 +161,4 @@ var allowlist = []allowance{
{From: "domains/rds/instance", To: "runtime/compute/vm", Debt: "close-out: handlers/rds (ADR-0004 blocked-dependency list; inventory-rds boundary imports)", Reason: "legacy RDS calls another domain's or runtime implementation directly"},
{From: "domains/sts", To: "domains/iam", Debt: "IAM implementation consumers in STS, Ochre and ELBv2", Reason: "STS reads IAM service, trust-policy and OIDC-provider state; needs an IAM capability"},
{From: "operator/cli", To: "gateway", Debt: "operator/cli (dependency)", Reason: "command tree imports implementations; needs public capabilities"},
}
-1
View File
@@ -11,7 +11,6 @@ import (
// completed move whose line must be deleted.
var frozenLegacyPackages = []string{
"gateway",
"gateway/spx",
}
// retiredLegacyRoots were legacy roots whose every package has moved to its
+96
View File
@@ -0,0 +1,96 @@
#!/bin/sh
mount -t proc proc /proc
mount -t sysfs sys /sys
mount -t devtmpfs dev /dev
# virtio_mmio is built-in (CONFIG_VIRTIO_MMIO=y) so virtio-net devices are
# already enumerated by the time PID 1 runs — no modprobe needed.
# qemu_fw_cfg and virtio_net are =m in stock Alpine linux-virt, so load them.
#
# modprobe needs a usable modules.dep; when the image is built on a host whose
# depmod can't produce one, busybox modprobe silently no-ops and the module
# never loads — fw_cfg then never appears and init panics. insmod by explicit
# path needs no modules.dep, so fall back to it. Handles .ko and .ko.gz.
load_mod() {
modprobe "$1" 2>/dev/null && return 0
for ko in $(find /lib/modules -name "$1.ko" -o -name "$1.ko.gz" 2>/dev/null); do
insmod "$ko" 2>/dev/null && return 0
case "$ko" in
*.gz) gunzip -c "$ko" >/tmp/mod.ko 2>/dev/null \
&& insmod /tmp/mod.ko 2>/dev/null && return 0 ;;
esac
done
return 1
}
load_mod qemu_fw_cfg || load_mod fw_cfg_sysfs || true
# virtio_net depends on net_failover, which depends on failover. The load_mod
# insmod fallback loads a single .ko with no dependency resolution, and
# modules.dep is absent when the image is built on a kmod-less host (depmod
# skipped), so modprobe can't resolve the chain either. Load it explicitly
# bottom-up so the NIC comes up regardless of how the image was built —
# without this the agent has no network and the LB hangs in provisioning.
load_mod failover || true
load_mod net_failover || true
load_mod virtio_net || true
NETCFG=/sys/firmware/qemu_fw_cfg/by_name/opt/spinifex/netcfg/raw
i=0
while [ "$i" -lt 25 ]; do
[ -f "$NETCFG" ] && break
sleep 0.04
i=$((i + 1))
done
if [ ! -f "$NETCFG" ]; then
# Dump host/guest fw_cfg state to the serial console before init exits so a
# "netcfg not available" panic is diagnosable from the captured console log
# (module-not-loaded vs qemu-not-exposing-by_name vs wrong machine type).
echo "[init] FATAL: fw_cfg netcfg not available" >&2
echo "[init] dmi: vendor=$(cat /sys/class/dmi/id/sys_vendor 2>/dev/null) product=$(cat /sys/class/dmi/id/product_name 2>/dev/null) bios=$(cat /sys/class/dmi/id/bios_version 2>/dev/null)" >&2
echo "[init] qemu_fw_cfg dir present: $([ -d /sys/firmware/qemu_fw_cfg ] && echo yes || echo NO)" >&2
echo "[init] modules: $(lsmod 2>/dev/null | awk 'NR>1{print $1}' | tr '\n' ',')" >&2
echo "[init] by_name listing:" >&2
ls -la /sys/firmware/qemu_fw_cfg/by_name/ 2>&1 | sed 's/^/[init] /' >&2
ls -la /sys/firmware/qemu_fw_cfg/by_name/opt/ 2>&1 | sed 's/^/[init] /' >&2
echo "[init] dmesg fw_cfg:" >&2
dmesg 2>/dev/null | grep -i fw_cfg | sed 's/^/[init] /' >&2
exit 1
fi
. "$NETCFG"
for n in 0 1 2 3 4 5; do
eval mac=\$NIC${n}_MAC
[ -z "$mac" ] && continue
iface=""
for attempt in 1 2 3 4 5; do
iface=$(ip -o link | awk -v m="$mac" 'tolower($0) ~ tolower(m) {print $2}' | tr -d :)
[ -n "$iface" ] && break
sleep 0.02
done
if [ -z "$iface" ]; then
echo "[init] WARNING: no interface found for MAC $mac (NIC$n), skipping" >&2
continue
fi
eval cidr=\$NIC${n}_CIDR
eval gw=\$NIC${n}_GW
eval default=\$NIC${n}_DEFAULT
eval rdst=\$NIC${n}_ROUTE_DST
eval rvia=\$NIC${n}_ROUTE_VIA
ip link set "$iface" up
[ -n "$cidr" ] && ip addr add "$cidr" dev "$iface"
[ "$default" = "1" ] && [ -n "$gw" ] && ip route add default via "$gw" dev "$iface"
[ -n "$rdst" ] && [ -n "$rvia" ] && ip route add "$rdst" via "$rvia" dev "$iface"
done
# The store image takes no lb-agent environment. A CA bundle is optional here:
# nothing in this image dials out yet.
CA_CERT=/sys/firmware/qemu_fw_cfg/by_name/opt/spinifex/ca-cert/raw
mkdir -p /etc/ssl/certs
[ -f "$CA_CERT" ] && cp "$CA_CERT" /etc/ssl/certs/ca-certificates.crt
exec /sbin/init
+10
View File
@@ -0,0 +1,10 @@
# The power button loads here, not in /init: busybox init has its SIGUSR2
# (poweroff) handler installed before sysinit runs, so a press can never reach
# the pre-exec shell PID 1. A press before this line is lost; the host re-sends.
::sysinit:/sbin/modprobe tiny_power_button power_signal=12
::sysinit:/usr/local/lib/sqs-store/sqs-store-prepare
::respawn:/usr/local/lib/sqs-store/sqs-store-run
::ctrlaltdel:/sbin/reboot
# One action: the store stops and its disk unmounts first, and the generic
# umount -a -r runs only if the store is gone.
::shutdown:/usr/local/lib/sqs-store/sqs-store-stop
+215
View File
@@ -0,0 +1,215 @@
# sqs-store-lib.sh — shared by the SQS store guest's prepare, run and stop
# steps. Sourced, never executed. Every path and command is overridable so the
# host test can drive the same code against a fake fw_cfg, sysfs and tools.
#
# Guest contract, read from fw_cfg under opt/spinifex/sqs-store/:
# data-serial virtio-blk serial of the already-formatted ext4 data disk
# listen-addr IPv4 address on a configured guest NIC; the only listener
# client-nkey NATS user NKey public key allowed to connect; never a seed
# Anything absent, malformed or ambiguous refuses the store. Nothing formats.
SQS_FWCFG=${SQS_FWCFG:-/sys/firmware/qemu_fw_cfg/by_name/opt/spinifex/sqs-store}
SQS_SYSBLOCK=${SQS_SYSBLOCK:-/sys/block}
SQS_DEVDIR=${SQS_DEVDIR:-/dev}
# The host test cannot create block nodes, so it relaxes this to -e.
SQS_NODE_TEST=${SQS_NODE_TEST:--b}
SQS_RUN=${SQS_RUN:-/run/sqs-store}
SQS_DATA=${SQS_DATA:-/data}
SQS_CONSOLE=${SQS_CONSOLE:-/dev/console}
SQS_MOUNTS=${SQS_MOUNTS:-/proc/mounts}
SQS_PORT=${SQS_PORT:-4222}
SQS_STOP_BUDGET_TENTHS=${SQS_STOP_BUDGET_TENTHS:-120}
NATS_BIN=${NATS_BIN:-/usr/local/bin/nats-server}
E2FSCK=${E2FSCK:-e2fsck}
MOUNT=${MOUNT:-mount}
UMOUNT=${UMOUNT:-umount}
IP=${IP:-ip}
sqs_log() { echo "[sqs-store] $*" >> "$SQS_CONSOLE"; }
sqs_fatal() { sqs_log "FATAL: $*"; return 1; }
# sqs_fwcfg <name>: print one fw_cfg value, refusing a missing, empty, oversized
# or multi-token file. The value is not echoed on failure.
sqs_fwcfg() {
f="$SQS_FWCFG/$1/raw"
[ -f "$f" ] || { sqs_fatal "fw_cfg $1 not supplied"; return 1; }
[ "$(wc -c < "$f")" -le 128 ] || { sqs_fatal "fw_cfg $1 is oversized"; return 1; }
v=$(cat "$f")
case "$v" in
"" | *[[:space:]]*) sqs_fatal "fw_cfg $1 must be exactly one value"; return 1 ;;
esac
printf '%s' "$v"
}
# A volume serial is the volume ID with dashes stripped: vol + 17 hex.
sqs_valid_serial() {
[ "${#1}" -eq 20 ] || return 1
case "$1" in vol*) ;; *) return 1 ;; esac
case "${1#vol}" in *[!0-9a-f]*) return 1 ;; esac
}
# A NATS user public NKey: "U" then 55 base32 characters. The checksum is
# left to the pinned server's own config test.
sqs_valid_user_nkey() {
[ "${#1}" -eq 56 ] || return 1
case "$1" in U*) ;; *) return 1 ;; esac
case "$1" in *[!A-Z2-7]*) return 1 ;; esac
}
sqs_valid_ipv4() {
case "$1" in *[!0-9.]* | .* | *. | *..*) return 1 ;; esac
old_ifs=$IFS; IFS=.
# shellcheck disable=SC2086 # split on dots on purpose
set -- $1
IFS=$old_ifs
[ "$#" -eq 4 ] || return 1
for o in "$@"; do
[ "${#o}" -le 3 ] && [ "$o" -le 255 ] || return 1
case "$o" in 0?*) return 1 ;; esac
done
}
# sqs_find_disk <serial>: print the /dev node of the one block device whose
# sysfs serial matches exactly. Zero or several matches refuse.
sqs_find_disk() {
found="" n=0
for b in "$SQS_SYSBLOCK"/*; do
[ -r "$b/serial" ] || continue
[ "$(cat "$b/serial")" = "$1" ] || continue
found=${b##*/}
n=$((n + 1))
done
[ "$n" -eq 1 ] || { sqs_fatal "expected one disk with serial $1, found $n"; return 1; }
test "$SQS_NODE_TEST" "$SQS_DEVDIR/$found" || { sqs_fatal "disk $found has no block device node"; return 1; }
printf '%s' "$SQS_DEVDIR/$found"
}
# sqs_has_addr <ipv4>: the address is assigned to a non-loopback interface.
sqs_has_addr() {
"$IP" -o -4 addr show 2>/dev/null \
| awk -v a="$1" '$2 != "lo" { split($4, p, "/"); if (p[1] == a) f = 1 } END { exit !f }'
}
# sqs_alive <pid>: running or stopped, not exited (a zombie counts as exited).
sqs_alive() { [ -r "/proc/$1/status" ] && ! grep -q '^State:[[:space:]]*Z' "/proc/$1/status" 2>/dev/null; }
# sqs_starttime <pid>: kernel start time (stat field 22). It survives exec, and
# pairing it with the pid reduces PID-reuse risk; without a pidfd the check and
# the signal stay separate steps, so it is not an absolute guarantee.
sqs_starttime() { sed 's/.*) //' "/proc/$1/stat" 2>/dev/null | cut -d' ' -f20; }
# sqs_same <pid> <starttime>: the recorded process is still alive.
sqs_same() { [ -n "$2" ] && sqs_alive "$1" && [ "$(sqs_starttime "$1")" = "$2" ]; }
# sqs_prepare: validate the contract, check and mount the data disk, write the
# server config and mark the store ready. Returns non-zero, unready, on any refusal.
sqs_prepare() {
rm -f "$SQS_RUN/ready"
mkdir -p "$SQS_RUN"
serial=$(sqs_fwcfg data-serial) || return 1
sqs_valid_serial "$serial" || { sqs_fatal "data-serial is not a volume serial"; return 1; }
addr=$(sqs_fwcfg listen-addr) || return 1
sqs_valid_ipv4 "$addr" || { sqs_fatal "listen-addr is not an IPv4 address"; return 1; }
nkey=$(sqs_fwcfg client-nkey) || return 1
sqs_valid_user_nkey "$nkey" || { sqs_fatal "client-nkey is not a user public NKey"; return 1; }
sqs_has_addr "$addr" || { sqs_fatal "listen-addr $addr is not on any guest NIC"; return 1; }
# The server checks the config, including the NKey checksum, before the
# disk is touched.
umask 077
cat > "$SQS_RUN/nats.conf" <<EOF
listen: "$addr:$SQS_PORT"
server_name: "sqs-store"
jetstream {
store_dir: "$SQS_DATA"
sync_interval: always
}
authorization {
users = [ { nkey: "$nkey" } ]
}
EOF
if ! "$NATS_BIN" -t -c "$SQS_RUN/nats.conf" > "$SQS_RUN/config-test.out" 2>&1; then
sqs_fatal "server config test failed: $(sed 's/U[A-Z2-7]\{55\}/<nkey>/g' "$SQS_RUN/config-test.out" | tr '\n' ' ')"
return 1
fi
dev=$(sqs_find_disk "$serial") || return 1
rc=0
"$E2FSCK" -p "$dev" > "$SQS_RUN/fsck.out" 2>&1 || rc=$?
sqs_log "e2fsck -p $dev rc=$rc"
# 0 clean, 1 corrected: proceed. Anything higher, including a disk that is
# not ext4 at all, refuses; the guest never formats.
[ "$rc" -le 1 ] || { sqs_fatal "e2fsck refused $dev: $(tr '\n' ' ' < "$SQS_RUN/fsck.out")"; return 1; }
mkdir -p "$SQS_DATA"
"$MOUNT" -t ext4 -o nodev,nosuid,noexec "$dev" "$SQS_DATA" || { sqs_fatal "mount $dev failed"; return 1; }
: > "$SQS_RUN/ready"
sqs_log "prepared: $dev mounted at $SQS_DATA, config written for $addr:$SQS_PORT; server not started yet"
}
# sqs_run: the respawned supervisor body. Its identity is recorded before the
# stopping check: a stop that misses it set stopping first, so this parks; a
# stop that reads it signals this process whether or not it has exec'd yet.
sqs_run() {
mkdir -p "$SQS_RUN"
echo "$$ $(sqs_starttime $$)" > "$SQS_RUN/pid"
if [ -e "$SQS_RUN/stopping" ]; then
sqs_log "run: shutdown in progress, not starting"
return 2
fi
if [ ! -e "$SQS_RUN/ready" ]; then
sqs_log "run: store not prepared, not starting"
return 2
fi
sqs_log "run: starting pid=$$"
exec "$NATS_BIN" -c "$SQS_RUN/nats.conf"
}
# sqs_stop: first shutdown action. Block any respawn, SIGTERM the recorded run
# process (a server, or a start not yet exec'd), SIGKILL only after the budget,
# then sync and unmount. Each signal rechecks the identity; a survivor keeps the disk mounted.
sqs_stop() {
mkdir -p "$SQS_RUN"
: > "$SQS_RUN/stopping"
sqs_log "stop: begin"
rec=$(cat "$SQS_RUN/pid" 2>/dev/null || true)
pid=${rec%% *} st=${rec#* }
[ "$st" != "$rec" ] || st=""
if [ -n "$pid" ] && sqs_same "$pid" "$st"; then
kill -TERM "$pid" 2>/dev/null || true
sqs_log "stop: SIGTERM sent to run pid=$pid"
i=0
while sqs_same "$pid" "$st" && [ "$i" -lt "$SQS_STOP_BUDGET_TENTHS" ]; do sleep 0.1; i=$((i + 1)); done
if sqs_same "$pid" "$st"; then
sqs_log "stop: run pid=$pid still running after $((SQS_STOP_BUDGET_TENTHS / 10))s, SIGKILL"
kill -KILL "$pid" 2>/dev/null || true
j=0
while sqs_same "$pid" "$st" && [ "$j" -lt 30 ]; do sleep 0.1; j=$((j + 1)); done
fi
if sqs_same "$pid" "$st"; then
sqs_log "stop: run pid=$pid STILL ALIVE, leaving $SQS_DATA mounted"
return 1
fi
sqs_log "stop: store exited after $((i / 10)).$((i % 10))s"
else
sqs_log "stop: no running store"
fi
sync
if grep -q " $SQS_DATA " "$SQS_MOUNTS" 2>/dev/null; then
rc=0
"$UMOUNT" "$SQS_DATA" || rc=$?
sqs_log "stop: umount $SQS_DATA rc=$rc"
fi
}
# sqs_shutdown: the only shutdown action. The generic read-only remount runs
# only after the store stopped; a surviving writer keeps every mount as it is.
sqs_shutdown() {
if ! sqs_stop; then
sync
sqs_log "shutdown: store survived, skipping umount -a -r"
return 1
fi
rc=0
"$UMOUNT" -a -r || rc=$?
echo "[init] shutdown: umount -a -r rc=$rc" >> "$SQS_CONSOLE"
}
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# sysinit: load the disk drivers, then validate the guest contract, check and
# mount the data disk and write the server config. A refusal leaves the store
# unprepared, so the run step never starts it.
. /usr/local/lib/sqs-store/sqs-store-lib.sh
modprobe virtio_blk 2>/dev/null || true
modprobe ext4 2>/dev/null || true
sqs_prepare || sqs_log "store refused; it will not start"
exit 0
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
# Respawned by init. A store that must not run parks here instead of exiting,
# so init does not respawn it in a tight loop.
. /usr/local/lib/sqs-store/sqs-store-lib.sh
sqs_run
exec sleep 2147483647
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
# The only shutdown action: stop the store and unmount its disk, then run the
# generic read-only remount only if the store is gone.
. /usr/local/lib/sqs-store/sqs-store-lib.sh
sqs_shutdown
-57
View File
@@ -1,57 +0,0 @@
# spinifex-unit-version: 1
[Unit]
Description=Spinifex SQS Message Store (dedicated JetStream)
PartOf=spinifex.target
ConditionPathExists=/etc/spinifex/sqs-store/sqs-store.conf
[Service]
EnvironmentFile=-/etc/spinifex/telemetry.env
Type=simple
Slice=spinifex-system.slice
User=spinifex-sqsstore
Group=spinifex
ExecStart=/usr/local/bin/spx service sqs-store start
Restart=on-failure
RestartSec=5
# JetStream store shutdown and raft stepdown have no internal deadline.
TimeoutStopSec=20
OOMScoreAdjust=-500
# Soft Go heap limit for the store; MemoryHigh/Max bound a runaway on top.
Environment=GOMEMLIMIT=512MiB
MemoryHigh=10%
MemoryMax=20%
Environment=SPINIFEX_CONFIG_PATH=/etc/spinifex/sqs-store/sqs-store.conf
# Filesystem access
NoNewPrivileges=yes
ProtectSystem=strict
PrivateDevices=yes
ReadOnlyPaths=/etc/spinifex/sqs-store /etc/spinifex/server.pem /etc/spinifex/server.key /etc/spinifex/ca.pem
ReadWritePaths=/var/lib/spinifex/sqs-store /var/log/spinifex
# Hardening
ProtectHome=yes
PrivateTmp=yes
RestrictSUIDSGID=yes
LockPersonality=yes
RestrictRealtime=yes
RestrictNamespaces=yes
ProtectClock=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectProc=invisible
SystemCallArchitectures=native
MemoryDenyWriteExecute=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK
CapabilityBoundingSet=
ProtectHostname=yes
KeyringMode=private
RemoveIPC=yes
LimitCORE=0
LimitNOFILE=65536
LimitNPROC=4096
[Install]
WantedBy=spinifex.target
+2 -2
View File
@@ -1,9 +1,9 @@
# spinifex-unit-version: 3
# spinifex-unit-version: 4
[Unit]
Description=Spinifex Infrastructure Platform
After=network-online.target
Wants=network-online.target
Wants=spinifex-nats.service spinifex-sqs-store.service spinifex-predastore.service spinifex-northstar.service spinifex-viperblock.service spinifex-daemon.service spinifex-awsgw.service spinifex-vpcd.service spinifex-ui.service spinifex-qmp-collector.service spinifex-shutdown.service spinifex-nats-watchdog.timer ovsdb-server.service ovs-vswitchd.service ovn-controller.service
Wants=spinifex-nats.service spinifex-predastore.service spinifex-northstar.service spinifex-viperblock.service spinifex-daemon.service spinifex-awsgw.service spinifex-vpcd.service spinifex-ui.service spinifex-qmp-collector.service spinifex-shutdown.service spinifex-nats-watchdog.timer ovsdb-server.service ovs-vswitchd.service ovn-controller.service
[Install]
WantedBy=multi-user.target
+12
View File
@@ -10,7 +10,13 @@ import (
"github.com/mulgadc/spinifex/internal/awsmodel"
acmawsapi "github.com/mulgadc/spinifex/spinifex/domains/acm/awsapi"
awsapi "github.com/mulgadc/spinifex/spinifex/domains/ecr/awsapi"
ecsawsapi "github.com/mulgadc/spinifex/spinifex/domains/ecs/awsapi"
eksawsapi "github.com/mulgadc/spinifex/spinifex/domains/eks/awsapi"
elbv2awsapi "github.com/mulgadc/spinifex/spinifex/domains/elbv2/awsapi"
iamawsapi "github.com/mulgadc/spinifex/spinifex/domains/iam/awsapi"
rdsawsapi "github.com/mulgadc/spinifex/spinifex/domains/rds/awsapi"
route53awsapi "github.com/mulgadc/spinifex/spinifex/domains/route53/awsapi"
stsawsapi "github.com/mulgadc/spinifex/spinifex/domains/sts/awsapi"
"github.com/mulgadc/spinifex/spinifex/gateway"
"github.com/mulgadc/spinifex/spinifex/ingress/aws/dispatch"
@@ -54,6 +60,12 @@ func compareAll() ([]awsmodel.OperationCoverage, error) {
awsapi.ServiceName: awsapi.OperationInventory(),
acmawsapi.ServiceName: acmawsapi.OperationInventory(),
route53awsapi.ServiceName: route53awsapi.OperationInventory(),
elbv2awsapi.InventoryName: elbv2awsapi.OperationInventory(),
rdsawsapi.ServiceName: rdsawsapi.OperationInventory(),
ecsawsapi.ServiceName: ecsawsapi.OperationInventory(),
eksawsapi.ServiceName: eksawsapi.OperationInventory(),
iamawsapi.ServiceName: iamawsapi.OperationInventory(),
stsawsapi.ServiceName: stsawsapi.OperationInventory(),
})
// The loop below walks the embedded models, so a served service with no
// model would otherwise drop out of the report without a word.
+1
View File
@@ -29,6 +29,7 @@ func loadConfig() (tokenwebhook.Config, error) {
CertPath: envOr("EKS_WEBHOOK_CERT", "/etc/spinifex-eks/token-webhook.crt"),
KeyPath: envOr("EKS_WEBHOOK_KEY", "/etc/spinifex-eks/token-webhook.key"),
Kubeconfig: envOr("EKS_WEBHOOK_KUBECONFIG", "/etc/spinifex-eks/token-webhook.kubeconfig"),
ReadyAddr: os.Getenv("EKS_WEBHOOK_READY_ADDR"),
}
// Static SigV4 creds are optional: when absent, eksgw.New signs with the
// AWS SDK chain (IMDS instance-role creds), the same path the CP VM's
+5
View File
@@ -8,3 +8,8 @@ administration. It is separate from AWS tenant-facing service contracts.
roles and Reed-Solomon configuration. It is an operational status contract,
not a generic provider abstraction; do not change its subject or JSON shape
incompatibly. Add a new version when that is required.
`admin.go` holds the `/admin/<Method>` request and response bodies the private admin surface shares with the CLI.
`AdminMethodNames` is the list of callable methods, and the gateway router builds its accept set from it.
`AccountQuotaRequest`, `AccountQuotaResponse` and `DeleteAccountResponse` stay in the gateway until the `/admin` handlers move, because they embed types the contracts layer may not import.
Do not change a field name, JSON tag or omitempty incompatibly; add a new version when that is required.
+76
View File
@@ -0,0 +1,76 @@
package operatorv1
import "slices"
// adminMethodNames is the callable /admin/<Method> list. The gateway router
// builds its accept set from it, so a name cannot be served without being listed.
var adminMethodNames = []string{
"CreateAccount",
"DeleteAccount",
"DescribeAccountDeletion",
"GetAccountQuota",
"ListAccounts",
"PutAccountQuota",
}
// AdminMethodNames returns the callable /admin/<Method> names in sorted order.
// Tooling that mints a credential grants these by name, so the list has to be
// the one the router serves rather than a copy that can drift out of step.
func AdminMethodNames() []string {
return slices.Sorted(slices.Values(adminMethodNames))
}
// Deletion job states.
const (
DeletionStateRunning = "RUNNING"
DeletionStateCompleted = "COMPLETED"
DeletionStateFailed = "FAILED"
)
// CreateAccountRequest is the /admin/CreateAccount request body.
type CreateAccountRequest struct {
Name string `json:"name"`
ClientToken string `json:"clientToken"`
Source string `json:"source,omitempty"`
}
// CreateAccountResponse is the /admin/CreateAccount success body. It is stored
// verbatim (with the secret encrypted) so a replay returns an identical answer.
type CreateAccountResponse struct {
AccountID string `json:"accountId"`
AccountName string `json:"accountName"`
AdminUser string `json:"adminUser"`
AccessKeyID string `json:"accessKeyId"`
SecretAccessKey string `json:"secretAccessKey"`
DefaultVpcID string `json:"defaultVpcId"`
}
// DeleteAccountRequest is the /admin/DeleteAccount request body.
type DeleteAccountRequest struct {
AccountID string `json:"accountId"`
AccountName string `json:"accountName"`
ClientToken string `json:"clientToken"`
Force bool `json:"force,omitempty"`
DryRun bool `json:"dryRun,omitempty"`
}
// DescribeAccountDeletionRequest is the /admin/DescribeAccountDeletion body.
type DescribeAccountDeletionRequest struct {
AccountID string `json:"accountId"`
}
// AccountSummary is one row of /admin/ListAccounts. It carries no credential
// material: the caller can already create and delete accounts, but that is no
// reason for a listing to hand out keys.
type AccountSummary struct {
AccountID string `json:"accountId"`
AccountName string `json:"accountName"`
Status string `json:"status"`
CreatedAt string `json:"createdAt,omitempty"`
}
// ListAccountsResponse is the /admin/ListAccounts success body.
type ListAccountsResponse struct {
Accounts []AccountSummary `json:"accounts"`
Count int `json:"count"`
}
+65
View File
@@ -0,0 +1,65 @@
package operatorv1
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/require"
)
func goldenJSON(t *testing.T, v any, want string) {
t.Helper()
data, err := json.Marshal(v)
require.NoError(t, err)
require.JSONEq(t, want, string(data))
}
func TestAdminWire_CreateAccountRequest(t *testing.T) {
goldenJSON(t, CreateAccountRequest{Name: "acme", ClientToken: "tok-1", Source: "cli"},
`{"name":"acme","clientToken":"tok-1","source":"cli"}`)
goldenJSON(t, CreateAccountRequest{Name: "acme", ClientToken: "tok-1"},
`{"name":"acme","clientToken":"tok-1"}`)
}
func TestAdminWire_CreateAccountResponse(t *testing.T) {
goldenJSON(t, CreateAccountResponse{
AccountID: "000000000042", AccountName: "acme", AdminUser: "admin",
AccessKeyID: "AKIAEXAMPLE", SecretAccessKey: "secret", DefaultVpcID: "vpc-1",
}, `{"accountId":"000000000042","accountName":"acme","adminUser":"admin","accessKeyId":"AKIAEXAMPLE","secretAccessKey":"secret","defaultVpcId":"vpc-1"}`)
}
func TestAdminWire_DeleteAccountRequest(t *testing.T) {
goldenJSON(t, DeleteAccountRequest{AccountID: "000000000042", AccountName: "acme", ClientToken: "tok-2", Force: true, DryRun: true},
`{"accountId":"000000000042","accountName":"acme","clientToken":"tok-2","force":true,"dryRun":true}`)
goldenJSON(t, DeleteAccountRequest{AccountID: "000000000042", AccountName: "acme", ClientToken: "tok-2"},
`{"accountId":"000000000042","accountName":"acme","clientToken":"tok-2"}`)
}
func TestAdminWire_DescribeAccountDeletionRequest(t *testing.T) {
goldenJSON(t, DescribeAccountDeletionRequest{AccountID: "000000000042"}, `{"accountId":"000000000042"}`)
}
func TestAdminWire_DeletionStates(t *testing.T) {
require.Equal(t, "RUNNING", DeletionStateRunning)
require.Equal(t, "COMPLETED", DeletionStateCompleted)
require.Equal(t, "FAILED", DeletionStateFailed)
}
func TestAdminWire_ListAccountsResponse(t *testing.T) {
goldenJSON(t, ListAccountsResponse{
Accounts: []AccountSummary{
{AccountID: "000000000042", AccountName: "acme", Status: "ACTIVE", CreatedAt: "2026-01-02T03:04:05Z"},
{AccountID: "000000000043", AccountName: "bolt", Status: "TERMINATING"},
},
Count: 2,
}, `{"accounts":[
{"accountId":"000000000042","accountName":"acme","status":"ACTIVE","createdAt":"2026-01-02T03:04:05Z"},
{"accountId":"000000000043","accountName":"bolt","status":"TERMINATING"}],"count":2}`)
}
func TestAdminWire_AdminMethodNames(t *testing.T) {
require.Equal(t, []string{
"CreateAccount", "DeleteAccount", "DescribeAccountDeletion",
"GetAccountQuota", "ListAccounts", "PutAccountQuota",
}, AdminMethodNames())
}
+87
View File
@@ -229,6 +229,36 @@ type EBSRequest struct {
Viperblock responds with an NBD URI that QEMU uses to access the block device.
#### Direct-boot microVM data volumes
A direct-boot microVM keeps the launcher's saved `vm.Config` as a clean base, and `startQEMU` adds data volumes only to a launch-only copy of it (`runtime/compute/vm/lifecycle.go`).
At each start the daemon takes one snapshot of the instance's already-mounted data requests, probes each NBD or host block export from that snapshot, and builds the command from the same snapshot, so the launched endpoint is the one that was checked and is never written back into the saved base.
Each data volume becomes a `virtio-blk-device` on the MMIO bus with the same id, node name, I/O thread, serial and `werror=stop,rerror=stop` policy as the PCI device, and takes no PCIe hot-plug port.
Boot and EFI requests are rejected on this path, and a direct-boot instance with no data requests launches its base unchanged.
Disk-boot (q35) instances keep the existing PCI hot-plug path.
Hot-attaching a volume to a running direct-boot microVM is not supported, because the MMIO bus has no PCIe root port to plug into.
`AttachVolume` refuses it before mounting the volume or changing any instance or volume state, and the EC2 API returns `UnsupportedOperation`.
This covers only requests that are already mounted when the instance starts; nothing yet supplies data volumes to a system instance, and the path is verified with fake-QEMU unit tests, not with a real EBS volume in a guest.
#### Volume leases
Before opening an engine on a volume, the Viperblock worker takes a lease: one entry per volume in the `VIPERBLOCK_VOLUME_LEASES` JetStream KV bucket, which expires 45 seconds after its last write (`providers/ebs/viperblock/volume_lease.go`).
A renewal becomes eligible once the last confirmed write is 10 seconds old, and the holder checks for that periodically, so the rewrite lands some time after that point.
Each rewrite is conditioned on the revision the holder last wrote, and a refused write that finds the entry gone or naming another owner or generation fences the export as a takeover.
It may keep writing for 40 seconds after the last write the store acknowledged, measured from when that write was sent, because the server starts the entry's expiry when it applies the write and never earlier.
A slow acknowledgement therefore shortens the remaining validity rather than extending it, and an acquisition acknowledged after its validity has already run out is refused as retryable.
For a holder that cannot renew, a timer is armed for the validity deadline, leaving a nominal 5 seconds before the entry can expire; when it fires, the export's nbdkit is fenced with SIGKILL (`volume_fence.go`).
The fence runs on its own goroutine, so Go scheduling, that goroutine and process termination all delay the kill, and enough delay can use up the whole margin; a kill held in uninterruptible sleep, which the fence waits up to 30 seconds for, is the extreme case.
Once a lease is lost or has lapsed it stays lost: a renewal that succeeds afterwards is ignored, and another open on the same node cannot share it while the fence runs.
These rules bound only the holder's own clock.
The storage backend does not reject a stale writer, so a paused or partitioned host that resumes after its validity can still write; generation enforcement at the write boundary is required by Q-24 in the umbrella repository's `docs/specs/viperblock/rfc3-1_overview.md` and is not implemented.
An export that survives a daemon restart writes without a renewed lease until recovery adopts it, and a survivor that recovery cannot adopt while a guest still uses it is left running without a lease or a fence.
### Predastore (S3)
Object storage used for:
@@ -256,6 +286,63 @@ file. It does not connect to Predastore to do so, and no Predastore node
exposes a status endpoint. This is an operator status interface, not a generic
storage-provider contract.
### SQS message store (internal)
`domains/sqs/message` defines the store-neutral interface the SQS domain reaches its message store through (ADR-0011:S6), with a JetStream adapter in `domains/sqs/message/jetstream` and a shared conformance suite in `domains/sqs/message/conformance`.
It is an internal primitive: nothing outside the SQS domain uses it, no daemon or service is wired to it, and it does not itself deliver an SQS API.
The dedicated JetStream server ADR-0011 describes is not deployed by this code, and Spinifex ships no host service, unit, user or firewall rule for it; the guest that could run it is described under *SQS store system instance (not wired)*.
The interface covers durable and idempotent append, body and metadata reads, conditional state writes and deletes, per-namespace counts, namespace enumeration, an ordered change feed, a bounded paginated scan, namespace deletion and a sweep of tombstoned bodies.
A namespace carries an immutable message-shard and state-shard allocation chosen when the queue is created, so a later change in shard counts never moves an existing queue.
The adapter provisions a fixed set of shared message streams (`SQS_M_<shard>`, one subject per queue) and shared state buckets (`sqs_state_<shard>`), keeps historical ones, and applies a 14-day-plus-one-hour retention backstop to both.
It supports one node (R1) and three nodes (R3) only and refuses any other declared cluster size before provisioning.
Reads that must observe a completed write or delete go to the stream leader: `GetState`, the state-key pass behind `Count` and `Namespaces`, and the body pass behind `Namespaces` and `Scan`.
This avoids the follower-served direct gets and follower-placed consumers that returned purged data in local three-node fault-injection tests; it is not a general linearizability guarantee.
Each leader read is one request per record, and the body pass transfers each full body internally even though `Scan` returns metadata only, which is a material cost for a large backlog.
A state-key pass is bounded but is not a snapshot when a key is overwritten during it.
The feed reads through an in-memory, headers-only ordered consumer.
If that consumer delivers nothing for about two seconds while the stream holds a change after the feed's cursor, the feed replaces it from the cursor, so a stored change does not wait on a stalled consumer; the cause of those stalls is not established.
`Close` is terminal, waits for consumer opens and deletes in progress and retries failed deletes, but cleanup is best effort for a create whose outcome is unknown: a consumer that lands after its last delete is removed by the server's one-minute inactive threshold.
Coverage is unit and conformance tests on in-process R1 and R3 servers; there is no end-to-end or multi-host validation of this code, and earlier multi-host evidence predates the final feed.
### SQS store system instance (not wired)
Spinifex can build, install, launch, restart and give storage to a dedicated SQS store microVM, but nothing calls any of it.
No SQS API, domain service, admin command or daemon start-up path creates a store, so none of this is in production use.
The guest image is built by `make build-sqs-store-microvm-image`, separate from the load balancer image, and bundles the `nats-server` version pinned in `go.mod` plus the ext4 tools.
Release tarballs carry it as `microvm-sqs-store/`, and `setup.sh` installs it to `/usr/share/spinifex/microvm/sqs-store/`.
A release without a complete image removes any previously installed one, so a launch is then refused rather than booting a stale image.
At boot the guest reads three firmware config values: the data disk's serial, an IPv4 address on one of its interfaces, and one NATS user NKey public key.
It mounts exactly one matching disk at `/data` after `e2fsck -p`, refuses a missing, duplicate, unformatted or unrepairable disk, and never formats.
JetStream keeps its data on `/data` with `sync_interval: always` (ADR-0011:S3), and the server listens only on that address and accepts only that key.
On shutdown the store is stopped before `/data` is unmounted; a store that survives SIGKILL leaves every mount in place.
A launch uses the versioned subject `system.LaunchSQSStore.v1`, which a daemon without this code does not serve, so it fails with no responder instead of booting another guest.
The legacy `system.LaunchInstance` path refuses the store kind on both send and receive.
Every input check runs before capacity is reserved, and the data volume must be an available system-account volume.
It is mounted through the normal EBS path and detached, never deleted, on terminate, which is the protection standard EBS gives today and nothing stronger.
CPU mitigations stay enabled for the store, unlike the load balancer.
A successful launch means the VM is running, not that NATS is ready.
The instance record keeps the store's non-secret guest settings so a restart on the node that launched it rewrites the firmware config files.
A relaunch on any other node is refused, and cross-node recovery never claims a store.
Both checks exist only in daemons with this code: an older daemon can still claim and relaunch a store elsewhere, and an explicit start served by another node claims the instance before its relaunch is refused.
`domains/sqs/storevolume` prepares a fresh data volume, because the guest never formats.
It checks for `mkfs.ext4` and `qemu-img` before allocating, creates the volume in `creating`, writes an empty ext4 image to it over NBD on the local node, unpublishes it, and only then makes it `available`.
While a volume is `creating`, attach, delete, modify, force-detach and snapshot are refused.
A volume is deleted only after a confirmed unpublish; any publish error, an unconfirmed unpublish or a failed release keeps it and reports its ID, with its state reported as unknown after a failed release.
Evidence is local only: unit tests, real QEMU boots against disposable scratch disks, and one run of the preparer against the `qemunbdd` provider whose volume kept acknowledged writes across a reboot.
Viperblock, volume encryption, the EC2 volume record path, multiple nodes and host reachability of the guest address are not tested.
Credential issuance and rotation, store placement and NATS readiness checks do not exist, and there is no failover: a lost node leaves its store unavailable.
## Configuration
Cluster configuration (`spinifex/bootstrap/config/config.go`):
+21 -9
View File
@@ -351,8 +351,20 @@ while the branch is in flight; they do not describe the umbrella repository's
| `spinifex#1269` | `spinifex/handlers/elbv2` | `spinifex/domains/elbv2` (package `elbv2`) | A mechanical whole-package relocation under the 2026-10-26 ADR-0001 amendment: the ELBv2 control plane keeps its files, tests and current dependencies, and importers alias it `elbv2domain`. No identifier, API, NATS subject, KV bucket, metric, error string or behaviour changes. Its allowlist entries are now sourced from `domains/elbv2`. Q-30's data-plane boundary stays deferred, recorded as `agents/elbv2` (Q-30 data-plane boundary) debt. |
| `spinifex#1271` | `spinifex/handlers/ecs` | `spinifex/domains/ecs` (package `ecs`) | A mechanical whole-package relocation: ADR-0001's `handlers/ecs` row targets `domains/ecs`, the files are already organised by resource, and resource packages are introduced only where callers need a compiler boundary. The ECS control plane keeps its files, tests and current dependencies alongside the already-extracted `domains/ecs/taskdefinition`, and importers alias it `ecsdomain`. No identifier, API, NATS subject, KV bucket, metric, error string or behaviour changes. Its allowlist entries are now sourced from `domains/ecs`. `handlers` has no package left and is a retired legacy root; R5 holds `domains/ecs` to the interim rule's ban on importing the daemon. |
| `spinifex#1273` | `spinifex/gateway/{ecs,elbv2}` | `spinifex/domains/{ecs,elbv2}/awsapi` (`awsapi`, imported as `ecsawsapi`, `elbv2awsapi`) | A mechanical relocation of the ECS and ELBv2 AWS action adapters to their ADR-0001 domain homes, as `spinifex#1265` did for IAM, STS, EKS and RDS; APIs, NATS subjects, KV buckets and behaviour are unchanged. The root `gateway` dispatch still imports each package, recorded as `gateway` (service registration) debt, and `domains/admission/quota` keeps its live ELBv2 counter import, now of `domains/elbv2/awsapi`. |
| `spinifex#1336` | `spinifex/gateway/tagging.go` (`Tagging_Request`, `taggingActions`, `taggingActionFromTarget`) and the `GatewayConfig.TaggingResources` field | `spinifex/domains/tagging/awsapi` (`NewRegistration`, `Deps`, `Actions`, `OperationInventory`), composed by `spinifex/runtime/roles/awsgw` | Resource Groups Tagging registers through the ADR-0002 seam like ACM and Route 53. The check order is kept: action, scope, authorization, account, body, aggregator, so a denied caller still gets `AccessDenied` before any body error and an unwired aggregator answers `ServerInternal`. The `checkPolicyResources` stand-in of `*` for every action is unchanged. The legacy switch case, the `supportedServices` entry and the `jsonErrorService` case are removed, and the registration declares the JSON 1.1 envelope. No allowlist row existed for this path. The nil-NATS check moves to the gateway-wide gate, which answers `ServiceUnavailableException` before dispatch as it did for every service. `cmd/aws-model-coverage` output is byte-identical because there is no embedded Tagging model. The characterization tests that pin the pipeline behaviour were committed first and pass unchanged against the registration; only the `withTagging` test helper changed. |
| `spinifex#1336` | `spinifex/gateway/elbv2.go` (`ELBv2_Request`, `elbv2Actions`, `elbv2Handler`, `accountLoadBalancerLimit`) | `spinifex/domains/elbv2/awsapi` (`NewRegistration`, `Deps`, `Quota`, `ActionNames`, `OperationInventory`), `spinifex/domains/admission/quota` (`Service.LoadBalancerLimit`), `spinifex/ingress/aws/query` (`ParseArgs`), composed by `spinifex/runtime/roles/awsgw` | ELBv2 registers through the ADR-0002 seam as the first AWS Query service. The check order is kept: query parse, action, account, input parse, scope, authorization, NATS, dispatch, so a denied caller still gets `AccessDenied` before the handler runs. The gateway members ELBv2 read are now supplied as `Deps`: `NATSConn` as `Deps.NATS`, `Quota` as the `Deps.Quota` interface declared in `awsapi` because `domains/admission/quota` imports `awsapi`, `Region` as `Invocation.Region`, and the policy gate as `Invocation.Authorize`. The `DescribeAccountLimits` cap resolution moves to `Service.LoadBalancerLimit` unchanged, and a nil `Deps.Quota` enforces nothing and reports the AWS default. AWSGW now wires the registry after it builds the quota service, because the registration captures it. The registration declares the XML envelope and the inventory name `elasticloadbalancingv2`, so `cmd/aws-model-coverage` keys it explicitly and its output is byte-identical. `gateway.ParseAWSQueryArgs` delegates to `query.ParseArgs`. The legacy switch case, the `supportedServices` entry, the inventory entry and the `gateway -> domains/elbv2/awsapi` allowlist row are removed. `cmd/aws-model-coverage` imports `domains/elbv2/awsapi` for the inventory, under a fourth named-exception allowlist row whose reason is now generic for all four. Finding, not fixed here: the XML for `DescribeAccountLimits` and `DescribeLoadBalancers` lists member fields in a different order from run to run because the marshal is map-ordered, so the characterization tests pin decoded content rather than bytes. The characterization tests that pin the pipeline behaviour were committed first and pass unchanged against the registration; only the `withELBv2` and `serveELBv2` test helpers and the setup of two older gateway tests changed. |
| `spinifex#1337` | `spinifex/gateway/spinifex.go` (`Spinifex_Request`, `spinifexAdminActions`) | `spinifex/operator/admin` (`NewRegistration`, `Deps`, `ModelAccess`, `ActionNames`), composed by `spinifex/runtime/roles/awsgw` | The `spinifex` Query service registers through the ADR-0002 seam with the XML error envelope it had. The check order is kept: query parse, action, authorization with the wildcard resource, account, the super-admin account gate, then the action, so a denied caller learns nothing about which actions exist. The gateway members the actions read are now `Deps`: `Version` and `Commit` strings, `NATSConn` as `Deps.NATS`, `RootCAs`, `DiscoverActiveNodes` as `Deps.ActiveNodes`, `BedrockAccessAdmin` as the `ModelAccess` interface, and the credential and access resolvers as `Deps.Credentials` and `Deps.Access`. The query actions need only the caller account, so the actor is not widened. The cluster-unavailable answer stays in the shared request path ahead of authorization. `/admin/{method}` moved onto the same registration in `mulga-3nbla.7`, recorded below. |
| `spinifex#1344` | `spinifex/gateway/rds.go` (`RDS_Request`, `rdsCaller`) | `spinifex/domains/rds/awsapi` (`NewRegistration`, `Deps`, `Quota`, `CallerFromActor`, `OperationInventory`), composed by `spinifex/runtime/roles/awsgw` | RDS registers through the ADR-0002 seam with the XML envelope it had. The check order is kept: query parse, action, account, the principal-class gate for the internal agent actions, scope, authorization, NATS, quota and dispatch, so a denied caller still gets `AccessDenied` before the handler runs and no customer grant is evaluated against an agent action. The gateway members RDS read are now supplied as `Deps`: `NATSConn` as `Deps.NATS`, `ExpectedNodes` as `Deps.ExpectedNodes`, `Quota.EnforceRDSInstances` as the `Deps.Quota` interface, `Region` as `Invocation.Region` and the policy gate as `Invocation.Authorize`. A nil `Deps.Quota` skips the DB-instance cap. The caller comes from `dispatch.Actor`: the session name for an assumed-role session and the user name otherwise, and the role name from `Actor.RoleName()`, which parses the underlying role ARN and never the session name. The account comes from `Invocation.AccountID`, so a caller with no composable ARN still reaches the policy check and is refused there as before. The legacy switch case, the `supportedServices` entry, the inventory entry and the `gateway -> domains/rds/awsapi` allowlist row are removed, and `cmd/aws-model-coverage` reads the inventory under a fifth named-exception allowlist row. The characterization tests that pin the pipeline behaviour were committed first with spinifex#1336 and pass unchanged against the registration; only the `withRDS` and `serveRDS` test helpers and the setup of the direct-call RDS tests changed. |
| `#1277` | `spinifex/accountteardown` | `spinifex/operator/accountlifecycle` (package `accountlifecycle`, imported as `accountteardown`) | A mechanical whole-package relocation under the 2026-10-27 ADR-0001 amendment: the account deletion coordinator keeps its APIs, NATS subjects, KV access and behaviour; importers keep the `accountteardown` name as an alias, so only their import paths change. Replacing its direct domain and adapter cleanup calls with owner capabilities stays deferred debt. |
| `#1285` | `spinifex/gateway/requestaudit.go` and `slogRequestLogger` from `spinifex/gateway/gateway.go` | `spinifex/ingress/aws/audit` (package `audit`) | The first generic-ingress extraction from the root gateway: the request-audit middleware and access-log middleware move unchanged in behaviour. The gateway's authentication flow and dispatch still populate the record, now through the exported `audit.From` and `Record` setters at the same call sites; the package imports only `foundation/telemetry` and `ingress/http`. Its unit tests moved with it; the tests that run it behind SigV4 stay in `gateway`. |
| `spinifex#1334` | `spinifex/gateway/spx` (`spx.go`, `storage.go`, `promote_image.go` and their tests) | `spinifex/operator/admin` (package `admin`) | The version, node, VM and storage-status gather helpers and the image-promote NATS request move unchanged with no shim; the `spinifex` service dispatch that calls them stays in `gateway/spinifex.go` until the `spinifex` registration slice. `operator/admin` already imports `domains/ec2/image` and `contracts/operator/v1`, so the move adds no edge and the layering ratchet needed no allowlist row. The `gateway/spx` frozen-legacy entry is removed. |
| `spinifex#1334` | `spinifex/gateway` (`CreateAccountRequest`/`Response`, `DeleteAccountRequest`, `DescribeAccountDeletionRequest`, `DeletionState*`, `AccountSummary`, `ListAccountsResponse`, `AdminMethodNames`) | `contracts/operator/v1` (`admin.go`) | The `/admin` bodies the CLI shares with the gateway move unchanged in field names, JSON tags and omitempty, pinned by golden JSON written against the gateway types first and moved with them. `AdminMethodNames` is now owned by the contract and the gateway builds its `adminMethods` accept set from it, with a test that the router accepts exactly that list. `AccountQuotaRequest`/`AccountQuotaResponse` (embed `quota.Overrides` from `domains/admission/quota`) and `DeleteAccountResponse` (embeds `accountlifecycle.Result`) stay in `gateway`: `contracts` may import only `foundation` and `contracts`, so they are settled when the `/admin` handlers move to `operator/admin`. `accountlifecycle.Stage` serialises as an integer, not its name; the golden test pins that. |
| `spinifex#1345` | `spinifex/gateway/admin*.go` (the `/admin/{method}` handlers, gates and body cap) and the `AccountQuotaRequest`/`AccountQuotaResponse`/`DeleteAccountResponse` wire types | `spinifex/operator/admin` (`rest.go`, `account_*.go`), served by the same `spinifex` registration | `/admin/{method}` stays a chi route in `gateway`, ahead of the service selector, but `Admin_Request` now only mints the request ID and header and hands the request to the registered entry through `dispatchRegistered`, the path every Query request takes. `dispatch.Invocation` gains `Service`, the credential-scope service, so the scope gate is the first identity gate in the dispatcher and a key signed for another service is denied exactly as before. The order is unchanged: verb and method, then the five fail-closed gates (scope, super-admin account, IAM user, identity, `spinifex:<Method>` policy), then the cluster check, then the 8 KiB body cap. The dispatcher returns errors and the route renders them as the JSON envelope with `requestId`, then logs once from the real result, so a denial or a 5xx is never logged as a completed request; the registration's `ResolveAction` labels the method, which removes the `auth.go` special case. The caller is read from `dispatch.Actor` (`UserName` for the gate and `updatedBy`). `BucketStore` and `SignupMaxAccounts` leave `GatewayConfig` for `operator/admin.Deps`, composed in `awsgw` beside `IAM`, `Quota`, `ExpectedNodes` and `NodeIDs`. The three wire types that could not enter `contracts` move to `operator/admin` with their handlers, `operator/cli` imports them from there, and the last `operator/cli` → `gateway` allowlist entry is deleted. |
| `spinifex#1346` | `spinifex/gateway/iam.go` (`IAM_Request`, the IAM action table, `getUserForCaller`, the PassRole check) | `spinifex/domains/iam/awsapi` (`NewRegistration`, `Deps`, `ActionNames`), composed by `spinifex/runtime/roles/awsgw` | IAM registers through the ADR-0002 seam with the XML error envelope it had. The check order is kept: query parse, action, service and account checks, then one parse of the input, the `GetUser` default for a missing `UserName`, scope resolution, authorization, the `iam:PassRole` check for `AddRoleToInstanceProfile`, then the handler. The caller is read from `dispatch.Actor` (`PrincipalType`, `UserName`), with no ARN parsing. The dependencies are `Deps.IAM` and `Deps.CountInstanceProfileAssociations`, composed in `awsgw`, and the gateway keeps no IAM fallback. The `cmd/aws-model-coverage` named exception gains an `iam` row. |
| `spinifex#1346` | `spinifex/gateway/sts.go` (`STS_Request`, the STS action table, the anonymous STS dispatch) | `spinifex/domains/sts/awsapi` (`NewRegistration`, `Deps`, `ActionNames`, `NewAnonymousAssumeRoleWithWebIdentity`), composed by `spinifex/runtime/roles/awsgw` | STS registers through the ADR-0002 seam with the XML error envelope it had. The check order is kept: query parse, action, service check, caller, the `AssumeRole` identity gate scoped to the stored role ARN, then the handler. The caller is read from `dispatch.Actor` (`CallerARN`, `UserName`, `SessionName`, `UserID`, `AccessKeyID`), with no ARN parsing. The gateway's authorization failure wraps a generic `dispatch.PolicyDenialError`, and STS matches it to answer with the caller, action and resource, so the gateway holds no STS-specific denial code. An unsigned `AssumeRoleWithWebIdentity` stays ahead of SigV4 in the gateway and reaches the handler through `GatewayConfig.AnonymousSTS`, a func composed in `awsgw`, never the STS service. The `cmd/aws-model-coverage` named exception gains an `sts` row. |
| `spinifex#1348` | `spinifex/gateway/ecs.go` (`ECS_Request`) and `spinifex/gateway/eks.go` (`EKS_Request`, the EKS route table) | `spinifex/domains/ecs/awsapi` and `spinifex/domains/eks/awsapi` (`NewRegistration`, `Deps`, `OperationInventory`), composed by `spinifex/runtime/roles/awsgw` | ECS (AWS JSON 1.1) and EKS (REST JSON) register through the ADR-0002 seam with the JSON error envelopes they had, both declared as AWS JSON 1.1 (see the envelope divergence below). The check order and every response are kept, pinned by the pipeline characterisation tests committed first. EKS and ECS resolve roles through `foundation/aws/passrole` `Check` with `domains/iam` `RoleResolver`: a malformed or foreign role is refused first, a missing role is authorized as written before it is reported, and a resolver outage is returned unchanged. Role handling now follows the AWS capture of 2026-10-30. ECS RegisterTaskDefinition refuses a foreign role with `ClientException` "Role is not valid" before PassRole and accepts a nonexistent, invented-path or non-ARN role from a caller who can pass roles. ECS RunTask refuses a foreign `taskRoleArn` or `executionRoleArn` override the same way and answers a nonexistent or invented-path one with "ECS was unable to assume the role". EKS CreateCluster and CreateNodegroup answer a non-ARN or foreign role with `AccessDeniedException` "Cross-account pass role is not allowed.". EKS public routes now report every parameter fault as `InvalidParameterException`, the code the EKS model declares, while the internal control-plane routes keep `InvalidParameterValue` because the guest agents match on it. Two deliberate EKS divergences remain. First, CreateCluster still refuses a nonexistent or invented-path role with `InvalidParameterException` "role ... does not exist", where AWS accepts it and the cluster later ends FAILED. Our EKS only stores, validates and echoes the cluster role and never assumes it, so accepting would leave an ACTIVE cluster bound to a role that does not exist. Second, CreateNodegroup keeps its existing refusal of a nonexistent role because AWS was not captured for it. A third divergence is the error envelope. EKS is restJson1 but registers `ErrorEnvelopeJSON`, so errors carry `application/x-amz-json-1.1` and a `__type` body where AWS sends `application/json` and a `message` body. The `X-Amzn-Errortype` header is correct and SDKs read the code from it, so impact is low. Switching to `ErrorEnvelopeRESTJSON` also changes the throttle code and the default internal-error code (`ServiceException` where the EKS model declares `ServerException`), so it is left for its own change. Verified live on env14: the ECS and EKS role cases above, and a valid CreateCluster reaching ACTIVE with the control-plane agent publishing through the gateway. The EKS route table and its tests move with the registration, and the gateway keeps no ECS or EKS fallback. The `cmd/aws-model-coverage` named exception gains an `ecs` and an `eks` row, and the two `gateway` allowlist rows are removed. |
| `spinifex#1350` | `spinifex/gateway` (`ecr.go`, `ecrauth_middleware.go`, the `/v2/token` exchange, `ecr_principal.go` with `ResolveECRPrincipal`, the per-operation `/v2` authorization, the registry host matcher, `ctxECRPrincipal`) | `spinifex/domains/ecr/registry` (`Bridge`, `NewBridge`, `BridgeConfig`, and its own `Principal`, `Rehydrator`, `Authorizer`, `Admission` types with `ErrInvalidCredential` and `ErrUnavailable`), `spinifex/ingress/http` (`HostMatcher`, `TargetAccount`, `RequestClientIP`; names no service), `spinifex/ingress/aws/credential` (`Rehydrator`, `Principal.CallerARN`), and under `spinifex/runtime/roles/awsgw`: `credverify` (`Rehydrate`, sharing the SigV4 key and session lookups), `policyauth`, `accountadmission`, `registryadapt` | ADR-0001 amendment 2026-10-29 and ADR-0005:S2: the OCI `/v2` bridge and its token auth move out of the gateway, and ECR resolves its principal through the credential capability instead of reading `IAMService` and `STSService` directly. ADR-0002:S5 keeps `/v2` outside the seam, so the gateway keeps only a `RegistryHandler` mount that answers 501 when unset. `domains/ecr/registry` imports no ingress package (`TestADR0001_Layering` unchanged): the principal, rehydrator and authorizer are registry-local types and `registryadapt` maps `credential.Failure` codes onto `ErrInvalidCredential` (401) and `ErrUnavailable` (503). No widening of `dispatch.Actor` or `dispatch.Invocation`. The SigV4 path and the bridge share one policy evaluator (`policyauth`) and one account-admission check. Deliberate change: the open-registry mode for a nil token verifier is deleted and `NewBridge` refuses a nil Verifier, Issuer, Rehydrator, Authorizer or Admission, so tests that want an unauthenticated registry mount `registry.Handler` directly. The pre-move pipeline characterisation (status codes, error bodies, the `WWW-Authenticate` challenge, referrers, token exchange, revoked and deleted principals) passes unchanged apart from setup, and the retired `ResolveECRPrincipal` parity rows live on as `credverify` `Rehydrate` rows and `Bridge` claim-check rows. Live on env14 (DHCP external IP): crane, skopeo and docker push and pull (`tests/e2e/ecr`), a cosign sign and verify in the legacy tag mode and in OCI 1.1 referrers mode with the signature returned by `GET /v2/{repo}/referrers/{digest}`, `/v2/token` refresh from fresh logins, and a deactivated access key answering 401 on `/v2/token`, manifest GET, crane pull and crane push, then 200 again once reactivated. The ECR signing-key deadlock bead (`mulga-6wqce`) is untouched. |
| `spinifex#1334` | `spinifex/gateway/oidc_discovery.go` (`eksAccountKV`, the discovery-document and JWKS read and construction) | `spinifex/domains/eks/cluster` (`OIDCPublisher`, `OIDCDiscoveryDocument`), composed by `spinifex/runtime/roles/awsgw` | The EKS domain now reads its own account bucket and builds the per-cluster discovery document and JWKS responses (ADR-0005:S4), and the gateway only maps the unauthenticated `/oidc/eks/...` routes onto an `OIDCPublisher` interface it is handed. Responses are byte-identical, pinned by `oidc_discovery_current_behaviour_test.go`, whose assertions are unchanged. The gateway no longer imports `domains/eks/cluster` in production code. `STS` keeps its own `ClusterJWKSResolver` (`OIDCJWKSReader`), untouched. Recorded debt, not repaired here: a stored JWKS is served verbatim with 200 even when it is not valid JSON. |
The EC2 contract row is intentionally different from the directory moves: it creates
a compatibility boundary. `ec2.cmd.*` retains its deployed one-token NATS
subscription and permission shape, while callers use
@@ -387,9 +399,9 @@ the canonical IAM/STS principal before dispatch, because ECR must not depend on
gateway identity context or ARN construction.
All implemented ECR control-plane actions now dispatch through explicit ECR
capabilities. The remaining ECR-named gateway code is generic `/v2/*` route
assembly, SigV4/registry authentication and policy enforcement; it remains in
gateway rather than inverting those dependencies into the ECR domain.
capabilities. The OCI `/v2` bridge, its token exchange and its principal
resolution now live in `domains/ecr/registry`; the gateway keeps only the
`RegistryHandler` mount, and `awsgw` composes the bridge.
### ACM relocation residuals
@@ -438,7 +450,7 @@ These residuals were recorded by individual slices and must be resolved once the
- `runtime/roles/vpcd` (placement): the role still mixes process/role supervision with network-controller responsibilities. `lease_reaper.go` (orphaned external-pool DHCP lease sweep), `ovn_controller_watchdog.go` (OVN controller liveness and restart), `host_eip_loop.go` (host-EIP reconcile loop) and `lease_datapath_reconcile.go` (lease datapath reconcile) are periodic network-control loops, not role wiring; `vpcd.go` itself also carries bridge-mode detection and verification, chassis-list parsing, external-CIDR resolution, DHCP manager startup and lease/IP-change handling, and gateway/host-EIP allocator and neighbour flush/prime construction alongside `Service.Start`. The future placement question is whether these belong in `domains/network`. Removal condition: an accepted decision on network-controller placement, and extraction of those loops and helpers behind the role.
- ECR control-plane registration: `awsapi.Deps.NATS` is a raw `*nats.Conn`, not a narrow capability. Every NATS-backed `Handler` passes it to `domains/ecr.NewNATSMetaStore`, which calls `natsmsg.NATSRequest`, so narrowing it means changing the exported `Handler` type, every handler and the meta store; it must not be broadened further meanwhile.
- ACM control-plane registration: `domains/acm/awsapi.Deps.NATS` (`registration.go`) is likewise a raw `*nats.Conn` carried by every `Handler`, for the same reason; it must not be broadened further meanwhile.
- `cmd/aws-model-coverage` imports `ingress/aws/dispatch`, `domains/ecr/awsapi`, `domains/acm/awsapi`, `domains/route53/awsapi` and `gateway` to read ECR's, ACM's and Route 53's declared inventories. It is a non-serving tool and the only named exception to the ADR-0002 composition invariant; it must not construct a registration.
- `cmd/aws-model-coverage` imports `ingress/aws/dispatch`, `gateway` and the `awsapi` package of each registered service (`domains/ecr/awsapi`, `domains/acm/awsapi`, `domains/route53/awsapi`, `domains/elbv2/awsapi`, `domains/rds/awsapi`, `domains/ecs/awsapi`, `domains/eks/awsapi`) to read their declared inventories. It is a non-serving tool and the only named exception to the ADR-0002 composition invariant; it must not construct a registration.
- Ingress pipeline (ADR-0002 phase 4): the request-audit record, the trace action enricher, the throttle key functions and the gateway request-context keys stay in `gateway` until the auth/IAM and request-context boundary is designed. SigV4 authentication writes the audit record and context keys from four places, so moving them now would export exactly the setters ADR-0002 says must not be exported solely to make a directory move possible.
- NAT projection delivery is inconsistent and is preserved as found: EIP `AssociateAddress` sends `vpc.add-nat` unacknowledged (`AnnounceNATAdd`), skipping the 45s OVN barrier every other add path waits on, and `DeleteNetworkInterface` sends `vpc.delete-nat` unacknowledged (`AnnounceNATDelete`), skipping the ack and the ErrNoResponders retry. The reconciler's orphan sweep is the only backstop for both. Clears when those call sites use `AddNAT`/`AddNATBestEffort` and `RemoveNAT`, a reliability change of its own.
- `vpc.add-system-egress` has a `vpcd` subscriber and a contract entry but no producer (its former `domains/ec2/eip` publisher is gone); `domains/eks/cluster` still publishes the delete. Either a producer is missing or the add route is dead; it needs an owner decision.
@@ -456,10 +468,10 @@ These residuals were recorded by individual slices and must be resolved once the
- `operator/installer/firstboot` (security): `Config.InstallCallback` is rendered into `spinifex-firstboot.sh`, which is world-readable (0755). The field is currently unused (`fireInstallCallback` reads `SPINIFEX_INSTALL_CALLBACK` from the environment instead), but any future wiring must not place secrets or tokenised callback URLs in the generated script; sensitive callback credentials should reach first boot through a protected channel such as a 0600 file or a credential store.
- `operator/cli` (known security risk): `spx admin join` contacts the formation server with `InsecureSkipVerify`, sends the join token as a bearer credential and receives the cluster CA certificate and key, master key, Viperblock key and shared credentials, so an on-path attacker during formation can capture the token and the cluster root secrets or substitute a CA. This predates the move; lint surfaced it when the tree left `cmd/`. It is accepted for now and carries a line-level gosec annotation stating it is not a false positive. Removal condition: authenticate formation TLS with a pinned key or certificate delivered with the join material, or an out-of-band CA, with tests proving a mismatched server certificate fails before credentials are sent.
- `domains/eks/cluster` (potential security risk): `ClusterMeta.ControlPlaneTemplate` (`domains/eks/cluster/service_impl.go`) clears the template's credentials but keeps `OIDCPrivateKeyPEM` and the k3s `JoinToken`, so both are persisted in the `eks-account-{acct}` cluster record, which the gateway also reads. Whether that record is encrypted at rest is unconfirmed; if it is not, a reader of the bucket can forge service-account tokens for the cluster's OIDC issuer and join nodes to it. This predates the refactor and is not fixed in it. Removal condition: the key and token are held by a dedicated secret store (a future KMS or Secrets Manager capability is the likely owner) and the cluster record keeps only a reference, with a test proving the persisted record contains neither secret.
- `operator/cli` (dependency): the command tree still imports domain and service implementations directly (`handlers/{iam,eks}`, `domains/admission/quota`, `gateway`, `domains/ochre`, `vpcd`, the Viperblock adapter and runtime roles). The ADR's `cmd/spinifex` current-to-target map row requires command packages to reach domains through public capabilities; splitting supported use cases into `operator/*` packages is later work.
- `operator/cli` (dependency): the command tree still imports domain and service implementations directly (`handlers/{iam,eks}`, `domains/admission/quota`, `domains/ochre`, `vpcd`, the Viperblock adapter and runtime roles). The ADR's `cmd/spinifex` current-to-target map row requires command packages to reach domains through public capabilities; splitting supported use cases into `operator/*` packages is later work.
- `providers/ebs/viperblock` → `runtime/compute/nbd` and `runtime/host/process` (dependency, moved unchanged from `services/viperblockd`): the adapter formats NBD endpoints and manages nbdkit processes through runtime packages. ADR-0001 does not list providers → runtime as forbidden and the layering test does not enforce it (same category as `providers/ebs/conformance` → `runtime/compute/nbd`), but a provider should not depend on node runtime. Clears when NBD endpoint naming has a provider-facing home (a candidate for `contracts/ebs/v1`) and process supervision is injected by the role. The adapter also imports `providers/objectstore`, a provider-to-provider edge that is allowed.
- `gateway/ec2.go` (registration): the EC2 dispatch map stays a `GatewayConfig` method in `gateway` and imports every `domains/ec2/awsapi/*` package; `gateway/ec2_idempotency.go` also imports `domains/ec2/awsapi/idem` (`KVBucket`, `TTL`, `TokenAndParams`) for the dispatch-time idempotency wrapper. ADR-0001 makes the domain own its action registration; moving the map waits on the generic ingress registration seam and must not be done as a package move.
- `gateway` (service registration): the root `gateway` dispatch for IAM, STS, EKS, RDS, ECS and ELBv2 imports `domains/{iam,sts,eks,rds,ecs,elbv2}/awsapi`, which only AWSGW may wire. It clears when each service registers through the ADR-0002 ingress registration seam; as with EC2, moving the dispatch must not be done as a package move.
- `gateway` (service registration): the root `gateway` dispatch for IAM, STS, EKS, RDS and ECS imports `domains/{iam,sts,eks,rds,ecs}/awsapi`, which only AWSGW may wire. It clears when each service registers through the ADR-0002 ingress registration seam; as with EC2, moving the dispatch must not be done as a package move.
- `operator/accountlifecycle` (dependency): its EC2 reapers call `domains/ec2/awsapi/*` action adapters directly, as they did under `gateway/ec2`. The amended ADR-0001 `accountteardown` row keeps replacing these with domain-owned cleanup capabilities as deferred debt; it was not a relocation prerequisite. It also holds a read-only consumer of the EC2 platform-inventory contract (`contracts/ec2/v1`, `ec2.v1.PlatformInventory`), served by `domains/ec2/accountinventory`; only the explicit dry run (`Engine.DryRun`) calls it, to log a shadow comparison, and the key-pair, placement-group and launch-template reapers still use the `awsapi` adapters. A domain-owned cleanup capability for the proven-safe subset of those three kinds (key pairs and empty placement groups no instance, spot request or live launch-template version names, and launch-template residue; never live launch templates) exists as `domains/ec2/accountcleanup` (a Go interface with injected owners and reference readers, no NATS subject); nothing calls it yet. It also holds the StageAccount settings-seal reaper, a consumer of `contracts/ec2/v1`'s `ec2.v1.SealAccountSettings` and per-node `ec2.v1.AccountSettingsSealCapability.<node>` subjects, served by `domains/ec2/account` through the daemon; the reaper reads no KV and imports no domain package, reaching both subjects only through NATS and the configured node set `NewClusterEngine` already receives.
- `domains/admission/quota` (dependency, moved from `handlers/quota` unchanged): `live.go` imports `domains/elbv2/awsapi` and `domains/rds/instance` for its live ELBv2 and RDS counters; `records.go` imports `runtime/compute/vm` for the instance-record vCPU sweep; `live.go`, `vcpu.go` and `storage.go` call `domains/ec2/awsapi/{vpc,eip,volume}` describe adapters to count VPCs, subnets, addresses and volumes, as they did under `gateway/ec2`. The ADR's `handlers/quota` current-to-target map row replaces these with reader capabilities once their final locations exist.
- `domains/ec2/awsapi/instance` (dependency): imports `domains/iam` (`IAMService` in `DescribeInstances.go`, `RunInstances.go` and `IamInstanceProfileAssociation.go`; `InstanceProfile` in the latter two), `runtime/compute/cache` (`NodeState`, `NodeUnknown`, `NodeLive`) and `runtime/compute/vm` (`VM`), both in `status_synthesis.go`. The IAM edge needs an IAM capability; the runtime edges are domain-to-runtime and need the instance record and node liveness exposed through an EC2-owned projection.
@@ -676,8 +688,8 @@ series above; "needs decision" is open.
| `gateway/bedrock` | — | Done. The whole package moved into `domains/ochre` in `spinifex#1266` with its package-private core and tests intact and no behaviour change. Separating the action adapters into `domains/ochre/awsapi` remains deferred, recorded as `domains/ochre` (action adapters) debt above. |
| `gateway/{iam,sts,eks,rds}` | — | Done. The action adapters moved to `domains/{iam,sts,eks,rds}/awsapi` in `spinifex#1265` with no API, NATS subject, storage or behaviour change. ADR-0001 does not make ADR-0002 registration a prerequisite for relocating a domain's adapters, as the EC2 adapter moves already showed; the root `gateway` dispatch that still imports them is recorded `gateway` (service registration) debt. |
| `gateway/{ecs,elbv2}` | — | Done. The action adapters moved to `domains/{ecs,elbv2}/awsapi` in `spinifex#1273` with no API, NATS subject, storage or behaviour change; the root `gateway` dispatch that still imports them is recorded `gateway` (service registration) debt. |
| `gateway/spx` | `promote_image.go` and `spx.go` dispatch (`storage.go` already consumes `contracts/operator/v1`). | Needs decision: which package owns operator-plane action dispatch registration — an `ingress/aws`-style seam for the operator plane, or `gateway` stays its home. |
| `gateway/tagging` | — | Done. `domains/tagging` owns the read-only cross-resource `GetResources` aggregation and its API semantics (`0d830e901`, `aedd0b2c4`); AWSGW composes the owner listers, the EC2 tag index and ELBv2 (`f3545e3ea`); the root `gateway` keeps only the legacy dispatch in `gateway/tagging.go`. The package is removed, and its two allowlist rows and frozen-legacy entry are gone. Owner tag mutation capabilities remain future direction, so the RDS and ECS tag-writing edges above stay open. |
| `gateway/spx` | — | Done. The gather helpers, storage-status config and image-promote request moved to `operator/admin` with no behaviour change and the package is removed. The `spinifex` Query dispatch and the `/admin/{method}` handlers that call them now live in `operator/admin` as one seam registration. |
| `gateway/tagging` | — | Done. `domains/tagging` owns the read-only cross-resource `GetResources` aggregation and its API semantics (`0d830e901`, `aedd0b2c4`); AWSGW composes the owner listers, the EC2 tag index and ELBv2 (`f3545e3ea`); the dispatch moved to `domains/tagging/awsapi` and the root `gateway` no longer serves Tagging. The package is removed, and its two allowlist rows and frozen-legacy entry are gone. Owner tag mutation capabilities remain future direction, so the RDS and ECS tag-writing edges above stay open. |
| `services/viperblockd` | — | Done. The adapter is `providers/ebs/viperblock` (with the read-only `dirty` reader), the shared vocabulary is `contracts/viperblockd/legacy/v1`, and the role is `runtime/roles/viperblockd`. `services/` is empty. |
| `utils` | — | Done and deleted. `ec2_subject.go` went to `contracts/ec2/v1`, the vpcd protocol to `contracts/network/v1` with the typed client in `domains/network/projection`, and the master-key loader to `domains/ec2/ebs/encryption`. |
| `vpcd` | — | Done. The IMDS local-file reader and record-space opener moved to `domains/ec2/instance/state` and are injected through `guestmetadata.LocalStateReader`/`RecordLoader` (recorded above), so `vpcd` no longer imports `daemon` directly; its inter-process boundary now exists (`contracts/network/v1`, with `domains/network/subscribers` as the consumer and `domains/network/projection` as the producer client). The package moved unchanged to `runtime/roles/vpcd` (recorded below), and the legacy directory is removed. |
@@ -696,7 +708,7 @@ ADR-0001 completion is structural, so none of these is cleared by remediating se
| Class | Paths | Status |
|---|---|---|
| No missing boundary (candidate moves) | `handlers/ecs/bus` → `contracts/ecs/v1` (`a130f6b8e`); `admin/images_promote.go` → `domains/ec2/image` (`263c58167`); `admin` bootstrap account identifiers → `foundation/aws/identifiers` (`3fdaa54d9`); `admin` credential-format generators → `foundation/aws/credentials` `0368e861a`, retiring `admin` | Done. |
| One narrow missing boundary | Done: `handlers/sts` EKS JWKS lookup → `handlers/eks` `ClusterJWKSResolver` (`254d898a3`); `gateway/tagging` → `domains/tagging` with AWSGW-composed listers (`0d830e901`, `f3545e3ea`, `aedd0b2c4`). Open: `gateway/spx` (owner of operator-plane dispatch registration) | Each needs one decision or one capability, then a mechanical move. |
| One narrow missing boundary | Done: `handlers/sts` EKS JWKS lookup → `handlers/eks` `ClusterJWKSResolver` (`254d898a3`); `gateway/tagging` → `domains/tagging` with AWSGW-composed listers (`0d830e901`, `f3545e3ea`, `aedd0b2c4`); `gateway/spx` → `operator/admin`. Done: the `spinifex` service and `/admin` dispatch registration, owned by `operator/admin` | Each needs one decision or one capability, then a mechanical move. |
| Broader boundary or follows another package | `gateway` root (ADR-0002 auth and request-context phase) | Recorded debt with removal conditions above. |
Per-consumer IAM capabilities are the widest unblocker: they gate STS's IAM reads, Ochre's IAM reads, the ELBv2 role path and the ECS, EKS and RDS ensurers.
+1 -1
View File
@@ -73,7 +73,6 @@ The cluster plane is peer-scoped. On a single-NIC node the planes collapse onto
| Ports | Serving |
|---|---|
| TCP 4222, 4248 | NATS client and cluster routes |
| TCP 4223, 4249 | SQS message store client and cluster routes |
| TCP 4432 | Formation, then the daemon cluster manager |
| TCP and UDP 5300 | Internal DNS |
| TCP 6641, 6642 | OVN northbound and southbound |
@@ -158,6 +157,7 @@ Restarting the daemon is what re-arms it: the node rebuilds its peer list from t
> [!WARNING]
> Do not flush the whole nftables ruleset to clear the policy. The VPC daemon writes SNAT and per-elastic-IP forward rules into the `ip nat` and `ip filter` tables and reinstalls them only when it starts, so `nft flush ruleset` breaks elastic IPs silently until the next `systemctl restart spinifex-vpcd`. Use `disable`, which only ever touches `inet spinifex_filter`.
> On Oracle Linux with IPsec on, a flush also removes `inet spinifex_ipsec_guard`, so Geneve to a peer without an SA goes out in clear until the daemon puts the table back, within 60 seconds.
## The Files
+21
View File
@@ -144,6 +144,27 @@ The guest MTU moves with the setting, but a running guest holds its DHCP lease f
**Expect launches to fail for a minute or two after re-enabling.** `RunInstances` returns `ServerInternal` with `vpc.add-nat` timing out, because the OVN flows-ready barrier cannot confirm while `ovn-controller` reprograms every tunnel for the new SAs. It clears once `ip xfrm state` settles. The error is reported as a capacity problem, which it is not.
### Containers and nested overlays inside a guest
A Docker bridge, Kubernetes pod network or other overlay inside a guest defaults to an MTU of 1500, which is larger than the guest's 1408 or 1442.
Downloads from the internet still work for TCP on the veth and routed uplinks, because vpcd clamps the TCP MSS on the host hop (see [Performance Tuning → MTU](/docs/performance-tuning#4-mtu)).
That was measured on a single node (env12) with a Docker container; it was not measured on a physical uplink or on a multi-node cluster.
On a physical uplink there is no host hop to clamp, and UDP is never clamped, so set the inner MTU to the guest MTU.
For Docker, in `/etc/docker/daemon.json`:
```json
{
"mtu": 1408,
"default-network-opts": {
"bridge": { "com.docker.network.driver.mtu": "1408" }
}
}
```
Use 1442 when `ipsec_enabled = false`, and restart the Docker daemon so the default bridge is recreated.
The gateway MTU follows `ipsec_enabled` and converges on the next reconcile pass, so change the inner MTU together with the guest MTU.
## Private vs Public Subnets
A subnet's behavior depends on three things: whether the VPC has an Internet Gateway, whether the subnet's route table has a default route to that IGW, and whether the subnet has `MapPublicIpOnLaunch` enabled.
+66
View File
@@ -45,6 +45,7 @@ Each repository holds image manifests and their layers. Images are stored in obj
- Repository lifecycle — `CreateRepository`, `DeleteRepository`, `DescribeRepositories`.
- OCI push and pull — blobs, manifests, and tags, including cross-repository blob mounts.
- OCI 1.1 referrers — the referrers API, so cosign v3 signatures and other artifacts attached to an image can be listed (see [OCI referrers and image signing](#oci-referrers-and-image-signing)).
- Token auth — `GetAuthorizationToken` plus bearer/basic auth on `/v2/`.
- Repository policies — set, get, and delete a repository policy document.
@@ -176,6 +177,71 @@ Then authenticate Docker and push using the `repository_url` output, following s
:::
## EKS workers and multiple gateways
Each gateway puts its own address in the `repositoryUri` it returns, so repositories created through different gateways can carry different hosts.
When an EKS worker launches, the daemon that launches it writes every cluster gateway into the worker's registry mirrors, TLS trust and credential-provider config.
A pod can then pull from any `repositoryUri` host in the cluster.
The worker tries the gateway named in the image reference first and falls back to the others in cluster order.
Limits:
- The gateway list comes from the cluster config the launching daemon loaded at start.
A gateway added later is not trusted by existing workers; restart the launching daemon and replace the worker.
- Peer gateways are assumed to listen on port 9999.
A hand-edited `awsgw` bind on a peer is not covered.
- A gateway address that does not answer costs about 30 seconds on each cold pull while the worker's connection attempt gives up.
A stopped gateway on a host that is still up refuses the connection, and the worker moves to the next gateway at once.
Measured on a single-node environment: pulls by `repositoryUri` and by the account's ECR DNS name, a pull rejected with `x509: certificate signed by unknown authority` when the gateway host was not in the worker config, and a 31 second pull through an unreachable first endpoint.
Measured on a 3-node environment: a pod pulling each of the three gateways' `repositoryUri` on a worker launched with this change (two of the three failed with `x509` on a worker launched without it), and a pull of the stopped gateway's own `repositoryUri` that succeeded through another gateway within one retry (the pull itself took 147 ms after the first endpoint refused).
## OCI referrers and image signing
A manifest can name another manifest as its `subject`, which is how tools such as cosign v3 attach signatures and SBOMs to an image.
The registry records the subject when the manifest is pushed and answers with an `OCI-Subject` header on the `201`.
The `subject` does not have to exist in the repository when the referrer is pushed.
`GET /v2/<name>/referrers/<digest>` lists the manifests that name `<digest>` as their subject.
The request is authorised as `ecr:BatchGetImage` on the repository.
The response is `200` with `Content-Type: application/vnd.oci.image.index.v1+json` and an index whose `manifests` hold each referrer's `mediaType`, `digest`, `size`, `artifactType` and annotations.
A digest with no referrers, or one that is not stored, returns an empty index.
A malformed digest returns `400` with `DIGEST_INVALID`.
Adding `?artifactType=<type>` returns only referrers of that type and sets `OCI-Filters-Applied: artifactType`.
The header is also set when nothing matches.
An image manifest without an `artifactType` is listed under its config `mediaType`; an index without one has none.
Deleting an image by digest (`DELETE /v2/<name>/manifests/<digest>`, `aws ecr batch-delete-image` with `imageDigest`) also deletes its referrers, and their referrers in turn.
Deleting by tag removes only the tag and leaves the image and its referrers.
cosign v3 sign and verify work against the registry, including on a child manifest of an image index copied with `cosign copy`.
cosign v2 keeps writing its `sha256-<digest>.sig` tags and is unaffected.
`GET` on a manifest still returns `406` when the request's `Accept` header does not include the stored `mediaType`.
Limits:
- `cosign copy` does not copy v3 signatures to the destination repository.
This is client behaviour.
To keep the original signature, copy with `oras cp -r <source> <mirror>`, which copies the image and its referrers in one command, or `crane copy` the signature manifest by digest after the image.
Otherwise, sign the copy again.
- Referrers pushed before this version are not listed.
Push them again to add them to the index.
- A crash between deleting an image and deleting its referrers can leave referrers behind that nothing lists.
- The referrers listing is not paginated.
- `HEAD` on the referrers route is not served.
Measured on a 3-node environment with cosign v3.1.4 and v2.6.5:
- cosign v3.1.4 signed a fresh image index, with one `GET /referrers` answered `200`, no `sha256-<digest>` tag written and no `406`.
- Verify passed.
- A copied index's child manifest signed and verified, which returned `406` before this change.
- The listing returned the signature with its `artifactType`, the filter returned one entry for the signature's type and none for another type.
- `aws ecr batch-delete-image` of the signed image left an empty listing and `404` for both the signature and the image.
- cosign v2.6.5 signed and verified a fresh image.
Not measured: `oras`, `notation`, a listing with many referrers, and a crash in the middle of a delete.
## Troubleshooting
**`docker login` fails with an authorization error.** The token is account-scoped and short-lived. Re-run `aws ecr get-login-password` to mint a fresh token, and confirm the registry host in `docker login` matches your account's endpoint (`aws ecr describe-repositories` returns it).
+34
View File
@@ -60,6 +60,36 @@ Authentication uses **EKS access entries** (the API authentication mode) — IAM
- **The worker image is fixed.** Node groups always boot Spinifex's `eks-node` image. `ami_type` is recorded but does not select the image, and the image must be registered on the cluster before you create a node group.
- **Default Kubernetes version is `1.32`.**
### Control plane readiness and kubectl authentication
Each control-plane VM authenticates `kubectl` tokens through a webhook that calls the AWS gateway on the host the VM runs on.
When that gateway is stopped, the webhook cannot validate tokens and `kubectl` reports `Unauthorized` for the share of requests that the load balancer sends to that control plane.
The webhook serves `/readyz` on port 8444 of each control-plane VM.
It returns 200 only when the host gateway answers a TLS handshake and the local API server accepts a TCP connection, and 503 otherwise.
The API server target group health-checks `HTTP :8444/readyz` every 5 seconds with a healthy and unhealthy threshold of 2.
The target group still forwards TCP on 6443.
A control plane that cannot authenticate leaves rotation, and returns when its gateway is back.
Measured on a three-node cluster, one control plane per host, with `kubectl get ns` run continuously after stopping one gateway:
| Gateway stopped | Result |
| --- | --- |
| Host without the cluster load balancer VM, first run | 4 of 20 calls failed in the first round, 0 of 20 in the next round 54 s after the stop |
| Host without the cluster load balancer VM, second run | 2 failures in 100 s, at 3 s and 8 s after the stop |
| Host running the cluster load balancer VM | Not fixed: 20 of 60 calls failed over 100 s |
Before this change the same test failed 3, 4 and 3 calls of 10 per stopped gateway.
Limits:
- Only clusters created with the current `eks-node` image get the readiness listener, and only clusters created from now on get the health check on the target group.
Older clusters keep the TCP check on 6443 and are not changed.
- A cluster created with an older image gets the health check on its target group but no listener on 8444, so every control plane fails the check and the load balancer fails open to all of them.
- A stopped gateway on the host that runs the cluster load balancer VM is not covered.
The load balancer VM reports target health through its own host's gateway, so while that gateway is down the unhealthy control plane stays in rotation.
- Not measured: more than one control plane per host, a physical-node failure instead of a stopped gateway, and the target health state as `DescribeTargetHealth` reports it, because the load balancer and control-plane VMs belong to the system account.
## Prerequisites
> [!IMPORTANT]
@@ -256,6 +286,10 @@ The workbooks form a ladder. **eks-quickstart** is a NodePort demo; **eks-https-
**`kubectl` cannot connect.** Re-run `aws eks update-kubeconfig --name <name>` to refresh the endpoint and CA, and confirm the cluster is `ACTIVE`. `aws sts get-caller-identity` verifies your credentials reach the Spinifex endpoint.
**`kubectl` returns `Unauthorized` for some requests and works for others.**
One control plane cannot reach its host's AWS gateway, so check `systemctl status spinifex-awsgw` on each node.
Control plane readiness and kubectl authentication above lists which clusters recover on their own.
**Workers stay `NotReady`.** Almost always an egress or IAM problem:
- Confirm the workers can pull images — a default route to an Internet Gateway (public) or NAT Gateway (private).
- Confirm the node role has `AmazonEKSWorkerNodePolicy`, `AmazonEKS_CNI_Policy`, and `AmazonEC2ContainerRegistryReadOnly`.
+54 -2
View File
@@ -2,8 +2,8 @@
"schema_version": 1,
"model_source": {
"repository": "github.com/aws/api-models-aws",
"commit": "9b1a4929274443d8671ea8acfda7afbe856e29e9",
"commit_date": "2026-09-25"
"commit": "e10d6a1c5ac36af7c0c61d1f67b3c3ebbe41de49",
"commit_date": "2026-10-28"
},
"services": [
{
@@ -300,6 +300,7 @@
"DeleteCapacityManagerDataExport",
"DeleteCarrierGateway",
"DeleteClientVpnEndpoint",
"DeleteClientVpnEndpointAuthorizationPolicy",
"DeleteClientVpnRoute",
"DeleteCoipCidr",
"DeleteCoipPool",
@@ -681,7 +682,9 @@
"GetCapacityManagerMetricData",
"GetCapacityManagerMetricDimensions",
"GetCapacityManagerMonitoredTagKeys",
"GetCapacityManagerSupportabilityScores",
"GetCapacityReservationUsage",
"GetClientVpnEndpointAuthorizationPolicy",
"GetCoipPoolUsage",
"GetConsoleOutput",
"GetConsoleScreenshot",
@@ -695,6 +698,7 @@
"GetHostReservationPurchasePreview",
"GetImageAncestry",
"GetImageBlockPublicAccessState",
"GetImageFindings",
"GetInstanceMetadataDefaults",
"GetInstanceTpmEkPub",
"GetInstanceTypesFromInstanceRequirements",
@@ -734,6 +738,7 @@
"GetSnapshotBlockPublicAccessState",
"GetSpotPlacementScores",
"GetSubnetCidrReservations",
"GetTransitGatewayAttachmentNatConfiguration",
"GetTransitGatewayAttachmentPropagations",
"GetTransitGatewayMeteringPolicyEntries",
"GetTransitGatewayMulticastDomainAssociations",
@@ -766,6 +771,7 @@
"ModifyCapacityReservation",
"ModifyCapacityReservationFleet",
"ModifyClientVpnEndpoint",
"ModifyClientVpnEndpointAuthorizationPolicy",
"ModifyDefaultCreditSpecification",
"ModifyEbsDefaultKmsKeyId",
"ModifyFleet",
@@ -814,6 +820,7 @@
"ModifyTrafficMirrorFilterRule",
"ModifyTrafficMirrorSession",
"ModifyTransitGateway",
"ModifyTransitGatewayAttachmentNatConfiguration",
"ModifyTransitGatewayMeteringPolicy",
"ModifyTransitGatewayPolicyTableEntry",
"ModifyTransitGatewayPrefixListReference",
@@ -1335,6 +1342,7 @@
"DeleteCapacityManagerDataExport",
"DeleteCarrierGateway",
"DeleteClientVpnEndpoint",
"DeleteClientVpnEndpointAuthorizationPolicy",
"DeleteClientVpnRoute",
"DeleteCoipCidr",
"DeleteCoipPool",
@@ -1653,7 +1661,9 @@
"GetCapacityManagerMetricData",
"GetCapacityManagerMetricDimensions",
"GetCapacityManagerMonitoredTagKeys",
"GetCapacityManagerSupportabilityScores",
"GetCapacityReservationUsage",
"GetClientVpnEndpointAuthorizationPolicy",
"GetCoipPoolUsage",
"GetConsoleScreenshot",
"GetDeclarativePoliciesReportSummary",
@@ -1665,6 +1675,7 @@
"GetHostReservationPurchasePreview",
"GetImageAncestry",
"GetImageBlockPublicAccessState",
"GetImageFindings",
"GetInstanceMetadataDefaults",
"GetInstanceTpmEkPub",
"GetInstanceTypesFromInstanceRequirements",
@@ -1701,6 +1712,7 @@
"GetSnapshotBlockPublicAccessState",
"GetSpotPlacementScores",
"GetSubnetCidrReservations",
"GetTransitGatewayAttachmentNatConfiguration",
"GetTransitGatewayAttachmentPropagations",
"GetTransitGatewayMeteringPolicyEntries",
"GetTransitGatewayMulticastDomainAssociations",
@@ -1732,6 +1744,7 @@
"ModifyCapacityReservation",
"ModifyCapacityReservationFleet",
"ModifyClientVpnEndpoint",
"ModifyClientVpnEndpointAuthorizationPolicy",
"ModifyDefaultCreditSpecification",
"ModifyEbsDefaultKmsKeyId",
"ModifyFleet",
@@ -1773,6 +1786,7 @@
"ModifyTrafficMirrorFilterRule",
"ModifyTrafficMirrorSession",
"ModifyTransitGateway",
"ModifyTransitGatewayAttachmentNatConfiguration",
"ModifyTransitGatewayMeteringPolicy",
"ModifyTransitGatewayPolicyTableEntry",
"ModifyTransitGatewayPrefixListReference",
@@ -1897,6 +1911,7 @@
"DescribeImages",
"DescribePullThroughCacheRules",
"DescribeRegistry",
"DescribeReplicationBackfillResults",
"DescribeRepositories",
"DescribeRepositoryCreationTemplates",
"GetAccountSetting",
@@ -1912,6 +1927,7 @@
"ListImageReferrers",
"ListImages",
"ListPullTimeUpdateExclusions",
"ListReplicationBackfills",
"ListTagsForResource",
"PutAccountSetting",
"PutImage",
@@ -1926,6 +1942,8 @@
"SetRepositoryPolicy",
"StartImageScan",
"StartLifecyclePolicyPreview",
"StartReplicationBackfill",
"StopReplicationBackfill",
"TagResource",
"UntagResource",
"UpdateImageStorageClass",
@@ -2031,14 +2049,18 @@
"DescribeImageReplicationStatus",
"DescribeImageSigningStatus",
"DescribePullThroughCacheRules",
"DescribeReplicationBackfillResults",
"DescribeRepositoryCreationTemplates",
"GetAccountSetting",
"GetSigningConfiguration",
"ListImageReferrers",
"ListPullTimeUpdateExclusions",
"ListReplicationBackfills",
"PutAccountSetting",
"PutSigningConfiguration",
"RegisterPullTimeUpdateExclusion",
"StartReplicationBackfill",
"StopReplicationBackfill",
"UpdateImageStorageClass",
"UpdatePullThroughCacheRule",
"UpdateRepositoryCreationTemplate",
@@ -2058,11 +2080,13 @@
"note": "",
"operations": {
"modelled": [
"AssociateGatewayWithCluster",
"ContinueServiceDeployment",
"CreateCapacityProvider",
"CreateCluster",
"CreateDaemon",
"CreateExpressGatewayService",
"CreateGateway",
"CreateService",
"CreateTaskSet",
"DeleteAccountSetting",
@@ -2072,6 +2096,7 @@
"DeleteDaemon",
"DeleteDaemonTaskDefinition",
"DeleteExpressGatewayService",
"DeleteGateway",
"DeleteService",
"DeleteTaskDefinitions",
"DeleteTaskSet",
@@ -2085,12 +2110,16 @@
"DescribeDaemonRevisions",
"DescribeDaemonTaskDefinition",
"DescribeExpressGatewayService",
"DescribeGateway",
"DescribeGatewayResources",
"DescribeGatewayRoute",
"DescribeServiceDeployments",
"DescribeServiceRevisions",
"DescribeServices",
"DescribeTaskDefinition",
"DescribeTaskSets",
"DescribeTasks",
"DisassociateGatewayFromCluster",
"DiscoverPollEndpoint",
"ExecuteCommand",
"GetTaskProtection",
@@ -2101,6 +2130,9 @@
"ListDaemonDeployments",
"ListDaemonTaskDefinitions",
"ListDaemons",
"ListGatewayClusterAssociations",
"ListGatewayRoutes",
"ListGateways",
"ListServiceDeployments",
"ListServices",
"ListServicesByNamespace",
@@ -2131,6 +2163,7 @@
"UpdateContainerInstancesState",
"UpdateDaemon",
"UpdateExpressGatewayService",
"UpdateGateway",
"UpdateService",
"UpdateServicePrimaryTaskSet",
"UpdateTaskProtection",
@@ -2219,15 +2252,18 @@
],
"unsupported": [],
"missing": [
"AssociateGatewayWithCluster",
"ContinueServiceDeployment",
"CreateDaemon",
"CreateExpressGatewayService",
"CreateGateway",
"CreateTaskSet",
"DeleteAccountSetting",
"DeleteAttributes",
"DeleteDaemon",
"DeleteDaemonTaskDefinition",
"DeleteExpressGatewayService",
"DeleteGateway",
"DeleteTaskDefinitions",
"DeleteTaskSet",
"DescribeDaemon",
@@ -2235,9 +2271,13 @@
"DescribeDaemonRevisions",
"DescribeDaemonTaskDefinition",
"DescribeExpressGatewayService",
"DescribeGateway",
"DescribeGatewayResources",
"DescribeGatewayRoute",
"DescribeServiceDeployments",
"DescribeServiceRevisions",
"DescribeTaskSets",
"DisassociateGatewayFromCluster",
"DiscoverPollEndpoint",
"ExecuteCommand",
"GetTaskProtection",
@@ -2245,6 +2285,9 @@
"ListDaemonDeployments",
"ListDaemonTaskDefinitions",
"ListDaemons",
"ListGatewayClusterAssociations",
"ListGatewayRoutes",
"ListGateways",
"ListServiceDeployments",
"PutAccountSettingDefault",
"PutAttributes",
@@ -2257,6 +2300,7 @@
"UpdateContainerAgent",
"UpdateDaemon",
"UpdateExpressGatewayService",
"UpdateGateway",
"UpdateServicePrimaryTaskSet",
"UpdateTaskProtection",
"UpdateTaskSet"
@@ -3099,6 +3143,7 @@
"ApplyPendingMaintenanceAction",
"AuthorizeDBSecurityGroupIngress",
"BacktrackDBCluster",
"CancelDBCapacityReservation",
"CancelExportTask",
"CopyDBClusterParameterGroup",
"CopyDBClusterSnapshot",
@@ -3107,6 +3152,7 @@
"CopyOptionGroup",
"CreateBlueGreenDeployment",
"CreateCustomDBEngineVersion",
"CreateDBCapacityReservation",
"CreateDBCluster",
"CreateDBClusterEndpoint",
"CreateDBClusterParameterGroup",
@@ -3150,6 +3196,7 @@
"DescribeAccountAttributes",
"DescribeBlueGreenDeployments",
"DescribeCertificates",
"DescribeDBCapacityReservations",
"DescribeDBClusterAutomatedBackups",
"DescribeDBClusterBacktracks",
"DescribeDBClusterEndpoints",
@@ -3204,6 +3251,7 @@
"ModifyCertificates",
"ModifyCurrentDBClusterCapacity",
"ModifyCustomDBEngineVersion",
"ModifyDBCapacityReservation",
"ModifyDBCluster",
"ModifyDBClusterEndpoint",
"ModifyDBClusterParameterGroup",
@@ -3354,6 +3402,7 @@
"ApplyPendingMaintenanceAction",
"AuthorizeDBSecurityGroupIngress",
"BacktrackDBCluster",
"CancelDBCapacityReservation",
"CancelExportTask",
"CopyDBClusterParameterGroup",
"CopyDBClusterSnapshot",
@@ -3362,6 +3411,7 @@
"CopyOptionGroup",
"CreateBlueGreenDeployment",
"CreateCustomDBEngineVersion",
"CreateDBCapacityReservation",
"CreateDBClusterEndpoint",
"CreateDBClusterParameterGroup",
"CreateDBClusterSnapshot",
@@ -3392,6 +3442,7 @@
"DescribeAccountAttributes",
"DescribeBlueGreenDeployments",
"DescribeCertificates",
"DescribeDBCapacityReservations",
"DescribeDBClusterAutomatedBackups",
"DescribeDBClusterBacktracks",
"DescribeDBClusterEndpoints",
@@ -3433,6 +3484,7 @@
"ModifyCertificates",
"ModifyCurrentDBClusterCapacity",
"ModifyCustomDBEngineVersion",
"ModifyDBCapacityReservation",
"ModifyDBClusterEndpoint",
"ModifyDBClusterParameterGroup",
"ModifyDBClusterSnapshotAttribute",
+15
View File
@@ -28,6 +28,21 @@ Spot Instance Requests are a mock over the on-demand `RunInstances` path. A requ
An AMI cannot be shared with another account or made public. `ModifyImageAttribute` refuses `LaunchPermission`, `UserIds`, `UserGroups`, `OrganizationArns`, `OrganizationalUnitArns` and `OperationType`, and `ResetImageAttribute` resets only `description`, not `launchPermission`. Each refusal is `InvalidParameterValue`. Terraform's `aws_ami_launch_permission` therefore cannot be created. `description` is the only image attribute that can be modified or reset.
### RegisterImage Registers From a Snapshot
`RegisterImage` takes a root EBS snapshot in `BlockDeviceMappings` and writes an image that points at it.
`EnaSupport` is supported, with `true` and `false` both accepted and stored on the image.
`DescribeImages` returns `EnaSupport` when the image has one and leaves the member out when it was never set, as AWS does.
`CopyImage` carries the value to the copy, and `CreateImage` sets it to `true` because every instance reports ENA support.
`RunInstances` does not read the flag, so an image registered with `EnaSupport=false` is not held back from instance types that need ENA on AWS, since guests use virtio networking either way.
`RegisterImage` refuses `ImageLocation`, `KernelId`, `RamdiskId`, `TpmSupport`, `ImdsSupport` and `SriovNetSupport`, and any `VirtualizationType` other than `hvm`.
Each refusal is `InvalidParameterValue`, and the message names the parameter and the value, for example `Value (aki-123) for parameter KernelId is invalid. KernelId is not supported.`
The same form is used for a bad `Architecture`, `BootMode` or `Name` length.
A missing `Name`, `BlockDeviceMappings` or root snapshot answers `MissingParameter` and names what is missing.
Registering with `--ena-support`, `--no-ena-support` and neither, copying the image, and three refusals were run on a three-node cluster with the AWS CLI.
Launching an instance from an `EnaSupport` image was not run, so the launch path is unchanged by construction and not by test.
### Operations
| Operation |
+15
View File
@@ -5,3 +5,18 @@ Spot Instance Requests are a mock over the on-demand `RunInstances` path. A requ
### AMI Launch Permissions Are Refused
An AMI cannot be shared with another account or made public. `ModifyImageAttribute` refuses `LaunchPermission`, `UserIds`, `UserGroups`, `OrganizationArns`, `OrganizationalUnitArns` and `OperationType`, and `ResetImageAttribute` resets only `description`, not `launchPermission`. Each refusal is `InvalidParameterValue`. Terraform's `aws_ami_launch_permission` therefore cannot be created. `description` is the only image attribute that can be modified or reset.
### RegisterImage Registers From a Snapshot
`RegisterImage` takes a root EBS snapshot in `BlockDeviceMappings` and writes an image that points at it.
`EnaSupport` is supported, with `true` and `false` both accepted and stored on the image.
`DescribeImages` returns `EnaSupport` when the image has one and leaves the member out when it was never set, as AWS does.
`CopyImage` carries the value to the copy, and `CreateImage` sets it to `true` because every instance reports ENA support.
`RunInstances` does not read the flag, so an image registered with `EnaSupport=false` is not held back from instance types that need ENA on AWS, since guests use virtio networking either way.
`RegisterImage` refuses `ImageLocation`, `KernelId`, `RamdiskId`, `TpmSupport`, `ImdsSupport` and `SriovNetSupport`, and any `VirtualizationType` other than `hvm`.
Each refusal is `InvalidParameterValue`, and the message names the parameter and the value, for example `Value (aki-123) for parameter KernelId is invalid. KernelId is not supported.`
The same form is used for a bad `Architecture`, `BootMode` or `Name` length.
A missing `Name`, `BlockDeviceMappings` or root snapshot answers `MissingParameter` and names what is missing.
Registering with `--ena-support`, `--no-ena-support` and neither, copying the image, and three refusals were run on a three-node cluster with the AWS CLI.
Launching an instance from an `EnaSupport` image was not run, so the launch path is unchanged by construction and not by test.
+68
View File
@@ -24,6 +24,74 @@ Spinifex implements **36 operations** in the ELBv2 `2015-12-01` API model.
The data plane is a system-managed load balancer VM, launched automatically during `CreateLoadBalancer`. Application Load Balancers run HAProxy for the L7 surface — rules, fixed responses and redirects over HTTP and HTTPS. Network Load Balancers run nginx `stream` for the L4 surface — TCP, UDP, TLS and TCP_UDP — because HAProxy cannot load-balance UDP. The agent selects the engine from the configuration the control plane delivers, so the choice follows the load balancer type and is not separately configurable.
### Target health and routing
Traffic goes only to targets that are healthy or still `initial`.
A target that has failed its health check is removed from the data plane on the next render and put back when it passes again.
When every target in a group is unhealthy, the load balancer fails open and sends traffic to all of them rather than refusing it.
A Network Load Balancer renders every registered server in that case, and an Application Load Balancer falls back to unchecked backup servers that HAProxy uses only when every checked server is down.
`DescribeTargetHealth` keeps reporting the targets as unhealthy while this happens.
Draining targets and targets without an address never receive traffic.
An `initial` target receives traffic before its first successful check.
This differs from AWS, where a target takes no traffic until it passes.
Health state is reset to `initial` for every target when the control plane restarts, so excluding `initial` targets would drop all traffic after a restart.
Changing the health check of a target group with `ModifyTargetGroup` takes effect on the next render of every load balancer that uses it.
The time from a backend failing to traffic stopping is the health check interval times the unhealthy threshold, plus the agent poll of about 5 seconds and the heartbeat that reports the result.
Recovery takes the interval times the healthy threshold, plus the same delays.
Measured on a three-node cluster with a 5 second interval and thresholds of 2:
| Event | Time |
| --- | --- |
| Backend starts failing to reported `unhealthy` | 21 s |
| Backend recovers to reported `healthy` | 15 s, serving again 6 s later |
| Every backend failing to reported `unhealthy` | 12 s, fail open immediate |
A TCP connection held through a Network Load Balancer survived four configuration reloads while the other backend changed state, because the agent applies nginx with a graceful reload and HAProxy with a graceful restart.
The HAProxy configuration with the backup servers was accepted by a live Application Load Balancer, but its rendered text was not dumped and checked by hand.
### Forwarding headers
An Application Load Balancer sets three headers on every HTTP and HTTPS request it forwards.
`X-Forwarded-For` carries the client address, `X-Forwarded-Proto` is `http` or `https` for the listener that accepted the request, and `X-Forwarded-Port` is that listener's port.
`X-Forwarded-Proto` and `X-Forwarded-Port` are always overwritten, so a value sent by the client never reaches the target.
Network Load Balancers do not touch the stream.
`routing.http.xff_header_processing.mode` decides what happens to `X-Forwarded-For`:
| Mode | Behaviour |
| --- | --- |
| `append` (default) | Keeps what the client sent and adds the client address last, as one comma-separated line such as `203.0.113.9, 192.0.2.10`. |
| `preserve` | Forwards the client's value unchanged and adds nothing. The header is absent when the client sent none. |
| `remove` | Drops the header, including any client value. |
`routing.http.xff_client_port.enabled` (default `false`) appends the client's source port in `append` mode, as `192.0.2.10:54321`.
An IPv6 client is written `[2001:db8::1]:54321`.
The setting has no effect in `preserve` and `remove` modes.
`ModifyLoadBalancerAttributes` accepts only `append`, `preserve` or `remove` for the mode and `true` or `false` for the client port, and rejects anything else with `ValidationError`.
A change re-renders the load balancer configuration, and a call that leaves both values as they were does not.
In a live test each change reached the target within one 3 second poll.
A client that sends `X-Forwarded-For` more than once has its lines joined into the single comma-separated value.
At most eight client lines are joined, and any beyond the eighth are dropped, while the client address is still added last.
Every other `routing.http.*` attribute is stored and returned by `DescribeLoadBalancerAttributes` but has no effect on the data plane.
Measured on a three-node cluster, with the caller on the first node:
| Listener | `X-Forwarded-For` the target saw |
| --- | --- |
| Internet-facing HTTP | The node's real address, `192.168.0.120` |
| Internet-facing HTTPS | The same address, with `https` and port 443 |
| Internal HTTP | The calling instance's private address |
| Internet-facing HTTP with a client value of `203.0.113.9` | `203.0.113.9, 192.168.0.120` on one line |
A packet capture on the load balancer's interface showed HAProxy receiving the real client address, so nothing translates it first.
Behaviour against AWS was not compared, and the cases above were not run with an IPv6 client.
### Operations
| Operation |
+68
View File
@@ -1,3 +1,71 @@
### Two data planes
The data plane is a system-managed load balancer VM, launched automatically during `CreateLoadBalancer`. Application Load Balancers run HAProxy for the L7 surface — rules, fixed responses and redirects over HTTP and HTTPS. Network Load Balancers run nginx `stream` for the L4 surface — TCP, UDP, TLS and TCP_UDP — because HAProxy cannot load-balance UDP. The agent selects the engine from the configuration the control plane delivers, so the choice follows the load balancer type and is not separately configurable.
### Target health and routing
Traffic goes only to targets that are healthy or still `initial`.
A target that has failed its health check is removed from the data plane on the next render and put back when it passes again.
When every target in a group is unhealthy, the load balancer fails open and sends traffic to all of them rather than refusing it.
A Network Load Balancer renders every registered server in that case, and an Application Load Balancer falls back to unchecked backup servers that HAProxy uses only when every checked server is down.
`DescribeTargetHealth` keeps reporting the targets as unhealthy while this happens.
Draining targets and targets without an address never receive traffic.
An `initial` target receives traffic before its first successful check.
This differs from AWS, where a target takes no traffic until it passes.
Health state is reset to `initial` for every target when the control plane restarts, so excluding `initial` targets would drop all traffic after a restart.
Changing the health check of a target group with `ModifyTargetGroup` takes effect on the next render of every load balancer that uses it.
The time from a backend failing to traffic stopping is the health check interval times the unhealthy threshold, plus the agent poll of about 5 seconds and the heartbeat that reports the result.
Recovery takes the interval times the healthy threshold, plus the same delays.
Measured on a three-node cluster with a 5 second interval and thresholds of 2:
| Event | Time |
| --- | --- |
| Backend starts failing to reported `unhealthy` | 21 s |
| Backend recovers to reported `healthy` | 15 s, serving again 6 s later |
| Every backend failing to reported `unhealthy` | 12 s, fail open immediate |
A TCP connection held through a Network Load Balancer survived four configuration reloads while the other backend changed state, because the agent applies nginx with a graceful reload and HAProxy with a graceful restart.
The HAProxy configuration with the backup servers was accepted by a live Application Load Balancer, but its rendered text was not dumped and checked by hand.
### Forwarding headers
An Application Load Balancer sets three headers on every HTTP and HTTPS request it forwards.
`X-Forwarded-For` carries the client address, `X-Forwarded-Proto` is `http` or `https` for the listener that accepted the request, and `X-Forwarded-Port` is that listener's port.
`X-Forwarded-Proto` and `X-Forwarded-Port` are always overwritten, so a value sent by the client never reaches the target.
Network Load Balancers do not touch the stream.
`routing.http.xff_header_processing.mode` decides what happens to `X-Forwarded-For`:
| Mode | Behaviour |
| --- | --- |
| `append` (default) | Keeps what the client sent and adds the client address last, as one comma-separated line such as `203.0.113.9, 192.0.2.10`. |
| `preserve` | Forwards the client's value unchanged and adds nothing. The header is absent when the client sent none. |
| `remove` | Drops the header, including any client value. |
`routing.http.xff_client_port.enabled` (default `false`) appends the client's source port in `append` mode, as `192.0.2.10:54321`.
An IPv6 client is written `[2001:db8::1]:54321`.
The setting has no effect in `preserve` and `remove` modes.
`ModifyLoadBalancerAttributes` accepts only `append`, `preserve` or `remove` for the mode and `true` or `false` for the client port, and rejects anything else with `ValidationError`.
A change re-renders the load balancer configuration, and a call that leaves both values as they were does not.
In a live test each change reached the target within one 3 second poll.
A client that sends `X-Forwarded-For` more than once has its lines joined into the single comma-separated value.
At most eight client lines are joined, and any beyond the eighth are dropped, while the client address is still added last.
Every other `routing.http.*` attribute is stored and returned by `DescribeLoadBalancerAttributes` but has no effect on the data plane.
Measured on a three-node cluster, with the caller on the first node:
| Listener | `X-Forwarded-For` the target saw |
| --- | --- |
| Internet-facing HTTP | The node's real address, `192.168.0.120` |
| Internet-facing HTTPS | The same address, with `https` and port 443 |
| Internal HTTP | The calling instance's private address |
| Internet-facing HTTP with a client value of `203.0.113.9` | `203.0.113.9, 192.168.0.120` on one line |
A packet capture on the load balancer's interface showed HAProxy receiving the real client address, so nothing translates it first.
Behaviour against AWS was not compared, and the cases above were not run with an IPv6 client.
+31 -5
View File
@@ -4,7 +4,7 @@ Generated by `make aws-model-coverage`. This file is not published: it carries t
**Not implemented** is the candidate work. **Not applicable** is declared in `pages.json` and is not work: those operations describe something this platform will not have.
Pinned model source: `github.com/aws/api-models-aws@9b1a49292744, 2026-09-25`.
Pinned model source: `github.com/aws/api-models-aws@e10d6a1c5ac3, 2026-10-28`.
## acm
@@ -46,7 +46,7 @@ Pinned model source: `github.com/aws/api-models-aws@9b1a49292744, 2026-09-25`.
## ec2
`2016-11-15` — 127 of 804 modelled operations implemented (15.8%), 0 stubbed, 39 not applicable, 0 registered outside the pinned model.
`2016-11-15` — 127 of 811 modelled operations implemented (15.7%), 0 stubbed, 39 not applicable, 0 registered outside the pinned model.
### Not implemented
@@ -190,6 +190,7 @@ Pinned model source: `github.com/aws/api-models-aws@9b1a49292744, 2026-09-25`.
- `DeleteApplicationStatusCheck`
- `DeleteCapacityManagerDataExport`
- `DeleteClientVpnEndpoint`
- `DeleteClientVpnEndpointAuthorizationPolicy`
- `DeleteClientVpnRoute`
- `DeleteCoipCidr`
- `DeleteCoipPool`
@@ -484,7 +485,9 @@ Pinned model source: `github.com/aws/api-models-aws@9b1a49292744, 2026-09-25`.
- `GetCapacityManagerMetricData`
- `GetCapacityManagerMetricDimensions`
- `GetCapacityManagerMonitoredTagKeys`
- `GetCapacityManagerSupportabilityScores`
- `GetCapacityReservationUsage`
- `GetClientVpnEndpointAuthorizationPolicy`
- `GetCoipPoolUsage`
- `GetConsoleScreenshot`
- `GetDeclarativePoliciesReportSummary`
@@ -496,6 +499,7 @@ Pinned model source: `github.com/aws/api-models-aws@9b1a49292744, 2026-09-25`.
- `GetHostReservationPurchasePreview`
- `GetImageAncestry`
- `GetImageBlockPublicAccessState`
- `GetImageFindings`
- `GetInstanceMetadataDefaults`
- `GetInstanceTpmEkPub`
- `GetInstanceTypesFromInstanceRequirements`
@@ -532,6 +536,7 @@ Pinned model source: `github.com/aws/api-models-aws@9b1a49292744, 2026-09-25`.
- `GetSnapshotBlockPublicAccessState`
- `GetSpotPlacementScores`
- `GetSubnetCidrReservations`
- `GetTransitGatewayAttachmentNatConfiguration`
- `GetTransitGatewayAttachmentPropagations`
- `GetTransitGatewayMeteringPolicyEntries`
- `GetTransitGatewayMulticastDomainAssociations`
@@ -563,6 +568,7 @@ Pinned model source: `github.com/aws/api-models-aws@9b1a49292744, 2026-09-25`.
- `ModifyCapacityReservation`
- `ModifyCapacityReservationFleet`
- `ModifyClientVpnEndpoint`
- `ModifyClientVpnEndpointAuthorizationPolicy`
- `ModifyDefaultCreditSpecification`
- `ModifyEbsDefaultKmsKeyId`
- `ModifyFleet`
@@ -601,6 +607,7 @@ Pinned model source: `github.com/aws/api-models-aws@9b1a49292744, 2026-09-25`.
- `ModifyTrafficMirrorFilterRule`
- `ModifyTrafficMirrorSession`
- `ModifyTransitGateway`
- `ModifyTransitGatewayAttachmentNatConfiguration`
- `ModifyTransitGatewayMeteringPolicy`
- `ModifyTransitGatewayPolicyTableEntry`
- `ModifyTransitGatewayPrefixListReference`
@@ -762,7 +769,7 @@ spot-price: On owned hardware there is no spot-to-on-demand price differential,
## ecr
`2015-09-21` — 23 of 58 modelled operations implemented (39.7%), 10 stubbed, 0 not applicable, 3 registered outside the pinned model.
`2015-09-21` — 23 of 62 modelled operations implemented (37.1%), 10 stubbed, 0 not applicable, 3 registered outside the pinned model.
### Not implemented
@@ -776,14 +783,18 @@ spot-price: On owned hardware there is no spot-to-on-demand price differential,
- `DescribeImageReplicationStatus`
- `DescribeImageSigningStatus`
- `DescribePullThroughCacheRules`
- `DescribeReplicationBackfillResults`
- `DescribeRepositoryCreationTemplates`
- `GetAccountSetting`
- `GetSigningConfiguration`
- `ListImageReferrers`
- `ListPullTimeUpdateExclusions`
- `ListReplicationBackfills`
- `PutAccountSetting`
- `PutSigningConfiguration`
- `RegisterPullTimeUpdateExclusion`
- `StartReplicationBackfill`
- `StopReplicationBackfill`
- `UpdateImageStorageClass`
- `UpdatePullThroughCacheRule`
- `UpdateRepositoryCreationTemplate`
@@ -819,19 +830,22 @@ spot-price: On owned hardware there is no spot-to-on-demand price differential,
## ecs
`2014-11-13` — 31 of 77 modelled operations implemented (40.3%), 5 stubbed, 0 not applicable, 3 registered outside the pinned model.
`2014-11-13` — 31 of 88 modelled operations implemented (35.2%), 5 stubbed, 0 not applicable, 3 registered outside the pinned model.
### Not implemented
- `AssociateGatewayWithCluster`
- `ContinueServiceDeployment`
- `CreateDaemon`
- `CreateExpressGatewayService`
- `CreateGateway`
- `CreateTaskSet`
- `DeleteAccountSetting`
- `DeleteAttributes`
- `DeleteDaemon`
- `DeleteDaemonTaskDefinition`
- `DeleteExpressGatewayService`
- `DeleteGateway`
- `DeleteTaskDefinitions`
- `DeleteTaskSet`
- `DescribeDaemon`
@@ -839,9 +853,13 @@ spot-price: On owned hardware there is no spot-to-on-demand price differential,
- `DescribeDaemonRevisions`
- `DescribeDaemonTaskDefinition`
- `DescribeExpressGatewayService`
- `DescribeGateway`
- `DescribeGatewayResources`
- `DescribeGatewayRoute`
- `DescribeServiceDeployments`
- `DescribeServiceRevisions`
- `DescribeTaskSets`
- `DisassociateGatewayFromCluster`
- `DiscoverPollEndpoint`
- `ExecuteCommand`
- `GetTaskProtection`
@@ -849,6 +867,9 @@ spot-price: On owned hardware there is no spot-to-on-demand price differential,
- `ListDaemonDeployments`
- `ListDaemonTaskDefinitions`
- `ListDaemons`
- `ListGatewayClusterAssociations`
- `ListGatewayRoutes`
- `ListGateways`
- `ListServiceDeployments`
- `PutAccountSettingDefault`
- `PutAttributes`
@@ -861,6 +882,7 @@ spot-price: On owned hardware there is no spot-to-on-demand price differential,
- `UpdateContainerAgent`
- `UpdateDaemon`
- `UpdateExpressGatewayService`
- `UpdateGateway`
- `UpdateServicePrimaryTaskSet`
- `UpdateTaskProtection`
- `UpdateTaskSet`
@@ -1085,7 +1107,7 @@ signing-certificates: X.509 signing certificates are an EC2-Classic SOAP credent
## rds
`2014-10-31` — 27 of 164 modelled operations implemented (16.5%), 0 stubbed, 4 not applicable, 5 registered outside the pinned model.
`2014-10-31` — 27 of 168 modelled operations implemented (16.1%), 0 stubbed, 4 not applicable, 5 registered outside the pinned model.
### Not implemented
@@ -1095,6 +1117,7 @@ signing-certificates: X.509 signing certificates are an EC2-Classic SOAP credent
- `ApplyPendingMaintenanceAction`
- `AuthorizeDBSecurityGroupIngress`
- `BacktrackDBCluster`
- `CancelDBCapacityReservation`
- `CancelExportTask`
- `CopyDBClusterParameterGroup`
- `CopyDBClusterSnapshot`
@@ -1103,6 +1126,7 @@ signing-certificates: X.509 signing certificates are an EC2-Classic SOAP credent
- `CopyOptionGroup`
- `CreateBlueGreenDeployment`
- `CreateCustomDBEngineVersion`
- `CreateDBCapacityReservation`
- `CreateDBClusterEndpoint`
- `CreateDBClusterParameterGroup`
- `CreateDBClusterSnapshot`
@@ -1133,6 +1157,7 @@ signing-certificates: X.509 signing certificates are an EC2-Classic SOAP credent
- `DescribeAccountAttributes`
- `DescribeBlueGreenDeployments`
- `DescribeCertificates`
- `DescribeDBCapacityReservations`
- `DescribeDBClusterAutomatedBackups`
- `DescribeDBClusterBacktracks`
- `DescribeDBClusterEndpoints`
@@ -1174,6 +1199,7 @@ signing-certificates: X.509 signing certificates are an EC2-Classic SOAP credent
- `ModifyCertificates`
- `ModifyCurrentDBClusterCapacity`
- `ModifyCustomDBEngineVersion`
- `ModifyDBCapacityReservation`
- `ModifyDBClusterEndpoint`
- `ModifyDBClusterParameterGroup`
- `ModifyDBClusterSnapshotAttribute`
+7 -1
View File
@@ -163,11 +163,14 @@ Open between all hosts:
| Protocol and port | Used by |
|---|---|
| UDP 6081 | Geneve tunnels |
| UDP 500, 4500 and IP protocol 50 (ESP) | IPsec for the Geneve tunnels, while IPsec is on |
| TCP 4222, 4248 | NATS |
| TCP 6641, 6642 | OVN northbound and southbound |
| TCP 8443 | Predastore S3 gate |
| UDP 6660, 7660 | Object shards, metadata consensus |
UDP 4500 carries the tunnel traffic only where IKE detects NAT between two nodes; otherwise it travels as ESP, on Oracle Linux as on Debian.
Open between the three OVN database servers (servers 1 to 3) only:
| Protocol and port | Used by |
@@ -207,7 +210,10 @@ Spinifex's own **host** firewall is separate, and already carries this policy
Choose one method and apply it to **every** server in the cluster.
**Option A — existing OS.** On a server already running Ubuntu 26.04 or Debian 13 (Oracle Linux runs a single node only for now, see [Oracle Linux Hosts](/docs/install-oracle-linux)):
**Option A — existing OS.** Use this on servers already running Ubuntu 26.04, Debian 13 or Oracle Linux 10, and prepare an Oracle Linux server with [Oracle Linux Hosts](/docs/install-oracle-linux) first.
Every server in a cluster must run the same OS: Oracle Linux never shares a cluster with Debian or Ubuntu, and `spx admin join` does not check this for you.
Run the installer on each server:
```bash
curl -fsSL https://install.mulgadc.com | bash
+43 -7
View File
@@ -1,12 +1,13 @@
---
title: "Oracle Linux Hosts"
seoTitle: "Install Spinifex on Oracle Linux 10 — Spinifex Docs"
description: "Prepare an Oracle Linux 10 host for Spinifex: UEK R8, SELinux, a NetworkManager br-wan bridge, the CentOS NFV SIG repository, firewalld handover and updates."
description: "Prepare Oracle Linux 10 hosts for Spinifex: UEK R8, SELinux, a NetworkManager br-wan bridge, the NFV SIG repository, IPsec on libreswan and host updates."
category: "Install"
tags:
- install
- oracle linux
- single node
- multi node
resources:
- title: "Oracle Linux 10 Documentation"
url: "https://docs.oracle.com/en/operating-systems/oracle-linux/10/"
@@ -35,13 +36,12 @@ Follow it alongside [Single-Node Install](/docs/install).
**Supported on Oracle Linux:**
- A single node.
- A single node, or a cluster in which every node runs Oracle Linux; servers beyond the third join as compute nodes, as on Debian.
- Guests, VPCs, routed NAT, Elastic IPs, and Application and Network Load Balancers.
- Whole-GPU passthrough, on x86_64 GPU hosts (see [GPU Passthrough](/docs/gpu-passthrough)).
**Not supported on Oracle Linux yet:**
- Clusters of more than one node. They wait for IPsec on libreswan, so `spx admin init` turns IPsec off on Oracle Linux and refuses `--ipsec=true`.
- Clusters that mix Oracle Linux with Debian or Ubuntu nodes, on any release.
- SELinux enforcing, aarch64, Oracle Linux 9 or earlier, the Red Hat Compatible Kernel, a ZFS root, and NVIDIA MIG.
@@ -51,7 +51,7 @@ Spinifex installs `openvswitch3.5` and `ovn25.03`, the versions Debian 13 ships,
QEMU comes from Oracle's KVM Utilities repository, because only that build has the `microvm` machine type Spinifex load balancers boot on.
An Oracle Linux node must be a dedicated Spinifex host.
Spinifex claims every `tap*` device and stops libreswan's `ipsec.service`, so VPNs, hand-run QEMU guests and libreswan tunnels of your own cannot share the host.
Spinifex claims every `tap*` device and owns libreswan's `ipsec.service`, which it keeps stopped on a single node and runs for its own tunnels on a cluster node, so VPNs, hand-run QEMU guests and libreswan tunnels of your own cannot share the host.
Crypto policies other than `DEFAULT` and `FIPS` are untested, and so is Secure Boot.
## Prerequisites
@@ -134,8 +134,28 @@ Run the installer as a user with `sudo`, exactly as on Debian:
curl -fsSL https://install.mulgadc.com | bash
```
Then continue with [Single-Node Install](/docs/install) from Step 2: `setup-ovn.sh --management`, `spx admin init` and `systemctl start spinifex.target`.
`spx admin init` prints that IPsec is off on this host; on a single node there is no peer to encrypt traffic to.
For a single node, continue with [Single-Node Install](/docs/install) from Step 2: `setup-ovn.sh --management`, `spx admin init` and `systemctl start spinifex.target`.
IPsec stays off on a single node, because there is no peer to encrypt traffic to.
For a cluster, prepare and install every node this way, then continue with [Multi-Node Install](/docs/install-multi-node) from Step 2.
### Clusters
Every node in an Oracle Linux cluster runs Oracle Linux.
`install-node.sh` refuses a host list that mixes Oracle Linux with Debian or Ubuntu, but `spx admin join` does not check, so keep to one OS yourself when joining by hand.
IPsec encrypts the Geneve tunnels between nodes and is on by default, as on Debian.
On Oracle Linux it runs on libreswan, the IKE daemon Oracle ships, rather than strongSwan.
Once the node's IPsec certificate exists, the daemon unmasks and starts `ipsec.service` and `openvswitch-ipsec.service`.
`ovs-monitor-ipsec` then loads the node certificate, its key and the cluster CA into libreswan's NSS database at `/var/lib/ipsec/nss`, under nicknames that start with `ovs_cert`.
The tunnels are plain ESP (IP protocol 50), as on Debian, negotiated over UDP 500.
Open UDP 500, UDP 4500 and ESP between nodes: libreswan moves to UDP 4500 if it detects NAT between two nodes.
The Spinifex host firewall opens all three to cluster peers; a firewall between the nodes must allow them too.
While IKE to a peer fails, the node drops its Geneve traffic to that peer rather than send it in clear.
The nft table `inet spinifex_ipsec_guard` drops outbound UDP 6081 from the encap address whose route carries no SA, which also covers the moments pluto flushes the xfrm policy table as it starts and stops.
It is not persisted: `ipsec.service` puts it back at boot before ovn-controller builds the tunnels, and the daemon re-syncs it every 60 seconds.
`spx admin init --ipsec=false` leaves the tunnels unencrypted, as on any OS.
## Step 2. Know What the Installer Changed
@@ -182,7 +202,9 @@ Those advisories do not cover the NFV SIG packages, so follow Open vSwitch and O
## Step 5. Uninstall
`/usr/local/share/spinifex/uninstall-spx.sh` removes Spinifex as on Debian, and lists what it leaves in place on Oracle Linux: the repository changes and the SIG key, `OVS_USER_ID` and `OVN_USER_ID`, the OVS and OVN logrotate edits, the chrony include, `/etc/modules-load.d/spinifex.conf`, the SELinux mode, a masked `ipsec.service`, firewalld disabled, and any GPU passthrough configuration.
`/usr/local/share/spinifex/uninstall-spx.sh` removes Spinifex as on Debian.
On a cluster node it also stops `openvswitch-ipsec.service` and deletes the `ovs_cert*` entries from libreswan's NSS database, so the node can join a different cluster; other NSS identities and your connection files in `/etc/ipsec.d` stay.
It lists what it leaves in place on Oracle Linux: the repository changes and the SIG key, `OVS_USER_ID` and `OVN_USER_ID`, the OVS and OVN logrotate edits, the chrony include, `/etc/modules-load.d/spinifex.conf`, the SELinux mode, a masked `ipsec.service`, firewalld disabled, and any GPU passthrough configuration.
`--purge-deps` is refused on Oracle Linux, because dnf cannot tell the packages Spinifex installed from the host's own; remove them with `dnf remove` yourself.
## Troubleshooting
@@ -224,6 +246,20 @@ If it prints `yes`, run `sudo nmcli connection modify br-wan bridge.stp no` and
Check that `/usr/bin/spx` links to `/usr/local/bin/spx`; run the installer again if it does not, or call `sudo /usr/local/bin/spx` meanwhile.
### Cluster nodes form no IPsec tunnels
Check that both IPsec services run, and that libreswan holds the node's certificate and the cluster CA:
```bash
systemctl is-active ipsec.service openvswitch-ipsec.service
sudo certutil -L -d sql:/var/lib/ipsec/nss # ovs_certkey_<node>, ovs_cert_cacert
sudo ipsec trafficstatus # one line per peer tunnel
```
If the services are inactive, check the daemon log with `journalctl -u spinifex-daemon` for the IPsec reconcile.
If the certificates are present but no tunnel is listed, check that UDP 500 and ESP pass between the nodes in both directions, and look for `SEC_ERROR_UNKNOWN_ISSUER` in `journalctl -u ipsec`, which means a peer's certificate is from another CA.
Until the tunnel forms, guest traffic between those two nodes is dropped, which is the guard in [Clusters](#clusters) working.
### CA certificate not trusted
`sudo spx admin init` installs the CA automatically. To install it again by hand on Oracle Linux:
+1 -1
View File
@@ -39,7 +39,7 @@ This guide installs Spinifex on a single server using the binary installer. For
- Ubuntu 26.04
- Debian 13
- Oracle Linux 10.2 or a later 10.x, on UEK R8, x86_64 only, as a single node. Open vSwitch and OVN come from the CentOS NFV SIG, a community repository that Oracle does not support. Prepare the host with [Oracle Linux Hosts](/docs/install-oracle-linux) first.
- Oracle Linux 10.2 or a later 10.x, on UEK R8, x86_64 only, as a single node or, with [Multi-Node Install](/docs/install-multi-node), a cluster. Open vSwitch and OVN come from the CentOS NFV SIG, a community repository that Oracle does not support. Prepare the host with [Oracle Linux Hosts](/docs/install-oracle-linux) first.
**What Gets Installed:**
+29
View File
@@ -269,6 +269,35 @@ ip link set <dev> mtu 9000 # both ends
ping -M do -s 8972 -c 3 <peer> # must succeed
```
### The internet path
A guest MTU of 1408 or 1442 sits below the 1500 bytes the internet carries, so a server can send the guest segments it cannot receive.
The VPC gateway port carries `gateway_mtu = min(guest MTU, 1500)` and answers an oversized packet with ICMP fragmentation-needed (IPv4) or Packet Too Big (IPv6).
It follows `ipsec_enabled` and `network.underlay_mtu` and converges on the next reconcile pass, with no VPC recreate.
Path MTU discovery depends on that ICMP reaching the server, and an upstream NAT router or a CDN often drops it.
vpcd therefore also clamps the TCP MSS on the host hop to the gateway MTU minus 40 (IPv4) or minus 60 (IPv6), and re-asserts the rule every 30 seconds so a firewall reload cannot remove it for long.
| Uplink | Clamp | Table |
| --- | --- | --- |
| veth (distributed NAT) | yes | `bridge spinifex_mss`, matching the `veth-wan-br` port |
| routed NAT | yes | `inet spinifex_mss`, matching `spx-nat-host` |
| physical | no host hop exists | path MTU discovery only |
On a physical uplink the only cover is path MTU discovery, which fails when the upstream drops the ICMP or the peer ignores it.
Measured on one node (env12), IPsec on, Ubuntu 26.04 guest, 16 MB HTTPS download inside a Docker container at the default bridge MTU of 1500:
| Uplink | Without the clamp | With the clamp |
| --- | --- | --- |
| veth, instance with a public IP | stalled 3/3 | completed 3/3 |
| routed NAT | stalled 3/3, no ICMP seen on the host | completed 3/3 |
An instance behind a NAT gateway on the veth uplink also completed 3/3 with the clamp; its unclamped internet run was not measured.
The guest's own `curl` completed in every case.
Without the clamp, `gateway_mtu` alone fixed the download only against a server on the same L2 with no NAT in between (completed 3/3), and not against the internet through the lab's upstream NAT router.
Not measured: a physical uplink, a multi-node cluster, IPv6, and a Debian guest.
## 5. Measurement notes
Throughput on this stack is **noisy** — repeated identical 20s runs varied between
+6 -8
View File
@@ -99,9 +99,6 @@ behavior in other words.
| 4432 | Formation server | HTTPS | Cluster (bootstrap only) | Cluster join coordination; active only while a join token is valid. Binds the node's `--bind` (lan) address. See *Formation port lifecycle* below. | Short-lived bearer token + TLS¹ |
| 4222 | spinifex-nats (client) | NATS + TLS | Cluster | Internal service bus for EC2/EBS/VPC/S3 handlers | Token + mutual TLS (cluster CA) |
| 4248 | spinifex-nats (cluster) | NATS + TLS | Cluster | Inter-node NATS federation | Token + mutual TLS (cluster CA) |
| 4223 | spinifex-sqs-store (client) | NATS + TLS | Cluster | SQS message data, separate from the control-plane bus | Store-only token + TLS |
| 4249 | spinifex-sqs-store (cluster) | NATS + TLS | Cluster | Inter-node SQS store replication | Store-only token + mutual TLS (cluster CA) |
| 8223 | spinifex-sqs-store (monitor) | HTTP | Loopback | varz and jsz for the store | Loopback only |
| 5300 | northstar | DNS (UDP + TCP) | Cluster | Forward target for every node's per-instance DNS shim, dialled cross-node. Binds the wildcard by design. | None — restrict by firewall |
| 6660 | predastore (blob node) | QUIC / UDP | Cluster | Erasure-coded object shard transport between hosts. Multi-node clusters only — see *Predastore ports* below. | TLS 1.3, server certificate verified against the cluster CA |
| 7660 | predastore (meta node) | QUIC / UDP | Cluster | Raft consensus over global state — buckets and the object index — between hosts. Multi-node clusters only. | TLS 1.3, server certificate verified against the cluster CA |
@@ -111,8 +108,8 @@ behavior in other words.
| 6643 | OVN Northbound DB (RAFT) | OVSDB/TCP | Cluster | NB database RAFT replication between the 3 quorum nodes | Cluster network only; TLS planned |
| 6644 | OVN Southbound DB (RAFT) | OVSDB/TCP | Cluster | SB database RAFT replication between the 3 quorum nodes | Cluster network only; TLS planned |
| 6081 | OVN (Geneve) | UDP | Encap | Tenant traffic overlay between chassis. A kernel UDP-tunnel socket, so packets are delivered locally and traverse the host's netfilter input hook before OVS sees them — a host firewall must accept them explicitly. The socket is opened by the kernel tunnel driver and takes no bind address, so it binds the wildcard by design and reach must be restricted by firewall. | None — see 500/4500 |
| 500, 4500 | strongSwan `charon` | IKEv2 / UDP | Encap | IKE and NAT-T for the IPsec protecting Geneve, managed entirely by `ovs-monitor-ipsec`. Binds the wildcard by design (the upstream strongSwan default, accepted rather than overridden), so reach must be restricted by firewall. | Certificate-based, against the cluster CA |
| — | ESP | IP proto 50 | Encap | The IPsec payload itself, once IKE has negotiated an SA | Cluster CA |
| 500, 4500 | strongSwan `charon`, or libreswan `pluto` on Oracle Linux | IKEv2 / UDP | Encap | IKE and NAT-T for the IPsec protecting Geneve, managed entirely by `ovs-monitor-ipsec`; 4500 carries the ESP payload only where IKE detects NAT between two nodes. `charon` binds the wildcard by design (the upstream strongSwan default, accepted rather than overridden); `pluto` binds each host address separately, the WAN address included, which is no narrower. Either way reach must be restricted by firewall. | Certificate-based, against the cluster CA |
| — | ESP | IP proto 50 | Encap | The IPsec payload itself, once IKE has negotiated an SA, on Oracle Linux as on Debian. | Cluster CA |
| 8222 | spinifex-nats (monitoring) | HTTP | Localhost | `varz`/`subsz` metrics consumed by the daemon | Loopback only |
| 323 | chronyd | NTP | Localhost | Time sync client control socket | Loopback only |
| 169.254.169.254:80 | spinifex-vpcd (IMDS) | HTTP | Guest | Instance metadata service. One socket per instance, bound to that instance's `ime-*` interface. Terminates on the host, so it traverses the netfilter input hook. | Instance identity by interface; IMDSv2 tokens |
@@ -177,7 +174,7 @@ Control-plane and data-plane traffic between Spinifex nodes, for completeness an
| OVN NB/SB (client) | 6641 / 6642 | Cluster network only (TLS planned) | Network control plane; vpcd and ovn-controller dial the quorum |
| OVN NB/SB (RAFT) | 6643 / 6644 | Cluster network only (TLS planned) | NB/SB database replication across the 3 quorum nodes |
| OVN tunnels (Geneve) | UDP 6081 | Encapsulated by IPsec when `network.ipsec_enabled` is true, which is the default on multi-node clusters | Tenant traffic overlay between chassis, on the `vpc` plane |
| OVN IPsec (IKE / NAT-T / ESP) | UDP 500, UDP 4500, IP proto 50 | Certificate-based against the cluster CA, negotiated by `ovs-monitor-ipsec` | Protects the Geneve tunnels above. OVN-native only — no layer manages strongSwan directly. |
| OVN IPsec (IKE / NAT-T / ESP) | UDP 500, UDP 4500, IP proto 50 | Certificate-based against the cluster CA, negotiated by `ovs-monitor-ipsec` | Protects the Geneve tunnels above. OVN-native only: no layer configures strongSwan or libreswan directly. On Oracle Linux the daemon also blocks outbound Geneve that no SA covers, so a peer failing IKE gets no plaintext. |
| Instance DNS forwarding | UDP/TCP 5300 | None | Each node's per-instance DNS shim forwards guest queries to peer nodes' northstar `:5300` |
Nodes **must** sit on a network segment that is not routed to tenant/guest VMs or to the internet. The Predastore blob and meta transports and the OVN DBs are cluster-internal and must not be reachable from anywhere else.
@@ -224,7 +221,7 @@ table inet spinifex_filter {
# Cluster, from peer nodes only. Replace with your nodes' lan-plane
# addresses — a CIDR does not generalise to nodes on different subnets.
ip saddr { 10.0.1.1, 10.0.1.2, 10.0.1.3 } tcp dport { 4222, 4223, 4248, 4249, 4432, 5300, 6641, 6642, 6643, 6644, 8660 } accept
ip saddr { 10.0.1.1, 10.0.1.2, 10.0.1.3 } tcp dport { 4222, 4248, 4432, 5300, 6641, 6642, 6643, 6644, 8660 } accept
ip saddr { 10.0.1.1, 10.0.1.2, 10.0.1.3 } udp dport { 5300, 6660, 7660 } accept
# Encap, from peer chassis only. Replace with your nodes' vpc-plane
@@ -239,6 +236,7 @@ Notes that make the difference between this working and locking you out:
- **Use a dedicated table and never flush the others.** `vpcd` writes MASQUERADE and per-EIP FORWARD rules into the `ip filter` and `ip nat` tables, and only reinstalls them when the service starts. `iptables -F`, `nft flush ruleset`, `ufw enable` and `firewalld` all destroy them silently, and instance networking stays broken until the next restart.
- **Do not add a `forward` hook.** nftables evaluates every table registered on a hook and any `drop` is final, so a default-deny forward chain here would override `vpcd`'s accepts in the other table and break every routed-NAT instance and every EIP. Filtering forwarded guest traffic is the security group's job, not the host firewall's.
- **`vpcd` owns a second table named `spinifex_mss`, separate from `inet spinifex_filter`.** It is a `bridge` table on the veth uplink and an `inet` table on the routed uplink, it has a `forward` hook with policy `accept`, and it only rewrites the MSS option of TCP SYN packets on the host hop to the gateway. It never drops or accepts traffic and does not replace the forward-hook advice above. `vpcd` re-installs it every 30 seconds, so a flush is repaired within that interval, and there is none on a physical uplink.
- **`output` is deliberately untouched.** The metadata service's reply path egresses through per-instance policy routing; filtering `output` breaks it in ways that are hard to attribute.
- **On a single-NIC node the cluster and encap sets are the node's public addresses**, because the planes collapse. The rules are still correct, but they are no longer a boundary — an upstream ACL is the only real control there.
@@ -250,7 +248,7 @@ Every listener and outbound destination is controlled by one of these files. Cha
| File | Keys | Controls |
|------|------|----------|
| `/etc/spinifex/spinifex.toml` | `nodes.<node>.{awsgw,nats,predastore,daemon}.host`, `nodes.<node>.vpcd.ovn_{nb,sb}_addr`, `nodes.<node>.daemon.dev_networking`, `network.ipsec_enabled` | Per-service bind addresses/ports; dev-mode QEMU port forwarding. `network.ipsec_enabled` (default `true`) decides whether OVN-native IPsec protects the Geneve tunnels, and therefore whether `charon` listens on 500/4500 — single-node clusters never enable it. |
| `/etc/spinifex/spinifex.toml` | `nodes.<node>.{awsgw,nats,predastore,daemon}.host`, `nodes.<node>.vpcd.ovn_{nb,sb}_addr`, `nodes.<node>.daemon.dev_networking`, `network.ipsec_enabled` | Per-service bind addresses/ports; dev-mode QEMU port forwarding. `network.ipsec_enabled` (default `true`) decides whether OVN-native IPsec protects the Geneve tunnels, and therefore whether the IKE daemon (`charon`, or `pluto` on Oracle Linux) listens on 500/4500 — single-node clusters never enable it. |
| `/etc/spinifex/nats.conf` | `listen`, `cluster.listen`, `cluster.routes`, `http`, `tls`, `cluster.authorization` | NATS client/cluster/monitoring listeners, peer routes, TLS, cluster token. |
| `/etc/spinifex/predastore/predastore.toml` | `[[host]].bind_addr`, `[[host]].addr`, `[[host]].tls_cert`, `[[host]].tls_key`, `[[host.node]].role`, `[[host.node]].port` | Predastore host and node layout: `bind_addr` is the address the host's sockets bind, `addr` is the address peer hosts dial it on, and both carry no port — the nodes pinned to the host supply their own. The service's `--host`/`--port` override the bind address and the gate's S3 port. |
| `/etc/spinifex/northstar/northstar.toml` | `listen`, `forwarders` | DNS listen addresses (`:53` on the advertise address, `:5300` wildcard) and upstream resolvers. |
-521
View File
@@ -1,521 +0,0 @@
# Service interface manifest.
#
# Source of truth for "which services produce/consume which NATS subjects"
# and "which e2e suites cover which services". Consumed by
# tests/e2e/select-suites (Bead 4) to derive targeted suite selection from
# a PR diff.
#
# See docs/development/improvements/e2e-targeted-suite-selection.md.
#
# Editing rules
# -------------
# - subscribes / publishes: subjects this service receives / sends. Both
# lists use the literal subject string, or a "<prefix>.*" wildcard for
# pattern subscriptions (e.g. "ebs.snapshot.*").
# - depends_on: subjects this service requires from peers. Used by the
# selector to compute "if X changes, which suites might break".
# - Subjects must match what is actually referenced in source. The lint
# in Bead 5 greps `"(ec2|vpc|ebs|s3|iam|elbv2|spinifex)\.[a-zA-Z._-]+"`
# and fails if any subject is absent from this manifest.
version: 1
services:
awsgw:
path: spinifex/runtime/roles/awsgw
# TLS frontend, SigV4 auth. Pure router: HTTP → NATS request/response.
# No subscribes; only publishes (via NATSRequest).
subscribes: []
publishes:
- "ec2.*"
- "elbv2.*"
- "acm.*"
- "route53.*"
- "iam.*"
- "rds.*"
- "ecs.*"
- "ochre.vector.*"
depends_on:
- "ec2.*"
- "elbv2.*"
- "acm.*"
- "route53.*"
- "iam.*"
- "rds.*"
- "ecs.*"
- "ochre.vector.*"
spinifex_daemon:
path: spinifex/runtime/roles/spinifex
# Orchestrator. Owns most ec2.* + all elbv2.* + iam event publication.
# Translates VPC / EBS / S3 operations into vpc.* / ebs.* / s3.* and
# forwards to vpcd / viperblockd / predastore.
#
# Source layout: spinifex/runtime/roles/spinifex (entry), spinifex/runtime/daemon
# (subscribe registration), spinifex/domains/<domain> and the legacy
# spinifex/handlers/{ecs,eks,elbv2,iam,rds} packages (per-subject handler
# bodies). Selector treats these paths as belonging to this service via
# the `additional_paths` field.
additional_paths:
- spinifex/runtime/daemon
- spinifex/domains/ec2/account
- spinifex/domains/ec2/eigw
- spinifex/domains/ec2/eip
- spinifex/domains/ec2/igw
- spinifex/domains/ec2/image
- spinifex/domains/ec2/instance
- spinifex/domains/ec2/key
- spinifex/domains/ec2/launchtemplate
- spinifex/domains/ec2/natgw
- spinifex/domains/ec2/placementgroup
- spinifex/domains/ec2/routetable
- spinifex/domains/ec2/snapshot
- spinifex/domains/ec2/spotinstance
- spinifex/domains/ec2/tags
- spinifex/domains/ec2/volume
- spinifex/domains/ec2/volumestate
- spinifex/domains/ec2/vpc
- spinifex/domains/elbv2
- spinifex/domains/acm
- spinifex/domains/route53
- spinifex/domains/iam
- spinifex/domains/ecs
- spinifex/domains/rds/instance
- spinifex/domains/rds/subnetgroup
- spinifex/domains/rds/parametergroup
- spinifex/domains/rds/engine
- spinifex/domains/ecs/taskdefinition
- spinifex/domains/eks/cluster
- spinifex/domains/eks/access
- spinifex/domains/eks/addon
# Guest add-on wire contract (subject, report, staged-manifest body).
- contracts/eks/v1
# ECS agent/scheduler Layer-2 bus wire contract (subjects, message types).
- contracts/ecs/v1
- spinifex/domains/ochre/vector
subscribes:
# EC2 instance lifecycle.
- "ec2.RunInstances"
- "ec2.DescribeInstances"
- "ec2.DescribeStoppedInstances"
- "ec2.DescribeTerminatedInstances"
- "ec2.DescribeInstanceAttribute"
- "ec2.DescribeInstanceStatus"
- "ec2.DescribeInstanceTypes"
- "ec2.ModifyInstanceAttribute"
- "ec2.ModifyVolume"
- "ec2.start"
- "ec2.terminate"
- "ec2.launch"
# contracts/ec2/v1 owns the command payload and this subject vocabulary.
# The wildcard is intentionally one final instance-ID token, not `>`.
- "ec2.cmd.*"
# EC2 VPC / network ops handled by daemon before delegation to vpcd.
- "ec2.CreateVpc"
- "ec2.DescribeVpcs"
- "ec2.CreateSubnet"
- "ec2.CreateInternetGateway"
- "ec2.CreateKeyPair"
- "ec2.CreateImage"
- "ec2.DescribePlacementGroups"
# Cluster coordination subjects.
- "ec2.ReserveClusterNode"
- "ec2.FinalizeClusterInstances"
# An EIP association reaches whichever node holds the instance, which is
# rarely the node that served the request (fan-out, no queue group).
- "ec2.eni.public-ip-changed"
# contracts/cluster/v1 owns the node status/capacity payload and subject.
- "spinifex.node.status"
# contracts/cluster/v1 owns the VM inventory payload and subject.
- "spinifex.node.vms"
- "spinifex.nodes.discover"
- "spinifex.cluster.shutdown.progress"
# Coordinated cluster-shutdown phases (fan-out, no queue group).
- "spinifex.cluster.shutdown.gate"
- "spinifex.cluster.shutdown.drain"
- "spinifex.cluster.shutdown.storage"
- "spinifex.cluster.shutdown.persist"
- "spinifex.cluster.shutdown.infra"
# Operator-plane Predastore topology contract (contracts/operator/v1).
- "spinifex.storage.config"
# ELBv2 control plane (domains/elbv2/service_nats.go topic map).
- "elbv2.CreateLoadBalancer"
- "elbv2.DeleteLoadBalancer"
- "elbv2.DescribeLoadBalancers"
- "elbv2.CreateTargetGroup"
- "elbv2.DeleteTargetGroup"
- "elbv2.DescribeTargetGroups"
- "elbv2.RegisterTargets"
- "elbv2.DeregisterTargets"
- "elbv2.DescribeTargetHealth"
- "elbv2.CreateListener"
- "elbv2.DeleteListener"
- "elbv2.DescribeListeners"
# ACM-alike certificate store (domains/acm; subscribed in daemon.go).
- "acm.ImportCertificate"
- "acm.DescribeCertificate"
- "acm.ListCertificates"
- "acm.DeleteCertificate"
# Route 53 hosted zones (domains/route53; subscribed in daemon.go).
- "route53.*"
# Operator-only zone activation and delegation, sent by spx admin dns.
- "route53.admin.*"
- "elbv2.AddListenerCertificates"
- "elbv2.RemoveListenerCertificates"
- "elbv2.DescribeListenerCertificates"
- "elbv2.DescribeSSLPolicies"
# RDS control plane (domains/rds/instance/subjects.go). One wildcard rather than
# 30 literals: every action subject is registered from a constant, so a
# per-subject list would be a hand-mirror of that file with nothing
# checking it.
- "rds.*"
# ECS control plane (domains/ecs/service_nats.go, registered in
# daemon.go). One wildcard, as for RDS: every action subject is a literal
# in those two files, so a per-subject list would only mirror them.
- "ecs.*"
# Layer-2 agent bus: register and health are wildcard subscriptions over
# {account}.{db-instance}, so the subject is built at runtime and only the
# prefix is declarable.
- "rds.bus.*"
# ECS Layer-2 scheduler/agent bus (contracts/ecs/v1): account, cluster and
# instance/task IDs are runtime-built, so only the prefix is declarable.
# Only the leader holds these subscriptions, so there is no queue group.
- "ecs.bus.*"
# Ochre vector store tenant surface (domains/ochre/vector/api.go),
# gated behind config.OchreVectorConfig.Enabled (default off).
- "ochre.vector.createIndex"
- "ochre.vector.deleteIndex"
- "ochre.vector.listIndexes"
- "ochre.vector.ingest"
- "ochre.vector.describeJob"
- "ochre.vector.query"
- "ochre.vector.listJobs"
- "ochre.vector.stopJob"
# Fence route owned by contracts/viperblockd/legacy/v1: viperblockd
# announces a torn-down export so this node stops the guest that was
# using it. "ebs.fenced" is the single-node form; a named node is
# addressed as "ebs.<node>.fenced".
- "ebs.fenced"
publishes:
# → vpcd
- "vpc.create"
- "vpc.delete"
- "vpc.create-subnet"
- "vpc.delete-subnet"
- "vpc.create-sg"
- "vpc.delete-sg"
- "vpc.update-sg"
- "vpc.create-port"
- "vpc.delete-port"
- "vpc.update-port-sgs"
# EC2-to-network projection owned by contracts/ec2/v1. The network
# subscriber realizes it in OVN without reading EC2 private state.
- "vpc.igw-attach"
- "vpc.igw-detach"
- "vpc.add-nat-gateway"
- "vpc.delete-nat-gateway"
- "vpc.add-nat"
- "vpc.delete-nat"
- "vpc.dhcp.acquire"
- "vpc.dhcp.release"
# Per-subnet route-table projections owned by domains/ec2/routetable:
# IGW default-route reachability and the egress gate/ungate decision it
# implies, published fire-and-forget on every route-table mutation.
- "vpc.add-igw-route"
- "vpc.delete-igw-route"
- "vpc.gate-subnet-egress"
- "vpc.ungate-subnet-egress"
# Egress-only reroute removal for a single system instance
# (domains/eks/cluster). Fire-and-forget. vpc.add-system-egress has no
# current producer.
- "vpc.delete-system-egress"
# → viperblockd
# The migrated legacy ebs.config and ebs.sync payloads and routes are
# owned by contracts/viperblockd/legacy/v1. They are transitional and
# distinct from the generic providers/ebs protocol; other legacy ebs.*
# routes remain to be migrated separately.
- "ebs.mount"
- "ebs.unmount"
- "ebs.delete"
- "ebs.sync"
- "ebs.snapshot.*"
- "ebs.config"
- "ebs.config.*"
# Abandon route owned by contracts/viperblockd/legacy/v1: the daemon
# asks viperblockd to tear an export down without sealing. "ebs.abandon"
# is the single-node form; a named node addresses "ebs.<node>.abandon".
- "ebs.abandon"
# → predastore (S3 / AMI / keypair store)
- "s3.*"
# → every daemon, so the one holding the instance reports the new address
- "ec2.eni.public-ip-changed"
# IAM lifecycle event
- "iam.account.created"
# → the in-guest rds-agent: set-password and the like, published on the
# per-instance command subject and answered on its reply subject.
- "rds.bus.*"
# ECS service-reconcile self-wake (contracts/ecs/v1): the worker that
# recorded a task-state change is rarely the leader, so this fans the
# wake out and the leader's own "ecs.bus.*" subscription picks it up.
- "ecs.bus.*"
depends_on:
- "vpc.*"
- "ebs.*"
- "s3.*"
vpcd:
path: spinifex/runtime/roles/vpcd
# OVN-backed VPC / subnet / SG / NAT / IGW data plane.
subscribes:
- "vpc.create"
- "vpc.delete"
- "vpc.create-subnet"
- "vpc.delete-subnet"
- "vpc.create-sg"
- "vpc.delete-sg"
- "vpc.update-sg"
- "vpc.create-port"
- "vpc.delete-port"
- "vpc.update-port-sgs"
- "vpc.igw-attach"
- "vpc.igw-detach"
- "vpc.add-nat-gateway"
- "vpc.delete-nat-gateway"
- "vpc.add-nat"
- "vpc.delete-nat"
- "vpc.dhcp.acquire"
- "vpc.dhcp.release"
- "vpc.add-igw-route"
- "vpc.delete-igw-route"
- "vpc.gate-subnet-egress"
- "vpc.ungate-subnet-egress"
- "vpc.add-system-egress"
- "vpc.delete-system-egress"
publishes:
- "vpc.port-status"
- "vpc.dhcp.lease-changed"
- "vpc.dhcp.owner-check"
depends_on: []
viperblockd:
path: spinifex/runtime/roles/viperblockd
# EBS data plane. Backed by the viperblock storage engine in the
# mulga/viperblock submodule. Submodule pointer bump → selector forces
# "run all" (contract changes can be invisible at the spinifex source
# level).
# The migrated legacy ebs.config and ebs.sync routes are versioned by
# contracts/viperblockd/legacy/v1, not by providers/ebs. Other legacy
# ebs.* routes remain to be migrated separately.
# The dirty-marker JetStream KV bucket VIPERBLOCK_VOLUME_DIRTY is owned
# by the same contract; not a NATS subject, so not listed below.
#
# Source layout: spinifex/runtime/roles/viperblockd (role: process lifecycle,
# NATS subscription wiring) and spinifex/providers/ebs/viperblock (the
# Viperblock EBS provider adapter the role wires up). Selector treats the
# adapter path as belonging to this service via `additional_paths`.
additional_paths:
- spinifex/providers/ebs/viperblock
subscribes:
- "ebs.mount"
- "ebs.unmount"
- "ebs.delete"
- "ebs.sync"
- "ebs.snapshot.*"
- "ebs.config"
- "ebs.config.*"
# Abandon route (contracts/viperblockd/legacy/v1): request/reply from
# the daemon, answered by the Viperblock adapter on the named node.
- "ebs.abandon"
publishes:
- "ebs.mount.response"
# Fence route (contracts/viperblockd/legacy/v1): announced after the
# Viperblock adapter tears an export down because its lease moved.
- "ebs.fenced"
- "ebs.unmount.response"
depends_on: []
predastore:
path: spinifex/runtime/roles/predastore
# S3 / AMI / keypair storage. External submodule under mulga/predastore;
# this dir contains only the spinifex-side adapter. Submodule pointer
# bump → selector forces "run all".
subscribes:
- "s3.*"
publishes: []
depends_on: []
nats:
path: spinifex/runtime/roles/nats
# NATS broker bootstrap / cluster config. Not a NATS pub/sub
# participant. Any change here is infra-path; selector forces
# "run all".
subscribes: []
publishes: []
depends_on: []
spinifexui:
path: spinifex/runtime/roles/spinifexui
# Web UI. Talks to awsgw over HTTP, never NATS. Diffs limited to this
# dir do not need any e2e suite to run.
subscribes: []
publishes: []
depends_on: []
covers_no_suite: true
# Fixture → service mapping. Each Ensure* helper in
# tests/e2e/harness/fixtures.go exercises this set of services; the
# Bead 4 selector AST-scans test files for harness.Ensure* call sites
# and resolves coverage via this block.
fixtures:
EnsureKeyPair:
services: [spinifex_daemon, predastore]
EnsureAMI:
services: [spinifex_daemon, predastore, viperblockd]
EnsureDefaultVPC:
services: [vpcd, spinifex_daemon]
EnsureSubnet:
services: [vpcd, spinifex_daemon]
EnsureSG:
services: [vpcd, spinifex_daemon]
EnsureInstance:
services: [spinifex_daemon, viperblockd, vpcd]
EnsureVolume:
services: [spinifex_daemon, viperblockd]
EnsureSnapshot:
services: [spinifex_daemon, viperblockd, predastore]
EnsureNATGateway:
services: [vpcd, spinifex_daemon]
EnsureLoadBalancer:
services: [spinifex_daemon, awsgw]
suites:
e2e-cert:
path: tests/e2e/cert
covers: [awsgw, spinifex_daemon, vpcd, predastore]
e2e-lb:
path: tests/e2e/lb
covers: [awsgw, spinifex_daemon, vpcd, viperblockd, predastore]
# Exercises full ELBv2 control plane (domains/elbv2) + data plane
# (LB agent on the system VM). ELBv2 is part of spinifex_daemon in
# this manifest; revisit if it splits into a standalone service.
e2e-single:
path: tests/e2e/single
covers: [awsgw, spinifex_daemon, vpcd, viperblockd, predastore]
# Full single-node lifecycle: VPC, AMI, keypair, instance, volume,
# snapshot, IAM. Currently runs all phases sequentially under one
# `TestSingleNode`. Bead 3 (single-fixture-migration) splits this
# into per-test fixture-driven coverage so the selector can pick
# subtests, not just whole suites.
e2e-iam:
path: tests/e2e/iam
covers: [awsgw, spinifex_daemon, vpcd, viperblockd, predastore]
# "Everything IAM": the IAM/STS control plane plus the instance-identity
# tests (instance-profile association + IMDS), which boot guest VMs — OVN
# via vpcd, AMI via predastore, root volume via viperblockd, lifecycle via
# spinifex_daemon. Single-mode, VM-booting leg.
e2e-ecr:
path: tests/e2e/ecr
covers: [awsgw, spinifex_daemon, predastore]
# ECR control plane (domains/ecr, gateway/ecr*) + OCI data plane: blobs and
# manifests in predastore, control + auth bridge in awsgw, KV via
# spinifex_daemon. docker/crane/skopeo data-plane subtests skip when the
# client binary or registry-host resolution is absent.
e2e-bedrock:
path: tests/e2e/bedrock
covers: [awsgw]
# Ochre (AWS-Bedrock) control plane: static catalog list/get served
# straight from awsgw (gateway/bedrock.go, domains/ochre/) — no NATS
# hop to spinifex_daemon. Converse (Anthropic-direct / self-host vLLM)
# subtests are gated on backend availability and skip by default.
e2e-ecs:
path: tests/e2e/ecs
covers: [awsgw, spinifex_daemon, vpcd, viperblockd, predastore]
# ECS data plane end-to-end: cluster + a real container instance launched
# from the spinifex-ecs-node AMI (boots, registers over the gateway, runs
# tasks through containerd), standalone tasks in awsvpc/bridge/host modes,
# and an awsvpc service fronted by an ELBv2 target group. Boots a guest VM,
# so vpcd (OVN + awsvpc ENI), viperblockd (root volume), predastore (AMI)
# are all in the path.
e2e-rds:
path: tests/e2e/rds
covers: [awsgw, spinifex_daemon, vpcd, viperblockd, predastore]
# RDS create/describe/connect: CreateDBInstance boots a dual-NIC DB VM from
# the engine AMI (predastore) with a Viperblock data volume (viperblockd) and
# a customer ENI (vpcd), and the reconciler flips it to available on the
# in-guest agent's first healthy heartbeat over awsgw. Every test deletes the
# instances it creates, so the suite needs no gate beyond SPINIFEX_E2E.
e2e-ddil:
path: tests/e2e/ddil
covers: [awsgw, spinifex_daemon, vpcd, viperblockd, predastore]
# DDIL = degraded / disconnected / intermittent / low-bandwidth.
# Exercises the full daemon stack under network failure injection;
# any service touching the wire path is in scope.
e2e-route53:
path: tests/e2e/route53
covers: [awsgw, spinifex_daemon, predastore]
# Hosted zones end to end: delegation check, publish to the northstar zone
# store in predastore, and every node answering before a change is INSYNC.
# Suites below are bash-only today. Entries activate as the Go ports
# land (Bead 2 fixtures unblock new-shape ports for multinode etc.).
#
# e2e-multinode:
# path: spinifex/tests/e2e/multinode
# covers: [awsgw, spinifex_daemon, vpcd, viperblockd, predastore]
# e2e-reboot:
# path: spinifex/tests/e2e/reboot
# covers: [spinifex_daemon, viperblockd]
# e2e-tofu:
# path: spinifex/tests/e2e/tofu
# covers: [awsgw, spinifex_daemon, vpcd]
# e2e-bm:
# path: spinifex/tests/e2e/baremetal
# covers: [awsgw, spinifex_daemon, vpcd, viperblockd, predastore]
#
# e2e-natuplink activates once CI can provision an external_mode=nat
# node (setup-ovn.sh --nat-uplink + spx admin init --external-mode=nat).
# e2e-natuplink:
# path: spinifex/tests/e2e/natuplink
# covers: [awsgw, spinifex_daemon, vpcd, viperblockd, predastore]
# Special-case rules consumed by the selector (Bead 4). Hard-coded in
# the tool, listed here for visibility.
#
# infra_paths_force_all:
# - spinifex/runtime/roles/nats/**
# - spinifex/tests/e2e/harness/**
# - spinifex/tests/e2e/lib/**
# - spinifex/.github/workflows/e2e-go.yml
# - spinifex/.github/scripts/**
# - spinifex/Makefile
# - mulga/scripts/tofu-cluster/**
#
# submodule_force_all:
# - mulga/predastore (submodule pointer)
# - mulga/viperblock (submodule pointer)
#
# many_services_force_all_threshold: 3 # ≥ N services touched → run all
+8 -3
View File
@@ -40,7 +40,7 @@ Runs **on** a node, shelling out to `ip`/`iptables`/`ovn-nbctl` locally. Skips u
Phases 7 and 8 are gated on a cluster by what the datapath can actually do: the transit segment is a localnet, so host-to-guest Tier 1 ingress only exists where the VPC's gateway router port and the guest are both on this host. The VPC ingress route itself is installed on every node, so phase 8 checks it unconditionally.
Three nightly cells run it: `nat-single` (cell 19), its Oracle Linux twin (cell 36) and `nat-multi` (cell 30). Cell 20 is the bare-metal job and is not in the permutation matrix at all, which is why the multi-node NAT cell is numbered past the end rather than filling a gap.
Four nightly cells run it: `nat-single` (cell 19) and `nat-multi` (cell 30), and their Oracle Linux twins (cells 36 and 38). Cell 20 is the bare-metal job and is not in the permutation matrix at all, which is why the multi-node NAT cell is numbered past the end rather than filling a gap.
### `multinode` — behaviour that only exists on more than one node
@@ -50,6 +50,9 @@ Three nightly cells run it: `nat-single` (cell 19), its Oracle Linux twin (cell
**`TestMultinodeDNS` convergence budgets are env-tunable.** `SPINIFEX_MULTINODE_DNS_TOPOLOGY_TIMEOUT` (default `90s`) bounds every node agreeing on the NS topology, `SPINIFEX_MULTINODE_DNS_TIMEOUT` (default `2m`) bounds a record becoming answerable from a guest or a node, and `SPINIFEX_MULTINODE_DNS_POLL` (default `3s`) is the poll interval for both. Values are Go durations; a malformed or non-positive value panics rather than falling back to the default.
**`TestMultinodeOVNRaft` restarts each node's OVN central in turn before it kills the NB leader.**
A `setup-ovn.sh` rerun restarts a node's NB and SB members together, on EL through the one `ovn-northd.service`, so the test does the same on every database node in turn, waits for both members to be back as cluster members under a known leader, and requires an NB write to land after each step and the full quorum with one leader at the end.
**`TestMultinodeIPSec` proves guest traffic is encrypted on the wire, not only that IPsec is configured.**
It first requires every node to carry the OVS certificate, key and CA pointers, `NB_Global.ipsec=true` never asserted over an unconfigured chassis, and an AES-GCM SA in `ip xfrm state`.
None of those fails when SAs exist but traffic bypasses them, so it then launches two instances on distinct nodes and sends 200 pings of 1000 bytes between them.
@@ -112,9 +115,12 @@ CA installed and downloadable, fingerprint matches config, hostnames present in
Internal and internet-facing ALB and NLB, HTTPS listeners, listener rules, `ModifyListener`, and NLB UDP.
Unhealthy-target routing: an NLB with an HTTP health check on a TCP target group stops sending traffic to a target that fails it while still accepting TCP, sends traffic again once it recovers, and fails open when every target is unhealthy.
An ALB whose targets all fail their health check keeps serving from them instead of answering 503.
### `eks`, `ecs`, `ecr` — container services
`eks`: cluster create/delete, access entries, addon delivery, `GetToken`, kubeconfig artifacts, the EBS CSI volume path, and an IRSA pod wired with a projected SA token. `ecs`: clusters, container instances, the three network modes (`awsvpc`, `bridge`, `host`), task-role credentials fetched from the container credentials endpoint, a service behind an ELB, and ENI release on terminate. `ecr`: control-plane CRUD plus a real OCI data plane — docker login/build/push/pull round trips, multi-layer images, and raw blob HTTP.
`eks`: cluster create/delete, access entries, addon delivery, `GetToken`, kubeconfig artifacts, the EBS CSI volume path, an IRSA web-identity exchange under the stock AWS trust policy (`StringEquals` on the issuer host-path `:sub`/`:aud`, a mismatched `:sub` denied with `AccessDenied`, a `StringLike` `:sub` granted), and an IRSA pod wired with a projected SA token. `ecs`: clusters, container instances, the three network modes (`awsvpc`, `bridge`, `host`), task-role credentials fetched from the container credentials endpoint, a service behind an ELB, and ENI release on terminate. `ecr`: control-plane CRUD plus a real OCI data plane — docker login/build/push/pull round trips, multi-layer images, and raw blob HTTP.
### `rds` — managed databases
@@ -137,7 +143,6 @@ The create/describe/connect path against a live cluster: a DB VM that actually b
- **`ddil`** — Denied, Disrupted, Intermittent, Limited network scenarios.
- **`teardown`** — sweeps leftovers.
- **`harness`** — shared primitives, not a suite. `harness/vpc_egress.go` carries the VPC/subnet/IGW/NAT-gateway fixtures the egress scenarios build on.
- **`manifest-check`, `manifest-lint`** — manifest validation, not cluster behaviour.
## Keeping this honest
+1 -1
View File
@@ -33,6 +33,7 @@ require (
github.com/mulgadc/viperblock v1.23.0
github.com/nats-io/nats-server/v2 v2.15.1
github.com/nats-io/nats.go v1.54.0
github.com/nats-io/nkeys v0.4.16
github.com/opencontainers/runtime-spec v1.3.0
github.com/oracle/oci-go-sdk/v65 v65.128.0
github.com/ovn-kubernetes/libovsdb v0.9.0
@@ -161,7 +162,6 @@ require (
github.com/muesli/termenv v0.16.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nats-io/jwt/v2 v2.8.2 // indirect
github.com/nats-io/nkeys v0.4.16 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
+2 -2
View File
@@ -77,8 +77,8 @@ func TestEC2ErrorCatalogMetadataAndClasses(t *testing.T) {
if catalog.metadata.VerifiedOn == "" {
t.Fatal("verifiedOn is empty")
}
if len(catalog.codes) != 114 {
t.Fatalf("catalog code count = %d, want 114", len(catalog.codes))
if len(catalog.codes) != 115 {
t.Fatalf("catalog code count = %d, want 115", len(catalog.codes))
}
if catalog.codes["InvalidParameterValue"] != ec2ErrorClassClient {
t.Fatal("InvalidParameterValue is not classified as client")
+2 -2
View File
@@ -5,6 +5,6 @@ package awsmodel
// ModelCommit is the github.com/aws/api-models-aws commit the embedded
// models were taken from, and ModelCommitDate the day it was committed.
const (
ModelCommit = "9b1a4929274443d8671ea8acfda7afbe856e29e9"
ModelCommitDate = "2026-09-25"
ModelCommit = "e10d6a1c5ac36af7c0c61d1f67b3c3ebbe41de49"
ModelCommitDate = "2026-10-28"
)
+5 -5
View File
@@ -21,13 +21,13 @@ func TestLoadAllModels(t *testing.T) {
shapes int
}{
ACM: {"2015-12-08", 40, 239},
EC2: {"2016-11-15", 804, 4245},
ECR: {"2015-09-21", 58, 404},
ECS: {"2014-11-13", 77, 643},
EKS: {"2017-11-01", 70, 450},
EC2: {"2016-11-15", 811, 4297},
ECR: {"2015-09-21", 62, 426},
ECS: {"2014-11-13", 88, 734},
EKS: {"2017-11-01", 70, 458},
ElasticLoadBalancingV2: {"2015-12-01", 51, 418},
IAM: {"2010-05-08", 180, 624},
RDS: {"2014-10-31", 164, 791},
RDS: {"2014-10-31", 168, 816},
Route53: {"2013-04-01", 71, 409},
S3: {"2006-03-01", 112, 710},
STS: {"2011-06-15", 11, 101},
Binary file not shown.
Binary file not shown.
@@ -50,6 +50,7 @@
"InvalidCapacityReservationId.Malformed",
"InvalidCapacityReservationId.NotFound",
"InvalidEgressOnlyInternetGatewayId.NotFound",
"InvalidGatewayID.NotFound",
"InvalidGroup.Duplicate",
"InvalidGroup.NotFound",
"InvalidGroup.Reserved",
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3 -2
View File
@@ -111,7 +111,7 @@ func GenerateRequests(service Service, operationName string, options RequestOpti
}
for _, member := range append([]string{""}, optional...) {
if unguessable[member] {
if unguessable[member] && options.Fixtures[operationName+"."+member] == "" && options.Fixtures[member] == "" {
continue
}
value, _, err := generate()
@@ -157,7 +157,8 @@ func GenerateRequests(service Service, operationName string, options RequestOpti
// unguessable members take values the model cannot describe: a pagination
// token the service issued, or a filter name only its documentation lists.
// They get rejection requests but no acceptance request.
// They get rejection requests, and an acceptance request only when a fixture
// supplies a value.
var unguessable = map[string]bool{
"Filter": true,
"Filters": true,
+14
View File
@@ -337,6 +337,20 @@ func TestGenerateRequestsSkipsAcceptanceForUnguessableMembers(t *testing.T) {
require.NotEmpty(t, markerRejections, "a pagination token still gets rejection requests")
}
func TestGenerateRequestsAcceptsAFixtureForAnUnguessableMember(t *testing.T) {
options := testRequestOptions
options.Fixtures = map[string]string{"ListRoles.Marker": "fixture-marker"}
plan, err := GenerateRequests(IAM, "ListRoles", options)
require.NoError(t, err)
var markers []any
for _, request := range plan.Cases {
if request.Acceptance() && request.Member == "Marker" {
markers = append(markers, request.Input["Marker"])
}
}
require.Equal(t, []any{"fixture-marker"}, markers)
}
func TestGenerateRequestsUsesResourceHints(t *testing.T) {
tests := []struct {
service Service
+3 -2
View File
@@ -7,9 +7,10 @@ Node installation, dev-environment lifecycle, guest image builds, and verificati
| Script | What it does |
|---|---|
| `setup.sh` | The production binary installer, served from `install.mulgadc.com`. Installs deps, users, sudoers, the host firewall policy, files, systemd units, logrotate and udev rules, and loads `openvswitch`, `geneve`, `vhost_net` and `tun`, listing them in `/etc/modules-load.d/spinifex.conf` for later boots. It masks firewalld wherever it is installed, since the Spinifex nftables policy is the only supported node firewall. An unset `--firewall` keeps the mode recorded in `/etc/spinifex/firewall/mode`, and otherwise arms the policy when firewalld was active. Where systemd-resolved is installed but not running, resolvconf is absent and NetworkManager runs, it hands host DNS to resolved: it saves `/etc/resolv.conf` once to `/var/lib/spinifex-reset/resolv.conf.orig`, links `/etc/resolv.conf` to the resolved stub, and stops unless resolved has upstream servers and the package repository host still resolves. It links `/usr/bin/spx` to `/usr/local/bin/spx` where sudo's PATH leaves out `/usr/local/bin`, and takes the nbdkit plugin directory from `nbdkit --dump-config`, stopping when nbdkit cannot say. `SETUP_STAGES` runs a subset; `ISO_BUILD=1` runs it inside the ISO builder's chroot. |
| `setup-ovn.sh` | Bootstraps a compute node for OVN VPC networking: installs OVN/OVS, creates `br-int`, configures the WAN bridge (bridged, DHCP, or routed-NAT uplink), sets the chassis identity, and applies overlay sysctls. It runs OVS and OVN as root, setting `OVS_USER_ID` and `OVN_USER_ID` where `/etc/sysconfig` holds them, and hooks the socket-permission helper onto `ovs-vswitchd`, `ovn-controller`, `openvswitch-ipsec` and, on EL, `ovn-northd`. `--management` also starts the OVN central services, writes their `ovn-ctl` flags to `/etc/default/ovn-central` (Debian) or `/etc/sysconfig/ovn-northd` (EL), and records the role in `/etc/spinifex/ovn-role`. A later run without `--management` refuses while that file, or the `OVN_CTL_OPTS` line older nodes carry in `/etc/default/ovn-central`, records the role. It adds `maxsize 100M` to the OVS and OVN logrotate files, plus `rotate 5` where the file sets no count, and rotates as root, matching the daemons. On a host whose IPsec stack is libreswan it stops and masks `openvswitch-ipsec.service` and `ipsec.service`, because OVN IPsec does not run on libreswan yet; elsewhere it enables and starts `openvswitch-ipsec.service`, unless the daemon has masked it to keep IPsec off. The links it creates persist through systemd-networkd where that is enabled, and otherwise through `/etc/spinifex/hostnet.json`, which `spinifex-hostnet.service` (`spx admin hostnet apply`) replays at boot and on every OVS start, starting `ovn-controller` again when an OVS stop took it down; the first run records the choice in `/etc/spinifex/hostnet-backend`. Where NetworkManager runs, it leaves the links Spinifex owns unmanaged. |
| `setup-ovn.sh` | Bootstraps a compute node for OVN VPC networking: installs OVN/OVS, creates `br-int`, configures the WAN bridge (bridged, DHCP, or routed-NAT uplink), sets the chassis identity, and applies overlay sysctls. It runs OVS and OVN as root, setting `OVS_USER_ID` and `OVN_USER_ID` where `/etc/sysconfig` holds them, and hooks the socket-permission helper onto `ovs-vswitchd`, `ovn-controller`, `openvswitch-ipsec` and, on EL, `ovn-northd`. `--management` also starts the OVN central services, writes their `ovn-ctl` flags to `/etc/default/ovn-central` (Debian) or `/etc/sysconfig/ovn-northd` (EL), and records the role in `/etc/spinifex/ovn-role`. With clustered databases it returns only once this node's NB and SB members are back in their RAFT clusters under a known leader, and fails after `OVN_RAFT_REJOIN_WAIT` seconds (default 60) otherwise, so reruns one node at a time never take two members of a cluster down. A later run without `--management` refuses while that file, or the `OVN_CTL_OPTS` line older nodes carry in `/etc/default/ovn-central`, records the role. It adds `maxsize 100M` to the OVS and OVN logrotate files, plus `rotate 5` where the file sets no count, and rotates as root, matching the daemons. On a host whose IPsec stack is libreswan it enables, stops and masks `openvswitch-ipsec.service` and `ipsec.service` for the daemon to unmask when IPsec is on, unless `openvswitch-ipsec.service` is already running; elsewhere it enables and starts `openvswitch-ipsec.service`, unless the daemon has masked it to keep IPsec off. The links it creates persist through systemd-networkd where that is enabled, and otherwise through `/etc/spinifex/hostnet.json`, which `spinifex-hostnet.service` (`spx admin hostnet apply`) replays at boot and on every OVS start, starting `ovn-controller` again when an OVS stop took it down; the first run records the choice in `/etc/spinifex/hostnet-backend`. Where NetworkManager runs, it leaves the links Spinifex owns unmanaged. |
| `install-node.sh` | Forms a multi-node cluster across hosts that are already running Spinifex: rebuilds the OVN database in clustered form, runs `spx admin init` on the first host and `spx admin join` on the rest, then verifies. Before touching any host it refuses hosts of different OS families (`distro_os_family`) or `spx` versions, and `--ipsec on` when any host uses libreswan. The scripted form of [install-multi-node](../docs/install/install-multi-node/README.md). Destroys the joining nodes' logical network state and crypto — see its `--help`. |
| `dev-install.sh` | Full local dev setup through the production installer: builds from source, packs a tarball, runs `setup.sh`, initialises the cluster, and starts services under systemd. |
| `build-oracle-appliance.sh` | Turns an Oracle Linux 10.2 system reachable over SSH with sudo into a sealed gold image, then powers it off. It updates OL and reboots into the newest UEK R8, sets SELinux permissive, installs Spinifex without initialising it, and leaves `spinifex.target` and the NATS watchdog disabled. It creates the `spinifex` login with a default password that must be changed at first login, installs `appliance/firstboot.sh` as `spinifex-appliance-firstboot.service`, and wipes the system's identity (machine-id, SSH host keys, OVS chassis, NetworkManager profiles, logs). On each unit's first boot that service puts the first physical NIC with carrier on a DHCP `br-wan`, names the host `spinifex-<mac>`, runs `setup-ovn.sh --management` and `spx admin init --nodes 1`, and shows the IP and login on the console and in `/etc/motd`. `--channel`, `--version` and `--tarball` pick what to install. |
| `clone-deps.sh` | Clones or updates the viperblock and predastore checkouts alongside spinifex for cross-repo development. |
### `lib/distro.sh`: host-OS capability probes
@@ -58,7 +59,7 @@ Both ship to `/usr/local/share/spinifex/` on every node, so they are available o
| Script | What it does |
|---|---|
| `node-reset.sh` | Clears **state** and leaves the node installed: stops services, destroys guests, wipes `/etc/spinifex`, `/var/lib/spinifex`, `/var/log/spinifex` and the OVN databases, and removes the OVS bridges. It stops OVS and OVN central by the unit names the host's packages use. It leaves the NetworkManager unmanaged-device config, which the next `setup-ovn.sh` run rewrites, so NetworkManager cannot take a NIC back in between. The node is then ready for a fresh `spx admin init`. `--keep-data` preserves `/var/lib/spinifex`; `SPX_RESET_CONFIRM=reset` runs it unattended. |
| `node-reset.sh` | Clears **state** and leaves the node installed: stops services, destroys guests, wipes `/etc/spinifex`, `/var/lib/spinifex`, `/var/log/spinifex` and the OVN databases, and removes the OVS bridges. On a libreswan host it deletes the `ovs_cert_*` and `ovs_certkey_*` entries `ovs-monitor-ipsec` imported into libreswan's NSS database, leaving other identities and `/etc/ipsec.d/*.conf` alone. It stops OVS and OVN central by the unit names the host's packages use. It leaves the NetworkManager unmanaged-device config, which the next `setup-ovn.sh` run rewrites, so NetworkManager cannot take a NIC back in between. The node is then ready for a fresh `spx admin init`. `--keep-data` preserves `/var/lib/spinifex`; `SPX_RESET_CONFIRM=reset` runs it unattended. |
| `uninstall-spx.sh` | Removes the **software** — the inverse of `setup.sh`. Delegates the state teardown above to `node-reset.sh` rather than reimplementing it, then removes the binary, the nbdkit plugin, the systemd units and slices, the service users, the sudoers grant, the sysctl/logrotate/chrony/udev drop-ins, the `systemd-networkd` units, the host firewall policy and its loaded nft table, the Spinifex systemd-resolved drop-in, and the Spinifex CA from the host trust store. It unmasks firewalld and leaves it disabled. Where `setup.sh` handed DNS to systemd-resolved, it restores the saved `/etc/resolv.conf` and turns resolved off. Verifies afterwards and exits non-zero naming anything that survived, then lists the host settings `setup.sh` changed that it leaves in place, such as the dnf repositories, `OVS_USER_ID`, masked IPsec units and the SELinux mode. |
`node-reset.sh` finds guests by process name, `qemu-system-*` or `qemu-kvm`, owned by the daemon's service user, and waits for them to exit before it deletes any state.
+146
View File
@@ -0,0 +1,146 @@
#!/bin/bash
# Spinifex appliance first boot, for Oracle Linux units cloned from the gold
# image that build-oracle-appliance.sh seals. The OL counterpart of the ISO's
# spinifex-firstboot.sh: it also does the per-unit work the ISO installer does
# before first boot (hostname, br-wan on the NIC that is present), then sets
# up a single node. On success it writes $DONE_MARKER and the unit's
# ConditionPathExists=! stops it running again. A failed run leaves no marker,
# so the next boot retries from the top; every step below is safe to repeat.
set -euo pipefail
DONE_MARKER=/var/lib/spinifex/.appliance-firstboot-done
SHARE=/usr/local/share/spinifex
# shellcheck source=lib.sh
. "$SHARE/appliance/lib.sh"
# shellcheck source=../lib/distro.sh
. "$SHARE/lib/distro.sh"
log() { echo "[appliance-firstboot] $*"; }
if [ -f "$DONE_MARKER" ]; then
log "already complete, skipping"
exit 0
fi
# ── Primary NIC ─────────────────────────────────────────────────────────────
# Links start down when NetworkManager has no profile for them, so bring every
# physical NIC up to read its carrier, and give a cable up to 60s to come up.
nics=$(appliance_physical_nics)
if [ -z "$nics" ]; then
log "no physical Ethernet device found"
exit 1
fi
for nic in $nics; do
ip link set "$nic" up || true
done
for _i in $(seq 1 60); do
for nic in $nics; do
[ "$(cat "/sys/class/net/$nic/carrier" 2>/dev/null)" = 1 ] && break 2
done
sleep 1
done
NIC=$(appliance_pick_nic)
MAC=$(cat "/sys/class/net/$NIC/address")
log "primary NIC $NIC ($MAC), carrier $(cat "/sys/class/net/$NIC/carrier" 2>/dev/null || echo 0)"
HOSTNAME_NEW=$(appliance_hostname "$MAC")
hostnamectl set-hostname "$HOSTNAME_NEW"
log "hostname $HOSTNAME_NEW"
# ── br-wan on the primary NIC, DHCP ─────────────────────────────────────────
# The bridge takes the NIC's MAC so a DHCP reservation made for the unit's
# port keeps working. bridge.stp no: with STP on, the port sits in its
# forwarding delay long enough for DHCP on the bridge to time out.
for con in $(nmcli -g UUID,DEVICE connection show | awk -F: -v d="$NIC" '$2 == d {print $1}'); do
nmcli connection delete "$con" || true
done
nmcli connection delete br-wan br-wan-port >/dev/null 2>&1 || true
nmcli connection add type bridge ifname br-wan con-name br-wan \
bridge.stp no bridge.mac-address "$MAC" \
ipv4.method auto ipv6.method disabled connection.autoconnect yes
nmcli connection add type bridge-slave ifname "$NIC" master br-wan con-name br-wan-port \
connection.autoconnect yes
nmcli connection up br-wan || true
log "waiting for a DHCP address on br-wan"
WAN_IP=""
for _i in $(seq 1 120); do
WAN_IP=$(ip -4 -o addr show br-wan scope global 2>/dev/null | awk '{print $4}' | cut -d/ -f1 | head -1)
if [ -n "$WAN_IP" ] && ip -4 route show default dev br-wan | grep -q .; then
break
fi
WAN_IP=""
sleep 1
done
if [ -z "$WAN_IP" ]; then
log "br-wan got no DHCP address and default route in 120s; check the cable on $NIC and the site's DHCP"
exit 1
fi
log "br-wan $WAN_IP"
# ── Clock ───────────────────────────────────────────────────────────────────
# Credentials and TLS certificates are minted below, and a certificate issued
# against a wrong RTC carries a NotBefore that outlives the correction.
# Bounded and non-fatal, as on the ISO.
chronyc -a makestep >/dev/null 2>&1 || true
if chronyc waitsync 12 0.1 0 5 >/dev/null 2>&1; then
log "clock synced: $(date -uIs)"
else
log "WARNING: clock not synced, continuing with $(date -uIs)"
fi
# ── OVS and OVN ─────────────────────────────────────────────────────────────
# Start them before setup-ovn.sh so their databases exist when it runs: on
# physical hardware first-boot DB initialisation outlasts its own timeout.
OVS_UNIT=$(distro_ovs_unit)
OVN_LAYOUT=$(distro_ovn_central_layout)
case $OVN_LAYOUT in
split) OVN_CENTRAL_UNIT=ovn-central.service ;;
lone-northd) OVN_CENTRAL_UNIT=ovn-northd.service ;;
esac
systemctl start "$OVS_UNIT" "$OVN_CENTRAL_UNIT"
for _i in $(seq 1 120); do
if ovn-nbctl --timeout=2 get-connection >/dev/null 2>&1; then
log "OVN NB DB ready (${_i}s)"
break
fi
sleep 1
done
"$SHARE/setup-ovn.sh" --management
# ── Single-node cluster ─────────────────────────────────────────────────────
# Same arguments as the ISO's single-NIC DHCP path. spx writes credentials to
# disk and never prints them.
spx admin init --node "$HOSTNAME_NEW" --nodes 1 2>&1
# spx ran as root, so the files it wrote are root:root. setup.sh's fixown
# stage knows each file's owner and mode.
SETUP_STAGES=fixown "$SHARE/setup.sh"
# ── spinifex login ──────────────────────────────────────────────────────────
if [ ! -f /home/spinifex/.ssh/id_ed25519 ]; then
install -d -m 700 -o spinifex -g spinifex /home/spinifex/.ssh
ssh-keygen -q -t ed25519 -f /home/spinifex/.ssh/id_ed25519 -N "" -C "spinifex@$HOSTNAME_NEW"
chown spinifex:spinifex /home/spinifex/.ssh/id_ed25519 /home/spinifex/.ssh/id_ed25519.pub
fi
# init wrote the AWS profile under HOME=/root; the operator logs in as spinifex.
if [ -f /root/.aws/credentials ]; then
install -d -m 700 -o spinifex -g spinifex /home/spinifex/.aws
install -m 600 -o spinifex -g spinifex /root/.aws/credentials /home/spinifex/.aws/credentials
[ -f /root/.aws/config ] && install -m 600 -o spinifex -g spinifex /root/.aws/config /home/spinifex/.aws/config
fi
# ── Services ────────────────────────────────────────────────────────────────
# Enabled here, not in the image, so a clone runs nothing of Spinifex before
# init has written its config.
systemctl enable spinifex.target spinifex-banner.service spinifex-firewall.service
systemctl enable --now spinifex-nats-watchdog.timer
mkdir -p "$(dirname "$DONE_MARKER")"
touch "$DONE_MARKER"
systemctl start spinifex.target
/usr/local/bin/spx admin banner --boot-check
log "complete: https://$WAN_IP:3000, login spinifex"
+4
View File
@@ -0,0 +1,4 @@
# Holds the console login prompt until first boot and the banner have written
# /etc/issue, so the unit's IP shows before anyone logs in.
[Unit]
After=spinifex-appliance-firstboot.service spinifex-banner.service
+37
View File
@@ -0,0 +1,37 @@
#!/bin/bash
# Helpers shared by the appliance first-boot script and its test. Sourced, not run.
# appliance_physical_nics — physical Ethernet devices, one per line, in PCI
# order. Skips anything without a backing device (bridges, veths, OVS ports,
# loopback), non-Ethernet link types and wireless. SYSFS overrides /sys.
appliance_physical_nics() {
local sys="${SYSFS:-/sys}/class/net" dev
for dev in "$sys"/*; do
[ -e "$dev/device" ] || continue
[ "$(cat "$dev/type" 2>/dev/null)" = 1 ] || continue
[ -d "$dev/wireless" ] && continue
printf '%s %s\n' "$(readlink -f "$dev/device")" "$(basename "$dev")"
done | sort | awk '{print $2}'
}
# appliance_pick_nic — the first physical NIC with carrier, else the first
# physical NIC. Prints nothing when the host has none.
appliance_pick_nic() {
local sys="${SYSFS:-/sys}/class/net" nic first=""
for nic in $(appliance_physical_nics); do
[ -n "$first" ] || first=$nic
if [ "$(cat "$sys/$nic/carrier" 2>/dev/null)" = 1 ]; then
echo "$nic"
return 0
fi
done
[ -n "$first" ] && echo "$first"
return 0
}
# appliance_hostname <mac> — spinifex-<last 6 hex digits of the MAC>.
appliance_hostname() {
local hex
hex=$(echo "$1" | tr -d ':' | tr '[:upper:]' '[:lower:]')
echo "spinifex-${hex: -6}"
}
+63
View File
@@ -0,0 +1,63 @@
#!/bin/sh
# lib_test.sh — tests for the appliance first-boot NIC and hostname helpers,
# run against a fixture sysfs tree (SYSFS) so the host's own NICs never count.
set -eu
DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
fails=0
pass() { echo " ok - $1"; }
fail() { echo " FAIL - $1"; fails=$((fails + 1)); }
echo "-- appliance/lib.sh"
# nic <name> <pci-slot> <carrier> [type] — a physical NIC behind a PCI device.
nic() {
mkdir -p "$SYS/devices/pci0000:00/$2" "$SYS/class/net/$1"
ln -s "../../../devices/pci0000:00/$2" "$SYS/class/net/$1/device"
echo "${4:-1}" > "$SYS/class/net/$1/type"
echo "$3" > "$SYS/class/net/$1/carrier"
}
# virt <name> — a link with no backing device (bridge, veth, OVS port).
virt() {
mkdir -p "$SYS/class/net/$1"
echo 1 > "$SYS/class/net/$1/type"
echo 1 > "$SYS/class/net/$1/carrier"
}
fixture() { SYS="$TMP/$1"; mkdir -p "$SYS/class/net"; }
run() { SYSFS="$SYS" bash -c ". '$DIR/lib.sh'; $1"; }
check() {
if [ "$2" = "$3" ]; then pass "$1"; else fail "$1: want '$2', got '$3'"; fi
}
fixture order
nic enp3s0 0000:00:03.0 0
nic enp1s0 0000:00:01.0 0
virt br-wan
virt lo
check "physical NICs in PCI order, virtual links skipped" "enp1s0 enp3s0" "$(run appliance_physical_nics | tr '\n' ' ' | sed 's/ $//')"
check "no carrier anywhere picks the first by PCI order" enp1s0 "$(run appliance_pick_nic)"
fixture carrier
nic eno1 0000:00:01.0 0
nic eno2 0000:00:02.0 1
nic eno3 0000:00:03.0 1
check "the first NIC with carrier wins over PCI order" eno2 "$(run appliance_pick_nic)"
fixture wireless
nic wlp1s0 0000:00:01.0 1
mkdir -p "$SYS/class/net/wlp1s0/wireless"
nic ib0 0000:00:02.0 1 32
nic enp4s0 0000:00:04.0 0
check "wireless and non-Ethernet links are skipped" enp4s0 "$(run appliance_pick_nic)"
fixture none
virt br-wan
check "no physical NIC prints nothing" "" "$(run appliance_pick_nic)"
check "hostname from the MAC's last 6 hex digits" spinifex-c0ffee "$(run 'appliance_hostname 52:54:00:C0:FF:EE')"
[ "$fails" -eq 0 ] || { echo " $fails failed"; exit 1; }
+191
View File
@@ -0,0 +1,191 @@
#!/bin/bash
# Runs as root on the Oracle Linux build system, one stage per call, driven by
# build-oracle-appliance.sh from the payload directory it copied over.
# prepare.sh check refuse anything but OL 10.2+ on UEK R8, x86_64
# prepare.sh update dnf update, SELinux permissive; prints PREPARE_REBOOT=1 if
# the newest kernel is not the running one
# prepare.sh install install Spinifex, uninitialised and not enabled
# prepare.sh appliance spinifex login, first-boot service, console placeholder
# prepare.sh seal wipe this system's identity, then power off
# INSTALL_SPINIFEX_CHANNEL, INSTALL_SPINIFEX_VERSION and INSTALL_SPINIFEX_TARBALL
# pick the release tarball to install. BUILD_USER is the SSH user to lock at seal.
set -euo pipefail
# Shared by every unit built from this image; first login forces a change.
DEFAULT_PASSWORD=spinifex
HERE=$(cd "$(dirname "$0")" && pwd)
SHARE=/usr/local/share/spinifex
log() { echo "[prepare] $*"; }
die() { echo "[prepare] ERROR: $*" >&2; exit 1; }
[ "$(id -u)" = 0 ] || die "run as root"
stage_check() {
# shellcheck source=/dev/null
. /etc/os-release
[ "${ID:-}" = ol ] || die "not Oracle Linux (ID=${ID:-unset})"
local major=${VERSION_ID%%.*} minor=${VERSION_ID#*.}
[ "$minor" = "$VERSION_ID" ] && minor=0
if [ "$major" -lt 10 ] || { [ "$major" -eq 10 ] && [ "$minor" -lt 2 ]; }; then
# A 10.0 or 10.1 system reaches 10.2 through the update stage, which
# calls this again with "strict" once it has run.
if [ "$major" -ne 10 ] || [ "${1:-}" = strict ]; then
die "Oracle Linux $VERSION_ID; 10.2 or later is required"
fi
log "Oracle Linux $VERSION_ID; the update stage brings it to the current minor"
fi
[ "$(uname -m)" = x86_64 ] || die "$(uname -m); only x86_64 is supported"
case $(uname -r) in
6.12.0-*uek*) ;;
*) die "running kernel $(uname -r) is not UEK R8; install kernel-uek and boot it first" ;;
esac
command -v nmcli >/dev/null || die "NetworkManager (nmcli) is required"
log "OK: $PRETTY_NAME, kernel $(uname -r)"
}
stage_update() {
setenforce 0 2>/dev/null || true
sed -i 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
[ "$(getenforce)" != Enforcing ] || die "SELinux is still enforcing"
dnf update -y
stage_check strict >/dev/null
local newest
newest=$(grubby --default-kernel | sed 's|^/boot/vmlinuz-||')
case $newest in
6.12.0-*uek*) ;;
*) die "the default boot kernel is $newest, not UEK R8; set a kernel-uek default with grubby" ;;
esac
if [ "$newest" != "$(uname -r)" ]; then
echo PREPARE_REBOOT=1
fi
}
stage_install() {
[ ! -e /etc/spinifex/spinifex.toml ] || die "/etc/spinifex/spinifex.toml exists; this system has been initialised, start from a clean OL install"
# install.mulgadc.com serves the latest stable setup.sh, which may predate
# Oracle Linux support, so run the setup.sh inside the release tarball.
local dir tarball
dir=$(mktemp -d)
if [ -n "${INSTALL_SPINIFEX_TARBALL:-}" ]; then
tarball=$INSTALL_SPINIFEX_TARBALL
else
local url="https://install.mulgadc.com/download/${INSTALL_SPINIFEX_VERSION:-${INSTALL_SPINIFEX_CHANNEL:-latest}}/amd64"
tarball=$dir/spinifex.tar.gz
log "downloading $url"
curl -fsSL -o "$tarball" "$url"
curl -fsSL -o "$dir/checksum.sha256" "$url.sha256"
[ "$(awk '{print $1}' "$dir/checksum.sha256")" = "$(sha256sum "$tarball" | awk '{print $1}')" ] \
|| die "checksum mismatch for $url"
fi
tar -xzf "$tarball" -C "$dir" ./setup.sh
INSTALL_SPINIFEX_TARBALL=$tarball INSTALL_SPINIFEX_SKIP_NEWGRP=1 bash "$dir/setup.sh"
rm -rf "$dir"
# The installer enables these on a live host. The ISO image ships them off
# and first boot enables them after init; a clone that started them first
# would run every service with no config.
systemctl disable --now spinifex.target spinifex-nats-watchdog.timer
log "Spinifex $(spx version 2>/dev/null | head -1) installed, not initialised"
}
stage_appliance() {
# As on the ISO: the existing spinifex system group as primary, so the
# login can reach the sockets setup.sh group-owns, and passwordless sudo.
if ! id spinifex >/dev/null 2>&1; then
useradd --create-home --shell /bin/bash --gid spinifex --groups wheel spinifex
fi
echo "spinifex:$DEFAULT_PASSWORD" | chpasswd
chage -d 0 spinifex
echo 'spinifex ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/spinifex-admin
chmod 0440 /etc/sudoers.d/spinifex-admin
visudo -cf /etc/sudoers.d/spinifex-admin >/dev/null
# OL's pwquality gives one try per login, then ends the session, so say the
# rules up front. spx admin banner keeps /etc/motd content above its own
# section, and agetty shows /etc/issue.d beside the banner in /etc/issue.
local hint="First login: the new password needs 8+ characters and must not contain 'spinifex'."
printf '%s\n' "$hint" > /etc/motd
install -d /etc/issue.d
printf '%s\n\n' "$hint" > /etc/issue.d/spinifex-password.issue
# sshd takes the first value it reads, so this sorts ahead of the
# 50-cloud-init.conf that templates ship with passwords off.
printf 'PasswordAuthentication yes\n' > /etc/ssh/sshd_config.d/10-spinifex-appliance.conf
# No DHCP on every port: first boot puts the primary NIC on br-wan and
# leaves the rest alone, so no second port competes for the default route.
printf '[main]\nno-auto-default=*\n' > /etc/NetworkManager/conf.d/90-spinifex-appliance.conf
install -D -m 0644 "$HERE/lib.sh" "$SHARE/appliance/lib.sh"
install -D -m 0755 "$HERE/firstboot.sh" "$SHARE/appliance/firstboot.sh"
install -m 0644 "$HERE/spinifex-appliance-firstboot.service" "$HERE/spinifex-banner.service" /etc/systemd/system/
local getty
for getty in getty@tty1 serial-getty@ttyS0; do
install -D -m 0644 "$HERE/getty-wait.conf" "/etc/systemd/system/$getty.service.d/spinifex-wait.conf"
done
systemctl daemon-reload
systemctl enable spinifex-appliance-firstboot.service
# Cloud-init would re-run on each unit with no datasource and rewrite the
# network and users first boot owns.
if [ -d /etc/cloud ]; then
touch /etc/cloud/cloud-init.disabled
fi
log "spinifex login (default password '$DEFAULT_PASSWORD', change forced) and first-boot service installed"
}
stage_seal() {
dnf clean all
systemctl stop "$(. "$SHARE/lib/distro.sh" && distro_ovs_unit)" ovn-northd.service ovn-controller.service 2>/dev/null || true
# OVS writes the chassis UUID on first start; a shared one makes every unit
# the same chassis in OVN.
rm -f /etc/openvswitch/system-id.conf /etc/openvswitch/conf.db /etc/openvswitch/.conf.db.~lock~
rm -f /var/lib/ovn/*.db /etc/ovn/*.db
rm -f /etc/spinifex/node.conf
# Profiles for the build system's NICs, its DHCP leases and NM's
# per-machine secret. First boot writes br-wan for the unit's own NIC.
rm -f /etc/NetworkManager/system-connections/*
rm -f /var/lib/NetworkManager/*.lease /var/lib/NetworkManager/secret_key \
/var/lib/NetworkManager/timestamps /var/lib/NetworkManager/seen-bssids
if command -v cloud-init >/dev/null; then
cloud-init clean --logs || true
fi
# sshd-keygen regenerates host keys before sshd on the next boot; systemd
# generates a machine-id when the file is empty.
rm -f /etc/ssh/ssh_host_*
truncate -s 0 /etc/machine-id
rm -f /var/lib/dbus/machine-id /var/lib/systemd/random-seed
echo localhost > /etc/hostname
# The build user's access goes; the spinifex login is the way in.
if [ -n "${BUILD_USER:-}" ] && [ "$BUILD_USER" != spinifex ] && [ "$BUILD_USER" != root ]; then
local home
home=$(getent passwd "$BUILD_USER" | cut -d: -f6)
rm -f "$home/.ssh/authorized_keys" "$home/.bash_history"
passwd -l "$BUILD_USER" >/dev/null
rm -f /etc/sudoers.d/90-cloud-init-users /etc/sudoers.d/90-spinifex-build
fi
rm -f /root/.ssh/authorized_keys /root/.bash_history /home/spinifex/.bash_history
printf '\nSpinifex first boot is in progress. This screen updates when it finishes.\n\n' > /etc/issue
sed -i '/^# --- Spinifex ---$/,$d' /etc/motd 2>/dev/null || true
find /var/log -type f -exec truncate -s 0 {} + 2>/dev/null || true
rm -rf /var/log/journal/* /tmp/* /var/tmp/*
sync
log "sealed; powering off"
systemctl poweroff --no-block
}
case "${1:-}" in
check) stage_check ;;
update) stage_update ;;
install) stage_install ;;
appliance) stage_appliance ;;
seal) stage_seal ;;
*) die "usage: $0 check|update|install|appliance|seal" ;;
esac
@@ -0,0 +1,22 @@
[Unit]
Description=Spinifex appliance first-boot provisioning
After=NetworkManager.service network-online.target chronyd.service
Wants=NetworkManager.service network-online.target
ConditionPathExists=!/var/lib/spinifex/.appliance-firstboot-done
[Service]
Type=oneshot
Environment=HOME=/root
ExecStart=/usr/local/share/spinifex/appliance/firstboot.sh
RemainAfterExit=yes
# The banner is never enabled when first boot fails, so without this the
# console would keep the "first boot in progress" placeholder.
ExecStopPost=/bin/sh -c 'if [ "$EXIT_STATUS" != "0" ]; then printf "\n*** Spinifex first boot FAILED ***\nLog in as spinifex, then run:\n sudo journalctl -u spinifex-appliance-firstboot.service\nCheck the network cable and DHCP, then reboot to retry.\n\n" > /etc/issue; fi'
# setup-ovn.sh and spx admin init must not wedge multi-user.target and keep
# getty from ever showing a login prompt.
TimeoutStartSec=600s
StandardOutput=journal+console
StandardError=journal+console
[Install]
WantedBy=multi-user.target
+15
View File
@@ -0,0 +1,15 @@
[Unit]
Description=Spinifex console banner and boot health check
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/spx admin banner --boot-check
RemainAfterExit=yes
# Cap it so a stuck boot-check cannot hold getty behind the console drop-in.
TimeoutStartSec=30s
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
+113
View File
@@ -0,0 +1,113 @@
#!/bin/bash
# build-oracle-appliance.sh — turn an Oracle Linux 10.2 system reachable over
# SSH with sudo into a sealed Spinifex gold image: installed, not initialised,
# with a first-boot service that sets each cloned unit up as a single node.
# The system powers off at the end; capture its disk as the image.
#
# Usage: build-oracle-appliance.sh [options] <user>@<host>
# --channel latest|dev install channel (default: latest)
# --version <tag> install a specific release
# --tarball <path> install a local release tarball instead
#
# Ports, keys and jump hosts come from ~/.ssh/config. <user> needs sudo;
# without passwordless sudo, sudo asks for its password once.
set -euo pipefail
HERE=$(cd "$(dirname "$0")" && pwd)
PAYLOAD_SRC="$HERE/appliance"
REMOTE_DIR=/tmp/spinifex-appliance
CHANNEL="" VERSION="" TARBALL="" TARGET=""
usage() { sed -n '2,13p' "$0" | sed 's/^# \{0,1\}//'; exit "${1:-0}"; }
log() { echo "==> $*"; }
die() { echo "ERROR: $*" >&2; exit 1; }
while [ $# -gt 0 ]; do
case "$1" in
--channel) CHANNEL="${2:-}"; shift ;;
--version) VERSION="${2:-}"; shift ;;
--tarball) TARBALL="${2:-}"; shift ;;
-h | --help) usage ;;
-*) die "unknown option: $1" ;;
*) [ -z "$TARGET" ] || die "one target only"; TARGET=$1 ;;
esac
shift
done
[ -n "$TARGET" ] || usage 1
case $TARGET in *@*) ;; *) die "target must be <user>@<host>" ;; esac
BUILD_USER=${TARGET%@*}
[ -z "$TARBALL" ] || [ -f "$TARBALL" ] || die "no such tarball: $TARBALL"
# One multiplexed connection; host key checking is relaxed because the build
# system is usually a fresh install whose key nobody has recorded yet.
CTL_DIR=$(mktemp -d)
trap 'ssh -o ControlPath="$CTL_DIR/c" -O exit "$TARGET" >/dev/null 2>&1 || true; rm -rf "$CTL_DIR"' EXIT
SSH_OPTS=(-o ControlMaster=auto -o ControlPath="$CTL_DIR/c" -o ControlPersist=60
-o StrictHostKeyChecking=accept-new -o ServerAliveInterval=15 -o ConnectTimeout=10)
rsh() { ssh "${SSH_OPTS[@]}" "$TARGET" "$@"; }
# prepare <stage> — run one prepare.sh stage as root on the build system.
prepare() {
rsh "sudo env INSTALL_SPINIFEX_CHANNEL='$CHANNEL' INSTALL_SPINIFEX_VERSION='$VERSION' \
INSTALL_SPINIFEX_TARBALL='${TARBALL:+$REMOTE_DIR/$(basename "$TARBALL")}' \
BUILD_USER='$BUILD_USER' bash $REMOTE_DIR/prepare.sh $1"
}
push_payload() {
rsh "rm -rf $REMOTE_DIR && mkdir -p $REMOTE_DIR"
tar -C "$PAYLOAD_SRC" -cf - . | rsh "tar -C $REMOTE_DIR -xf -"
if [ -n "$TARBALL" ]; then
scp "${SSH_OPTS[@]}" -q "$TARBALL" "$TARGET:$REMOTE_DIR/"
fi
}
wait_for_ssh() {
local _i
ssh "${SSH_OPTS[@]}" -O exit "$TARGET" >/dev/null 2>&1 || true
sleep 10
for _i in $(seq 1 60); do
if rsh true 2>/dev/null; then return 0; fi
sleep 5
done
die "$TARGET did not come back over SSH after the reboot"
}
rsh true || die "cannot SSH to $TARGET; set its key in ~/.ssh/config (IdentityFile) or ssh-add it"
# The stages run sudo with no terminal, so grant passwordless sudo for the
# build when the user lacks it. Seal removes the grant.
if ! rsh "sudo -n true" 2>/dev/null; then
log "Granting $BUILD_USER passwordless sudo for the build; sudo asks for its password once"
ssh "${SSH_OPTS[@]}" -t "$TARGET" "echo '$BUILD_USER ALL=(ALL) NOPASSWD:ALL' | sudo tee /etc/sudoers.d/90-spinifex-build >/dev/null && sudo chmod 0440 /etc/sudoers.d/90-spinifex-build" \
|| die "could not grant $BUILD_USER passwordless sudo on the build system"
rsh "sudo -n true" || die "$BUILD_USER still has no passwordless sudo on the build system"
fi
# A minimal OL install has no tar, which the payload copy and the installer need.
rsh "command -v tar >/dev/null || sudo dnf install -y -q tar" || die "cannot install tar on the build system"
log "Copying the payload to $TARGET"
push_payload
prepare check
log "Updating Oracle Linux"
prepare update | tee "$CTL_DIR/update.log"
if grep -qx 'PREPARE_REBOOT=1' "$CTL_DIR/update.log"; then
log "Rebooting into the updated kernel"
rsh "sudo systemctl reboot" || true
wait_for_ssh
# /tmp is cleared on boot.
push_payload
prepare check
fi
log "Installing Spinifex (not initialising it)"
prepare install
log "Installing the spinifex login and the first-boot service"
prepare appliance
log "Sealing; the system powers off when done"
prepare seal || true
log "Done. Capture $TARGET's disk once it has powered off; each unit set up from it initialises itself on first boot."
+475
View File
@@ -0,0 +1,475 @@
#!/bin/bash
# build-sqs-store-microvm-image.sh — build the SQS store microVM kernel +
# initramfs: the dedicated nats-server, ext4 support, the store's guest steps
# and a clean power-down. The guest never formats a disk; build/microvm/
# sqs-store/sqs-store-lib.sh states its fw_cfg contract. The LB image
# (build-microvm-image.sh) is separate and unchanged.
#
# Inputs:
# $REPO_ROOT/build/microvm/sqs-store/init.sh, inittab
# $REPO_ROOT/build/microvm/sqs-store/sqs-store-{lib.sh,prepare,run,stop}
# $REPO_ROOT/bin/nats-server (make bin/nats-server, the go.mod-pinned version)
#
# Outputs:
# $REPO_ROOT/build/microvm/sqs-store/vmlinuz
# $REPO_ROOT/build/microvm/sqs-store/initramfs.cpio.gz
#
# Rootfs strategy (first match wins):
# 1. apk available on host → install directly into a temp chroot (Alpine CI/CD)
# 2. docker available → run alpine container, export filesystem
# 3. podman available → same via podman
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
BUILD_DIR="$REPO_ROOT/build/microvm/sqs-store"
INIT_SH="$BUILD_DIR/init.sh"
INITTAB="$BUILD_DIR/inittab"
NATS_SERVER_BIN="$REPO_ROOT/bin/nats-server"
ALPINE_VERSION="${ALPINE_VERSION:-3.24}"
ALPINE_MIRROR="${ALPINE_MIRROR:-https://dl-cdn.alpinelinux.org/alpine}"
# e2fsprogs: mkfs.ext4/e2fsck for a guest that mounts an ext4 data volume.
# kmod: the image's own depmod/modprobe rebuild module metadata below.
ALPINE_PACKAGES="busybox linux-virt iproute2 ca-certificates e2fsprogs kmod"
# Modules kept by name on top of the virtio/fw_cfg/failover globs, each with its
# full depends= and softdep closure. tiny_power_button turns the ACPI power
# button (QMP system_powerdown) into a signal busybox init handles as poweroff.
MICROVM_EXTRA_MODULES="${MICROVM_EXTRA_MODULES:-ext4 tiny_power_button}"
echo "[build-sqs-store-microvm-image] repo root: $REPO_ROOT"
echo "[build-sqs-store-microvm-image] build dir: $BUILD_DIR"
mkdir -p "$BUILD_DIR"
# --- Verify non-negotiable tools ---
# fakeroot is mandatory: device nodes are written into the cpio archive inside a
# faked-root environment so no real device node is ever created on the host
# filesystem (which previously required sudo mknod and risked clobbering host
# /dev/null on cleanup).
for tool in cpio gzip find fakeroot; do
if ! command -v "$tool" >/dev/null 2>&1; then
echo "ERROR: required tool not found: $tool" >&2
exit 1
fi
done
# --- Verify the dedicated nats-server is the go.mod-pinned build ---
# A stale or host-installed binary would ship an unreviewed server version.
NATS_SERVER_PIN=$(awk '$1 == "github.com/nats-io/nats-server/v2" { print $2; exit }' "$REPO_ROOT/go.mod")
if [ -z "$NATS_SERVER_PIN" ]; then
echo "ERROR: no github.com/nats-io/nats-server/v2 requirement in $REPO_ROOT/go.mod" >&2
exit 1
fi
if [ ! -x "$NATS_SERVER_BIN" ]; then
echo "ERROR: $NATS_SERVER_BIN not found — run 'make bin/nats-server'" >&2
exit 1
fi
if ! file -b "$NATS_SERVER_BIN" | grep -q "statically linked"; then
echo "ERROR: $NATS_SERVER_BIN is not statically linked — it cannot run on the musl guest" >&2
exit 1
fi
nats_server_version=$("$NATS_SERVER_BIN" --version 2>&1 | awk '{ print $NF; exit }')
if [ "$nats_server_version" != "$NATS_SERVER_PIN" ]; then
echo "ERROR: $NATS_SERVER_BIN reports $nats_server_version, go.mod pins $NATS_SERVER_PIN" >&2
exit 1
fi
echo "[build-sqs-store-microvm-image] nats-server: $nats_server_version (matches go.mod)"
# --- Create chroot ---
CHROOT_DIR=$(mktemp -d)
# Guard: every destructive op below targets "$CHROOT_DIR/...". An empty or
# unexpected value would aim rm -rf at the host (e.g. /dev). Refuse anything that
# is not a freshly-created temp dir.
case "${CHROOT_DIR:?mktemp -d returned empty}" in
/tmp/*|/var/tmp/*|"${TMPDIR:-/nonexistent}"/*) ;;
*) echo "ERROR: refusing to use unexpected CHROOT_DIR: $CHROOT_DIR" >&2; exit 1 ;;
esac
# Outputs are written here first, beside $BUILD_DIR so publishing is a rename.
STAGE_DIR=$(mktemp -d "$BUILD_DIR/.stage.XXXXXX")
CONTAINER_TOOL=""
CONTAINER_CID=""
cleanup() {
echo "[build-sqs-store-microvm-image] cleaning up chroot: $CHROOT_DIR"
rm -rf "$CHROOT_DIR"
rm -rf "${STAGE_DIR:?}"
if [ -n "$CONTAINER_CID" ] && [ -n "$CONTAINER_TOOL" ]; then
echo "[build-sqs-store-microvm-image] cleaning up container: $CONTAINER_CID"
$CONTAINER_TOOL rm -f "$CONTAINER_CID" >/dev/null 2>&1 || true
fi
}
trap cleanup EXIT
# --- Populate rootfs ---
# Strategy 1: native apk (Alpine hosts, CI)
if command -v apk >/dev/null 2>&1; then
echo "[build-sqs-store-microvm-image] rootfs: native apk"
mkdir -p \
"$CHROOT_DIR/etc/apk" \
"$CHROOT_DIR/lib/apk/db" \
"$CHROOT_DIR/var/cache/apk"
cat > "$CHROOT_DIR/etc/apk/repositories" <<EOF
${ALPINE_MIRROR}/v${ALPINE_VERSION}/main
${ALPINE_MIRROR}/v${ALPINE_VERSION}/community
EOF
apk add \
--root "$CHROOT_DIR" \
--arch x86_64 \
--no-cache \
--allow-untrusted \
--initdb \
$ALPINE_PACKAGES
# Strategy 2: docker -> BuildKit local export.
# Do NOT use `docker export` here. On Docker's overlay2 driver it leaks the
# container's overlay mount (the mount survives `docker rm`), orphaning layers
# under /var/lib/docker that only a daemon restart reclaims; on a busy CI host
# this grows without bound. `buildx --output type=local` writes the image
# filesystem straight to a directory and releases every mount, so nothing leaks.
elif command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
echo "[build-sqs-store-microvm-image] rootfs: docker buildx --output type=local (alpine:${ALPINE_VERSION})"
BUILD_CTX=$(mktemp -d)
cat > "$BUILD_CTX/Dockerfile" <<DOCKERFILE
FROM alpine:${ALPINE_VERSION}
RUN apk add --no-cache ${ALPINE_PACKAGES}
DOCKERFILE
docker buildx build \
--platform linux/amd64 \
--output "type=local,dest=${CHROOT_DIR}" \
"$BUILD_CTX"
rm -rf "$BUILD_CTX"
# Strategy 3: podman -> run + export. Podman's store does not exhibit the docker
# overlay2 export-mount leak, and podman has no buildx.
elif command -v podman >/dev/null 2>&1; then
echo "[build-sqs-store-microvm-image] rootfs: podman export (alpine:${ALPINE_VERSION})"
CONTAINER_TOOL=podman
CONTAINER_CID=$(podman run -d \
"alpine:${ALPINE_VERSION}" \
sh -c "apk add --no-cache ${ALPINE_PACKAGES}")
exit_code=$(podman wait "$CONTAINER_CID")
if [ "$exit_code" != "0" ]; then
echo "ERROR: package installation failed in container (exit $exit_code)" >&2
exit 1
fi
podman export "$CONTAINER_CID" | tar -x -C "$CHROOT_DIR"
else
echo "ERROR: no rootfs build tool available." >&2
echo " Install one of: apk (Alpine), docker, podman" >&2
exit 1
fi
# --- /dev: empty mountpoint only ---
# tar extraction without root silently creates 0-byte regular files for device
# nodes. Drop them and leave an empty /dev mountpoint. The two static nodes the
# kernel needs (/dev/console to wire init's stdio, /dev/null) are written into
# the cpio archive under fakeroot at pack time — NOT created on the host. init
# mounts devtmpfs over /dev as its first action for everything else at runtime.
rm -rf "${CHROOT_DIR:?}/dev"
mkdir "$CHROOT_DIR/dev"
# --- Place init script ---
echo "[build-sqs-store-microvm-image] installing init.sh as /init..."
if [ ! -f "$INIT_SH" ]; then
echo "ERROR: $INIT_SH not found — cannot build initramfs" >&2
exit 1
fi
install -m 0755 "$INIT_SH" "$CHROOT_DIR/init"
# --- Place inittab ---
# Required: without it busybox init runs its default table, not the power-down.
if [ ! -f "$INITTAB" ]; then
echo "ERROR: $INITTAB not found — cannot build initramfs" >&2
exit 1
fi
echo "[build-sqs-store-microvm-image] installing inittab..."
install -m 0644 "$INITTAB" "$CHROOT_DIR/etc/inittab"
# --- Place the store's guest steps ---
echo "[build-sqs-store-microvm-image] installing store guest steps..."
mkdir -p "$CHROOT_DIR/usr/local/lib/sqs-store"
for step in sqs-store-lib.sh sqs-store-prepare sqs-store-run sqs-store-stop; do
if [ ! -f "$BUILD_DIR/$step" ]; then
echo "ERROR: $BUILD_DIR/$step not found — cannot build initramfs" >&2
exit 1
fi
done
install -m 0644 "$BUILD_DIR/sqs-store-lib.sh" "$CHROOT_DIR/usr/local/lib/sqs-store/"
install -m 0755 "$BUILD_DIR/sqs-store-prepare" "$BUILD_DIR/sqs-store-run" "$BUILD_DIR/sqs-store-stop" \
"$CHROOT_DIR/usr/local/lib/sqs-store/"
# --- Copy nats-server binary ---
echo "[build-sqs-store-microvm-image] copying nats-server binary..."
mkdir -p "$CHROOT_DIR/usr/local/bin"
install -m 0755 "$NATS_SERVER_BIN" "$CHROOT_DIR/usr/local/bin/nats-server"
# --- Create required directories for init ---
mkdir -p \
"$CHROOT_DIR/proc" \
"$CHROOT_DIR/sys" \
"$CHROOT_DIR/dev" \
"$CHROOT_DIR/etc/ssl/certs"
# --- Locate kernel ---
KERNEL_IMG=$(find "$CHROOT_DIR/boot" -name "vmlinuz*" | sort | tail -1)
if [ -z "$KERNEL_IMG" ]; then
echo "ERROR: no vmlinuz found in $CHROOT_DIR/boot" >&2
exit 1
fi
echo "[build-sqs-store-microvm-image] kernel image: $KERNEL_IMG"
KERNEL_VER=$(basename "$KERNEL_IMG" | sed 's/vmlinuz-//')
KERNEL_CONFIG="$CHROOT_DIR/boot/config-${KERNEL_VER}"
# --- Assert fw_cfg module ---
if ! find "$CHROOT_DIR/lib/modules" \
-name "qemu_fw_cfg.ko*" \
-o -name "fw_cfg_sysfs.ko*" \
| grep -q .; then
if ! grep -q "CONFIG_FW_CFG_SYSFS=y" "$KERNEL_CONFIG" 2>/dev/null; then
echo "ERROR: qemu_fw_cfg module missing from initramfs — fw_cfg reads will fail at boot" >&2
exit 1
fi
echo "[build-sqs-store-microvm-image] fw_cfg: built-in (CONFIG_FW_CFG_SYSFS=y)"
else
echo "[build-sqs-store-microvm-image] fw_cfg: module found in lib/modules"
fi
# --- Assert ext4 userspace tools (data volume) ---
for fs_tool in mkfs.ext4 e2fsck; do
if [ ! -x "$CHROOT_DIR/sbin/$fs_tool" ] && [ ! -x "$CHROOT_DIR/usr/sbin/$fs_tool" ]; then
echo "ERROR: $fs_tool missing from image — guest cannot check or create an ext4 data volume" >&2
exit 1
fi
done
echo "[build-sqs-store-microvm-image] e2fsprogs: mkfs.ext4 + e2fsck present"
# --- Strip kernel modules (Phase 2 keep-list approach) ---
# Only modules needed by a virtio-mmio microvm guest are kept:
# virtio*.ko* — virtio bus, net, blk, rng, console, and helpers
# *fw_cfg*.ko* — QEMU fw_cfg sysfs driver (delivers boot blobs)
# *failover*.ko* — net_failover + failover (virtio_net deps for live migration)
# $MICROVM_EXTRA_MODULES — ext4 by default, plus dependency closure
# All other loadable modules are removed. Drivers compiled into the kernel
# (CONFIG_VIRTIO_MMIO=y etc.) are unaffected — they live in vmlinuz, not here.
# module_path prints a module's kernel/ path from the stock modules.dep, by
# name or modules.alias; it fails when the module is not loadable.
module_path() {
local kdir="$1" name="${2//-/_}" path alias_target
path=$(awk -F: -v n="$name" '{ f = $1; sub(/.*\//, "", f); sub(/\.ko(\.gz|\.xz|\.zst)?$/, "", f);
gsub(/-/, "_", f); if (f == n) { print $1; exit } }' "$kdir/modules.dep")
if [ -z "$path" ] && [ -f "$kdir/modules.alias" ]; then
alias_target=$(awk -v n="$2" '$1 == "alias" && $2 == n { print $3; exit }' "$kdir/modules.alias")
[ -n "$alias_target" ] && [ "$alias_target" != "$2" ] && path=$(module_path "$kdir" "$alias_target")
fi
[ -n "$path" ] && printf '%s\n' "$path"
}
# module_builtin reports whether a module name is compiled into the kernel.
module_builtin() {
local kdir="$1" name="${2//-/_}"
[ -f "$kdir/modules.builtin" ] || return 1
awk -v n="$name" '{ f = $0; sub(/.*\//, "", f); sub(/\.ko$/, "", f); gsub(/-/, "_", f);
if (f == n) { found = 1; exit } } END { exit !found }' "$kdir/modules.builtin"
}
# image_kmod runs the image's own kmod (depmod, modprobe) through its musl
# loader, so module metadata matches the guest's modprobe without a host kmod.
image_kmod() {
"$CHROOT_DIR/lib/ld-musl-x86_64.so.1" --library-path "$CHROOT_DIR/lib:$CHROOT_DIR/usr/lib" \
--argv0 "$1" "$CHROOT_DIR/bin/kmod" "${@:2}"
}
echo "[build-sqs-store-microvm-image] stripping kernel modules to virtio+fw_cfg+${MICROVM_EXTRA_MODULES} only..."
for kver_dir in "$CHROOT_DIR/lib/modules"/*/; do
kver="$(basename "$kver_dir")"
kernel_dir="$kver_dir/kernel"
[ -d "$kernel_dir" ] || continue
if [ ! -s "$kver_dir/modules.dep" ]; then
echo "ERROR: stock ${kver_dir}modules.dep missing — cannot resolve module dependencies" >&2
exit 1
fi
# Extra modules start the closure; the glob families are kept as found.
keep_list=$(mktemp)
: > "$keep_list"
for name in $MICROVM_EXTRA_MODULES; do
if ! path=$(module_path "$kver_dir" "$name"); then
if module_builtin "$kver_dir" "$name"; then continue; fi
echo "ERROR: module $name is neither loadable nor built into $kver" >&2
exit 1
fi
echo "$path" >> "$keep_list"
done
# Close over modules.dep hard dependencies and modules.softdep pre:/post:
# names until the set stops growing. A softdep must be loadable or built in.
while :; do
before=$(sort -u "$keep_list" | wc -l)
for path in $(sort -u "$keep_list"); do
awk -F': ' -v p="$path" '$1 == p { n = split($2, d, " "); for (i = 1; i <= n; i++) print d[i] }' \
"$kver_dir/modules.dep" >> "$keep_list"
mod=$(basename "$path"); mod="${mod%%.ko*}"; mod="${mod//-/_}"
[ -f "$kver_dir/modules.softdep" ] || continue
for soft in $(awk -v n="$mod" '{ m = $2; gsub(/-/, "_", m) }
$1 == "softdep" && m == n { for (i = 3; i <= NF; i++) if ($i != "pre:" && $i != "post:") print $i }' \
"$kver_dir/modules.softdep"); do
if soft_path=$(module_path "$kver_dir" "$soft"); then
echo "$soft_path" >> "$keep_list"
elif ! module_builtin "$kver_dir" "$soft"; then
echo "ERROR: softdep $soft of $mod is neither loadable nor built into $kver" >&2
exit 1
fi
done
done
after=$(sort -u "$keep_list" | wc -l)
[ "$before" -eq "$after" ] && break
done
extra_names=$(sort -u "$keep_list" | while read -r p; do m=$(basename "$p"); m="${m%%.ko*}"; echo "${m//-/_}"; done)
(cd "$kver_dir" && find kernel -name "virtio*.ko*" -o -name "*fw_cfg*.ko*" \
-o -name "*failover*.ko*") >> "$keep_list"
# Copy the keeper set out, preserving each kernel/ relative path.
tmp_keep=$(mktemp -d)
while read -r rel; do
rel="${rel#kernel/}"
mkdir -p "$tmp_keep/$(dirname "$rel")"
cp "$kernel_dir/$rel" "$tmp_keep/$rel"
done < <(sort -u "$keep_list")
rm -f "$keep_list"
# Replace kernel module tree with the keeper set.
rm -rf "$kernel_dir"
mkdir -p "$kernel_dir"
# Restore each kept file into the same relative path.
(cd "$tmp_keep" && find . -name "*.ko*" | while read -r f; do
dest_dir="$kernel_dir/$(dirname "${f#./}")"
mkdir -p "$dest_dir"
cp "$f" "$dest_dir/"
done)
rm -rf "$tmp_keep"
# Decompress kept modules to plain .ko. Alpine ships .ko.gz, but a host
# kmod that lacks gzip support (e.g. Debian trixie's kmod 34) silently
# produces an EMPTY modules.dep from compressed modules — the guest's
# modprobe then no-ops and qemu_fw_cfg never loads. Plain .ko sidesteps the
# host-kmod dependency entirely and the guest needs no decompressor either.
find "$kernel_dir" -name "*.ko.gz" -exec gunzip -f {} +
# Independent closure gate: each extra-closure module's own .modinfo depends=
# must name a kept module or a built-in, so a resolver bug fails here.
kept_names=$(find "$kernel_dir" -name "*.ko" -exec basename {} .ko \; | tr '-' '_' | sort -u)
while read -r ko; do
ko_name=$(basename "$ko" .ko); ko_name="${ko_name//-/_}"
grep -qx "$ko_name" <<< "$extra_names" || continue
deps=$(tr '\0' '\n' < "$ko" | grep -a -m1 '^depends=' | cut -d= -f2 | tr ',' ' ' || true)
for dep in $deps; do
dep="${dep//-/_}"
if ! grep -qx "$dep" <<< "$kept_names" && ! module_builtin "$kver_dir" "$dep"; then
echo "ERROR: $(basename "$ko") depends on $dep, which is neither kept nor built in" >&2
exit 1
fi
done
done < <(find "$kernel_dir" -name "*.ko")
for name in $MICROVM_EXTRA_MODULES; do
if ! grep -qx "${name//-/_}" <<< "$kept_names" && ! module_builtin "$kver_dir" "$name"; then
echo "ERROR: required module $name missing from the stripped module tree" >&2
exit 1
fi
done
echo "[build-sqs-store-microvm-image] extra module closure: $(echo "$extra_names" | tr '\n' ' ')"
echo "[build-sqs-store-microvm-image] modules kept: $(echo "$kept_names" | tr '\n' ' ')"
# Rebuild module metadata with the image's own kmod, the binary the guest's
# modprobe runs, so no host depmod is needed. Stock indexes still name .ko.gz
# files, so they are removed first and a failed rebuild cannot ship them.
for f in dep dep.bin alias alias.bin softdep weakdep symbols symbols.bin \
builtin.bin builtin.alias.bin devname; do
rm -f "$kver_dir/modules.$f"
done
if ! image_kmod depmod -b "$CHROOT_DIR" "$kver"; then
echo "ERROR: image depmod failed for $kver" >&2
exit 1
fi
if [ ! -s "$kver_dir/modules.dep" ] || [ ! -s "$kver_dir/modules.dep.bin" ]; then
echo "ERROR: ${kver_dir}modules.dep or modules.dep.bin missing or empty after depmod" >&2
exit 1
fi
# Resolution gate: the image's modprobe must resolve every required module
# to plain .ko files present in the stripped tree.
for name in $MICROVM_EXTRA_MODULES qemu_fw_cfg virtio_net; do
module_builtin "$kver_dir" "$name" && continue
if ! plan=$(image_kmod modprobe -d "$CHROOT_DIR" -S "$kver" --show-depends "$name"); then
echo "ERROR: image modprobe cannot resolve $name for $kver" >&2
exit 1
fi
while read -r verb path _; do
[ "$verb" = "insmod" ] || continue
case "$path" in
"$CHROOT_DIR/lib/modules/$kver/kernel/"*.ko) [ -f "$path" ] && continue ;;
esac
echo "ERROR: modprobe plan for $name names $path, not a kept plain .ko" >&2
exit 1
done <<< "$plan"
echo "[build-sqs-store-microvm-image] modprobe $name: $(awk '{ n = split($2, a, "/"); printf "%s ", a[n] }' <<< "$plan")"
done
done
# --- Strip package-manager artifacts (not needed at runtime) ---
echo "[build-sqs-store-microvm-image] stripping package manager artifacts..."
rm -rf \
"$CHROOT_DIR/lib/apk" \
"$CHROOT_DIR/var/cache/apk" \
"$CHROOT_DIR/etc/apk" \
"$CHROOT_DIR/usr/share/man" \
"$CHROOT_DIR/usr/share/doc" \
"$CHROOT_DIR/usr/share/apk" \
"$CHROOT_DIR/usr/include" \
"$CHROOT_DIR/usr/lib/pkgconfig"
# --- Strip debug symbols from binaries ---
# nats-server in /usr/local/bin is left as built (-s -w), so the shipped bytes
# are the ones whose version was checked above.
echo "[build-sqs-store-microvm-image] stripping debug symbols from binaries..."
find "$CHROOT_DIR/usr/sbin" "$CHROOT_DIR/usr/bin" \
"$CHROOT_DIR/sbin" "$CHROOT_DIR/bin" \
-type f 2>/dev/null | while read -r bin; do
strip --strip-all "$bin" 2>/dev/null || true
done
# --- Copy vmlinuz out before stripping /boot from chroot ---
VMLINUZ_OUT="$STAGE_DIR/vmlinuz"
echo "[build-sqs-store-microvm-image] copying kernel: $VMLINUZ_OUT"
cp "$KERNEL_IMG" "$VMLINUZ_OUT"
# Drop /boot from the chroot — vmlinuz, Alpine's stock initramfs-virt, System.map
# and kernel config all live here (~25 MiB). None are needed at runtime: the
# guest already has the kernel loaded by QEMU's -kernel, and Alpine's initramfs
# is unused because we replace it with our own /init. Leaving /boot in the cpio
# nearly doubles uncompressed initramfs size and forces a 512 MiB guest just to
# survive decompression.
rm -rf "${CHROOT_DIR:?}/boot"
# --- Build initramfs ---
INITRAMFS_OUT="$STAGE_DIR/initramfs.cpio.gz"
echo "[build-sqs-store-microvm-image] building initramfs: $INITRAMFS_OUT"
# Create the static device nodes and pack the archive inside a single fakeroot
# session: mknod/cpio see faked device entries and write real char-device
# records into the cpio, while the host filesystem never gets an actual node.
fakeroot sh -c '
cd "$1" || exit 1
mknod -m 600 dev/console c 5 1
mknod -m 666 dev/null c 1 3
find . | cpio --quiet -o -H newc | gzip -9 > "$2"
' _ "$CHROOT_DIR" "$INITRAMFS_OUT"
# --- Gate the staged pair, then publish it ---
# Nothing reaches $BUILD_DIR until every gate passes, so a failed build cannot
# leave a pair the grouped make target would take as up to date.
"$REPO_ROOT/scripts/lib/sqs-store-microvm-publish.sh" "$STAGE_DIR" "$BUILD_DIR"
echo ""
echo "[build-sqs-store-microvm-image] done."
@@ -25,7 +25,7 @@ error_log="/dev/console"
if [ -f /etc/spinifex-eks/first-boot.env ]; then
# shellcheck disable=SC1091
. /etc/spinifex-eks/first-boot.env
export EKS_GATEWAY_URL EKS_GATEWAY_CA EKS_ACCESS_KEY EKS_SECRET_KEY EKS_REGION EKS_ACCOUNT_ID EKS_CLUSTER_NAME
export EKS_GATEWAY_URL EKS_GATEWAY_CA EKS_ACCESS_KEY EKS_SECRET_KEY EKS_REGION EKS_ACCOUNT_ID EKS_CLUSTER_NAME EKS_WEBHOOK_READY_ADDR
fi
depend() {
+1 -14
View File
@@ -298,7 +298,6 @@ log "preflight on $N host(s)"
versions=""
families=""
libreswan_hosts=""
for i in $(seq 0 $((N - 1))); do
host="${HOSTS[$i]}"
@@ -322,12 +321,6 @@ for i in $(seq 0 $((N - 1))); do
fail "$host: cannot tell its OS from /etc/os-release"
families+="${host}: ${family}"$'\n'
# libreswan's pluto: Spinifex cannot run OVN IPsec on it yet, and spx admin
# init refuses --ipsec=true there, which would stop formation part way.
if [ "$(out "$host" "test -x /usr/libexec/ipsec/pluto && echo yes")" = "yes" ]; then
libreswan_hosts+=" $host"
fi
# A node that is already in a multi-node cluster is one whose keys and
# logical network state are load-bearing. Refusing here is deliberate:
# forming a cluster must never be the command that destroys a live one.
@@ -386,12 +379,6 @@ $(sed '/^$/d; s/^/ /' <<<"$families")
A cluster must run one OS on every host."
fi
if $IPSEC_ENABLED && [ -n "$libreswan_hosts" ]; then
fail "--ipsec on, but these hosts use libreswan for IPsec:$libreswan_hosts
Spinifex cannot run OVN IPsec on libreswan yet. Re-run with --ipsec off
only if the nodes share a trusted private link."
fi
# --- Confirm ---------------------------------------------------------------
echo ""
@@ -460,7 +447,7 @@ done
# Matched on the service argv so the ssh shell running this cannot match itself.
for host in "${HOSTS[@]}"; do
$DRY_RUN && { echo " [dry-run] $host: wait for every 'spx service' process to exit"; continue; }
on "$host" "for u in spinifex-predastore spinifex-viperblock spinifex-sqs-store spinifex-nats; do
on "$host" "for u in spinifex-predastore spinifex-viperblock spinifex-nats; do
systemctl is-active --quiet \$u && sudo systemctl stop \$u
done
for _ in \$(seq 1 45); do
+158
View File
@@ -0,0 +1,158 @@
#!/bin/sh
# ipsec_state_helper_test.sh — tests for the plaintext Geneve guard in the
# IPsec state helper that setup.sh installs.
#
# The helper is cut out of setup.sh's heredoc and run against stub nft,
# ovs-vsctl and systemctl commands, with pluto's path pointed at a fixture.
set -eu
SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
SETUP="$SCRIPT_DIR/setup.sh"
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
fails=0
pass() { echo " ok - $1"; }
fail() { echo " FAIL - $1"; fails=$((fails + 1)); }
echo "-- IPsec state helper: plaintext Geneve guard"
HELPER="$TMP/helper"
awk '/tee "\$\{IPSEC_STATE_HELPER\}"/ { on = 1; next } on && /^HELPER$/ { exit } on { print }' "$SETUP" |
sed "s#/usr/libexec/ipsec/pluto#$TMP/pluto#g" > "$HELPER"
chmod +x "$HELPER"
grep -q '^ guard)' "$HELPER" || { echo "could not extract the helper from setup.sh" >&2; exit 1; }
mkdir -p "$TMP/bin"
cat > "$TMP/bin/nft" <<EOF
#!/bin/sh
[ "\$*" = "-f -" ] || { echo "nft \$*" >> "$TMP/nft.log"; exit 0; }
cat >> "$TMP/nft.log"
echo "--" >> "$TMP/nft.log"
EOF
cat > "$TMP/bin/ovs-vsctl" <<EOF
#!/bin/sh
[ -e "$TMP/ovs-down" ] && { echo "ovs-vsctl: database connection failed" >&2; exit 1; }
case "\$*" in
*" find Interface type=geneve") cat "$TMP/ifaces" ;;
*" get Interface "*)
for last; do :; done
f="$TMP/opt.\$5.\${last#options:}"
if [ -e "\$f" ]; then cat "\$f"; else echo; fi
;;
*" get Open_vSwitch . external_ids:ovn-encap-ip")
if [ -e "$TMP/encap" ]; then cat "$TMP/encap"; else echo; fi
;;
*) exit 1 ;;
esac
EOF
printf '#!/bin/sh\nexit 0\n' > "$TMP/bin/systemctl"
chmod +x "$TMP/bin/nft" "$TMP/bin/ovs-vsctl" "$TMP/bin/systemctl"
# reset — no tunnels, OVS up, no pluto.
reset() {
rm -f "$TMP"/opt.* "$TMP/ovs-down" "$TMP/nft.log" "$TMP/pluto" "$TMP/encap"
: > "$TMP/ifaces"
touch "$TMP/nft.log"
}
# tunnel <name> <local_ip|-> [remote_name] — a geneve interface as ovn-controller writes it.
tunnel() {
echo "$1" >> "$TMP/ifaces"
[ "$2" = - ] || printf '"%s"\n' "$2" > "$TMP/opt.$1.local_ip"
[ -z "${3:-}" ] || echo "$3" > "$TMP/opt.$1.remote_name"
}
run() {
RC=0
OUT=$(PATH="$TMP/bin:$PATH" "$HELPER" "$1" 2>&1) || RC=$?
NFTLOG=$(cat "$TMP/nft.log")
}
LIFTED="table inet spinifex_ipsec_guard
delete table inet spinifex_ipsec_guard
--"
# expect_guarded <desc> <sources> — one transaction that swaps in a table
# dropping Geneve without an SA from exactly those sources.
expect_guarded() {
if [ "$RC" = 0 ] &&
[ "$(grep -c '^--$' "$TMP/nft.log")" = 1 ] &&
[ "$(sed -n 2p "$TMP/nft.log")" = "delete table inet spinifex_ipsec_guard" ] &&
grep -q "^ elements = { $2 }$" "$TMP/nft.log" &&
grep -q '^ ip saddr @srcs udp dport 6081 rt ipsec missing drop$' "$TMP/nft.log"; then
pass "$1"
else
fail "$1 (rc=$RC): got [$NFTLOG] want sources [$2] $OUT"
fi
}
expect_lifted() {
if [ "$RC" = 0 ] && [ "$NFTLOG" = "$LIFTED" ]; then pass "$1"; else fail "$1 (rc=$RC): got [$NFTLOG] $OUT"; fi
}
reset
tunnel ovn-node2-0 10.26.7.1 node2
tunnel ovn-node3-0 10.26.7.1 node3
run guard
expect_guarded "guards the encap address once OVN wants the tunnels encrypted" "10.26.7.1/32"
reset
tunnel ovn-node2-0 10.26.7.1
tunnel ovn-node3-0 10.26.7.1
run guard
expect_lifted "lifts the guard while OVN runs the tunnels in plaintext"
reset
tunnel ovn-node2-0 10.26.7.1 node2
tunnel ovn-node3-0 10.26.8.1
run guard
expect_guarded "guards only the addresses of tunnels OVN encrypts" "10.26.7.1/32"
reset
tunnel ovn-node2-0 - node2
run guard
expect_guarded "guards a tunnel without a local_ip from every source" "0.0.0.0/0"
reset
echo '"10.26.7.1"' > "$TMP/encap"
run guard
expect_guarded "guards the encap address before ovn-controller has built the tunnels" "10.26.7.1/32"
reset
echo '"10.26.7.1,10.26.8.1"' > "$TMP/encap"
run guard
expect_guarded "guards each encap address of a multi-address host before the tunnels exist" "10.26.7.1/32,10.26.8.1/32"
reset
run guard
expect_guarded "guards every source before the tunnels exist when no encap address is set" "0.0.0.0/0"
reset
tunnel ovn-node2-0 10.26.7.1 node2
touch "$TMP/ovs-down"
run guard
if [ "$RC" != 0 ] && [ -z "$NFTLOG" ]; then
pass "keeps the guard and fails when OVS cannot be read"
else
fail "with OVS down: rc=$RC nft calls [$NFTLOG]"
fi
reset
touch "$TMP/pluto"
chmod +x "$TMP/pluto"
run off
expect_lifted "off lifts the guard on a libreswan host"
reset
run off
if [ "$RC" = 0 ] && [ -z "$NFTLOG" ]; then pass "off leaves nft alone without libreswan"; else fail "off without pluto: rc=$RC [$NFTLOG]"; fi
reset
run unguard
expect_lifted "unguard lifts the guard"
reset
run bogus
if [ "$RC" = 2 ] && [ -z "$NFTLOG" ]; then pass "refuses an unknown verb"; else fail "unknown verb: rc=$RC [$NFTLOG]"; fi
if [ "$fails" -gt 0 ]; then
echo "$fails failure(s)"
exit 1
fi
echo "all passed"
+288
View File
@@ -0,0 +1,288 @@
#!/bin/sh
# sqs-store-guest_test.sh — the SQS store guest steps start the store only on
# a valid contract and one checked, mounted disk, never format, and stop the
# store before unmounting it.
#
# Drives build/microvm/sqs-store/sqs-store-lib.sh against a fake fw_cfg, sysfs
# and stub tools. The stop cases signal only test-owned children.
# The case settings below are read by the sourced library, not by this file.
# shellcheck disable=SC2034
set -eu
ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/../.." && pwd)
LIB=${SQS_GUEST_LIB:-"$ROOT/build/microvm/sqs-store/sqs-store-lib.sh"}
TMP=$(mktemp -d)
CHILDREN=""
cleanup() {
for p in $CHILDREN; do kill -KILL "$p" 2>/dev/null || true; done
rm -rf "$TMP"
}
trap cleanup EXIT
fails=0
pass() { echo " ok - $1"; }
fail() { echo " FAIL - $1"; fails=$((fails + 1)); }
check() { if eval "$2"; then pass "$1"; else fail "$1"; fi; }
echo "-- build/microvm/sqs-store/sqs-store-lib.sh"
SERIAL=vol0123456789abcdef0
NKEY=UAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB
ADDR=10.11.12.13
# Stub tools record each call to calls.log; their exit codes come from files.
mkdir -p "$TMP/bin"
cat > "$TMP/bin/e2fsck" <<'EOF'
#!/bin/sh
echo "e2fsck $*" >> "$T/calls.log"
exit "$(cat "$T/fsck.rc")"
EOF
cat > "$TMP/bin/mount" <<'EOF'
#!/bin/sh
echo "mount $*" >> "$T/calls.log"
exit "$(cat "$T/mount.rc")"
EOF
cat > "$TMP/bin/umount" <<'EOF'
#!/bin/sh
echo "umount $*" >> "$T/calls.log"
EOF
for f in mkfs mkfs.ext4 mke2fs; do
printf '#!/bin/sh\necho "mkfs %s $*" >> "$T/calls.log"\n' "$f" > "$TMP/bin/$f"
done
cat > "$TMP/bin/ip" <<'EOF'
#!/bin/sh
cat "$T/ip.out"
EOF
cat > "$TMP/bin/nats-server" <<'EOF'
#!/bin/sh
echo "nats-server $*" >> "$T/calls.log"
[ "$1" = -t ] && exit "$(cat "$T/configtest.rc")"
exit 0
EOF
chmod +x "$TMP/bin"/*
# fresh <name>: a case directory with a valid contract and one matching disk
# among others. Callers then break one thing.
fresh() {
T="$TMP/$1"
export T
mkdir -p "$T/fwcfg" "$T/sys" "$T/dev" "$T/run" "$T/data"
for k in data-serial listen-addr client-nkey; do mkdir -p "$T/fwcfg/$k"; done
printf '%s\n' "$SERIAL" > "$T/fwcfg/data-serial/raw"
printf '%s\n' "$ADDR" > "$T/fwcfg/listen-addr/raw"
printf '%s\n' "$NKEY" > "$T/fwcfg/client-nkey/raw"
disk vda vol00000000000000000
disk vdb "$SERIAL"
echo 0 > "$T/fsck.rc"
echo 0 > "$T/mount.rc"
echo 0 > "$T/configtest.rc"
: > "$T/calls.log"
: > "$T/console"
printf '1: lo inet 127.0.0.1/8 scope host lo\n2: eth0 inet %s/24 brd 10.11.12.255 scope global eth0\n' "$ADDR" > "$T/ip.out"
}
disk() { mkdir -p "$T/sys/$1"; printf '%s\n' "$2" > "$T/sys/$1/serial"; : > "$T/dev/$1"; }
# prepare: run sqs_prepare in a subshell with every path pointed at the case.
prepare() {
(
SQS_FWCFG="$T/fwcfg" SQS_SYSBLOCK="$T/sys" SQS_DEVDIR="$T/dev" SQS_NODE_TEST=-e
SQS_RUN="$T/run" SQS_DATA="$T/data" SQS_CONSOLE="$T/console"
E2FSCK="$TMP/bin/e2fsck" MOUNT="$TMP/bin/mount" IP="$TMP/bin/ip" NATS_BIN="$TMP/bin/nats-server"
PATH="$TMP/bin:$PATH"
export PATH
# shellcheck source=../../build/microvm/sqs-store/sqs-store-lib.sh
. "$LIB"
sqs_prepare
) > /dev/null 2>&1
}
refused() { [ ! -e "$T/run/ready" ] && grep -q FATAL "$T/console"; }
never_mounted() { ! grep -q '^mount ' "$T/calls.log"; }
never_formatted() { ! grep -q '^mkfs ' "$T/calls.log"; }
never_checked() { ! grep -q '^e2fsck ' "$T/calls.log"; }
# --- A valid contract prepares the store ---
fresh valid
check "valid contract is prepared" 'prepare && [ -e "$T/run/ready" ]'
check "the matching disk is checked, then mounted at the data dir" \
'grep -qx "e2fsck -p $T/dev/vdb" "$T/calls.log" && grep -qx "mount -t ext4 -o nodev,nosuid,noexec $T/dev/vdb $T/data" "$T/calls.log"'
check "config listens only on the supplied address" \
'grep -c "listen" "$T/run/nats.conf" | grep -qx 1 && grep -qx "listen: \"$ADDR:4222\"" "$T/run/nats.conf"'
check "config admits only the supplied user NKey" 'grep -q "users = \[ { nkey: \"$NKEY\" } \]" "$T/run/nats.conf"'
check "config syncs JetStream on the data disk" \
'grep -q "store_dir: \"$T/data\"" "$T/run/nats.conf" && grep -q "sync_interval: always" "$T/run/nats.conf"'
check "config is tested by the server before ready" 'grep -qx "nats-server -t -c $T/run/nats.conf" "$T/calls.log"'
check "no auth material on the console" '! grep -q "$NKEY" "$T/console"'
check "prepare reports the disk and config, not a listener" 'grep -q "prepared: $T/dev/vdb mounted" "$T/console" && ! grep -qi "listening" "$T/console"'
fresh fsck-corrected; echo 1 > "$T/fsck.rc"
check "e2fsck exit 1 (corrected) proceeds" 'prepare && [ -e "$T/run/ready" ]'
# --- Disk refusals: nothing mounted, nothing formatted ---
fresh no-disk; rm -rf "$T/sys/vdb"
check "missing disk is refused before any check or mount" '! prepare && refused && never_checked && never_mounted'
fresh wrong-disk; printf 'vol0fffffffffffffff0\n' > "$T/fwcfg/data-serial/raw"
check "disk with another serial is refused" '! prepare && refused && never_checked && never_mounted'
fresh two-disks; disk vdc "$SERIAL"
check "two disks with the serial are refused" '! prepare && refused && never_checked && never_mounted'
fresh bad-serial; printf 'vol-0123456789abcdef\n' > "$T/fwcfg/data-serial/raw"
check "malformed serial is refused" '! prepare && refused && never_mounted'
fresh no-node; rm -f "$T/dev/vdb"
check "disk without a device node is refused" '! prepare && refused && never_mounted'
for rc in 2 4 8; do
fresh "fsck-$rc"; echo "$rc" > "$T/fsck.rc"
check "e2fsck exit $rc is refused without mount or format" '! prepare && refused && never_mounted && never_formatted'
done
fresh mount-fail; echo 32 > "$T/mount.rc"
check "failed mount is refused" '! prepare && refused'
# --- Auth and listener refusals happen before the disk is touched ---
fresh no-nkey; rm -rf "$T/fwcfg/client-nkey"
check "missing NKey is refused before the disk" '! prepare && refused && never_checked && never_mounted'
for bad in seed lower short two empty; do
fresh "nkey-$bad"
case $bad in
seed) v=SUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ;;
lower) v=uaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab ;;
short) v=UAAAA ;;
two) v="$NKEY
$NKEY" ;;
empty) v="" ;;
esac
printf '%s\n' "$v" > "$T/fwcfg/client-nkey/raw"
check "NKey ($bad) is refused before the disk, without echoing it" \
'! prepare && refused && never_checked && { [ -z "$v" ] || ! grep -qF "$v" "$T/console"; }'
done
fresh nkey-checksum; echo 1 > "$T/configtest.rc"
check "NKey the server rejects is refused before the disk" '! prepare && refused && never_checked && never_mounted'
fresh no-addr; rm -rf "$T/fwcfg/listen-addr"
check "missing listen address is refused" '! prepare && refused && never_mounted'
fresh addr-absent; printf '1: lo inet 127.0.0.1/8 scope host lo\n2: eth0 inet 10.11.12.99/24 scope global eth0\n' > "$T/ip.out"
check "listen address not on a guest NIC is refused" '! prepare && refused && never_mounted'
fresh addr-loopback; printf '127.0.0.1\n' > "$T/fwcfg/listen-addr/raw"
check "loopback listen address is refused" '! prepare && refused && never_mounted'
for bad in 0.0.0.0x 1.2.3 1.2.3.256 01.2.3.4; do
fresh "addr-$bad"; printf '%s\n' "$bad" > "$T/fwcfg/listen-addr/raw"
check "malformed listen address $bad is refused" '! prepare && refused && never_mounted'
done
# --- Run: the store starts only when prepared and not stopping ---
run_step() {
(
SQS_RUN="$T/run" SQS_CONSOLE="$T/console" NATS_BIN="$TMP/bin/nats-server"
# shellcheck source=../../build/microvm/sqs-store/sqs-store-lib.sh
. "$LIB"
sqs_run
) > /dev/null 2>&1
}
fresh run-ready; prepare; : > "$T/calls.log"
check "a prepared store starts the server" 'run_step && grep -qx "nats-server -c $T/run/nats.conf" "$T/calls.log"'
fresh run-unready
check "an unprepared store never starts the server" '! run_step && ! grep -q "^nats-server" "$T/calls.log"'
fresh run-stopping; prepare; : > "$T/calls.log"; : > "$T/run/stopping"
check "a stopping store never starts the server" '! run_step && ! grep -q "^nats-server" "$T/calls.log"'
# --- Stop: SIGTERM the verified store, then unmount ---
STORE="$TMP/bin/fake-store"
cp "$(command -v sleep)" "$STORE"
stop_step() {
(
SQS_RUN="$T/run" SQS_DATA="$T/data" SQS_CONSOLE="$T/console" SQS_MOUNTS="$T/mounts"
UMOUNT="$TMP/bin/umount" NATS_BIN="$STORE" SQS_STOP_BUDGET_TENTHS=10
# shellcheck source=../../build/microvm/sqs-store/sqs-store-lib.sh
. "$LIB"
sqs_stop
) > /dev/null 2>&1
}
gone() { [ ! -r "/proc/$1/status" ] || grep -q '^State:[[:space:]]*Z' "/proc/$1/status"; }
# record <pid>: write the identity sqs_run would record for that process.
# shellcheck source=../../build/microvm/sqs-store/sqs-store-lib.sh
record() { echo "$1 $( . "$LIB"; sqs_starttime "$1" )" > "$T/run/pid"; }
fresh stop-orderly; echo "dev $T/data ext4 rw 0 0" > "$T/mounts"
"$STORE" 60 & pid=$!; CHILDREN="$CHILDREN $pid"; record "$pid"
stop_step
check "stop sends SIGTERM and the store exits" 'gone "$pid" && grep -q "SIGTERM sent" "$T/console" && ! grep -q SIGKILL "$T/console"'
check "stop blocks respawn and unmounts after the store exits" \
'[ -e "$T/run/stopping" ] && grep -qx "umount $T/data" "$T/calls.log"'
fresh stop-hung; echo "dev $T/data ext4 rw 0 0" > "$T/mounts"
(trap '' TERM; exec "$STORE" 60) & pid=$!; CHILDREN="$CHILDREN $pid"; record "$pid"
stop_step
check "store ignoring SIGTERM is killed after the budget, then unmounted" \
'gone "$pid" && grep -q SIGKILL "$T/console" && grep -qx "umount $T/data" "$T/calls.log"'
fresh stop-reused; echo "dev $T/data ext4 rw 0 0" > "$T/mounts"
"$STORE" 60 & pid=$!; CHILDREN="$CHILDREN $pid"; echo "$pid 1" > "$T/run/pid"
stop_step
check "a recorded PID with another start time is never signalled" '! gone "$pid" && grep -q "no running store" "$T/console"'
kill -KILL "$pid"
# A start held after its stopping check and before its exec: the run step
# blocks writing "run: starting" to a FIFO console until the test reads it.
fresh stop-pending-start; echo "dev $T/data ext4 rw 0 0" > "$T/mounts"
: > "$T/run/ready"
mkfifo "$T/run-console"
printf '#!/bin/sh\n: > "%s/started"\nexec "%s" 60\n' "$T" "$STORE" > "$TMP/bin/pending-nats"
chmod +x "$TMP/bin/pending-nats"
SQS_RUN="$T/run" SQS_CONSOLE="$T/run-console" NATS_BIN="$TMP/bin/pending-nats" \
sh -c '. "$1"; sqs_run' sh "$LIB" & pid=$!; CHILDREN="$CHILDREN $pid"
i=0
while [ "$i" -lt 100 ] && ! grep -q "^$pid " "$T/run/pid" 2>/dev/null; do i=$((i + 1)); sleep 0.05; done
check "pending start is held before its exec" 'grep -q "^$pid " "$T/run/pid" && ! gone "$pid" && [ ! -e "$T/started" ]'
stop_step
# Release the FIFO: a start that survived the stop would exec the server now.
cat "$T/run-console" > /dev/null 2>&1 &
reader=$!; CHILDREN="$CHILDREN $reader"
i=0
while [ "$i" -lt 20 ] && ! gone "$pid"; do i=$((i + 1)); sleep 0.05; done
check "stop ends a pending start before it can exec the server" 'gone "$pid" && [ ! -e "$T/started" ]'
check "stop unmounts only after the pending start is gone" \
'grep -q "store exited" "$T/console" && grep -qx "umount $T/data" "$T/calls.log"'
kill -KILL "$reader" 2>/dev/null || true
# --- Shutdown: the generic remount runs only once the store is gone ---
# shutdown_step [survivor-pid]: with a pid, that process is reported alive
# whatever happens to it, as a writer stuck past SIGKILL would be.
shutdown_step() {
(
SQS_RUN="$T/run" SQS_DATA="$T/data" SQS_CONSOLE="$T/console" SQS_MOUNTS="$T/mounts"
UMOUNT="$TMP/bin/umount" SQS_STOP_BUDGET_TENTHS=5
# shellcheck source=../../build/microvm/sqs-store/sqs-store-lib.sh
. "$LIB"
if [ -n "${1:-}" ]; then sqs_same() { [ "$1" = "$survivor" ]; }; survivor=$1; fi
sqs_shutdown
) > /dev/null 2>&1
}
fresh shutdown-orderly; echo "dev $T/data ext4 rw 0 0" > "$T/mounts"
"$STORE" 60 & pid=$!; CHILDREN="$CHILDREN $pid"; record "$pid"
check "orderly shutdown succeeds" 'shutdown_step'
check "orderly shutdown unmounts the data disk, then runs umount -a -r" \
'[ "$(grep "^umount" "$T/calls.log" | tr "\n" "|")" = "umount $T/data|umount -a -r|" ]'
fresh shutdown-survivor; echo "dev $T/data ext4 rw 0 0" > "$T/mounts"
"$STORE" 60 & pid=$!; CHILDREN="$CHILDREN $pid"; record "$pid"
check "shutdown with a surviving store reports failure" '! shutdown_step "$pid"'
check "a surviving store leaves the data disk and every other mount alone" \
'! grep -q "^umount" "$T/calls.log" && grep -q "STILL ALIVE" "$T/console" && grep -q "skipping umount -a -r" "$T/console"'
fresh stop-unmounted; : > "$T/mounts"
stop_step
check "stop with no data mount does not unmount" '! grep -q "^umount" "$T/calls.log"'
if [ "$fails" -ne 0 ]; then
echo " $fails failure(s)"
exit 1
fi
+97
View File
@@ -0,0 +1,97 @@
#!/bin/bash
# sqs-store-microvm-publish.sh STAGE_DIR OUT_DIR — gate a staged SQS store
# microVM kernel + initramfs and move them into OUT_DIR only if every gate passes.
#
# A failed gate leaves OUT_DIR as it was: a previous valid pair stays, and an
# older pair stays older than the build inputs, so make rebuilds next time.
set -euo pipefail
STAGE_DIR="${1:?usage: sqs-store-microvm-publish.sh STAGE_DIR OUT_DIR}"
OUT_DIR="${2:?usage: sqs-store-microvm-publish.sh STAGE_DIR OUT_DIR}"
VMLINUZ="$STAGE_DIR/vmlinuz"
INITRAMFS="$STAGE_DIR/initramfs.cpio.gz"
tag="[build-sqs-store-microvm-image]"
for f in "$VMLINUZ" "$INITRAMFS"; do
if [ ! -s "$f" ]; then
echo "ERROR: staged artifact $f missing or empty" >&2
exit 1
fi
done
# --- Content gate: read the packed archive, not the chroot ---
if ! archive_list=$(zcat "$INITRAMFS" | cpio --quiet -t); then
echo "ERROR: $INITRAMFS is not a readable gzip cpio archive" >&2
exit 1
fi
for want in init etc/inittab usr/local/bin/nats-server dev/console dev/null \
usr/local/lib/sqs-store/sqs-store-lib.sh usr/local/lib/sqs-store/sqs-store-prepare \
usr/local/lib/sqs-store/sqs-store-run usr/local/lib/sqs-store/sqs-store-stop; do
if ! grep -qx "$want" <<< "$archive_list"; then
echo "ERROR: $want missing from $INITRAMFS" >&2
exit 1
fi
done
for fs_tool in mkfs.ext4 e2fsck; do
if ! grep -qxE "(usr/)?sbin/$fs_tool" <<< "$archive_list"; then
echo "ERROR: $fs_tool missing from $INITRAMFS" >&2
exit 1
fi
done
# Module files may spell a name with dashes (tiny-power-button.ko). Normalise
# once: piping into grep -q under pipefail fails when grep exits on a match.
module_list=${archive_list//-/_}
for want_ko in ext4 tiny_power_button; do
if ! grep -q "/$want_ko\.ko\$" <<< "$module_list"; then
echo "ERROR: $want_ko missing from $INITRAMFS" >&2
exit 1
fi
done
if grep -qE '(^|/)(lb-agent|haproxy|nginx)$' <<< "$archive_list"; then
echo "ERROR: LB data-plane binaries found in the SQS store image" >&2
exit 1
fi
echo "$tag content gate: PASS"
echo ""
echo "$tag staged artifacts:"
ls -lh "$VMLINUZ" "$INITRAMFS"
echo ""
# --- Artifact size gate (50 MiB total) ---
ARTIFACT_MAX_MiB="${MICROVM_ARTIFACT_MAX_MiB:-50}"
total_bytes=$(( $(stat -c %s "$VMLINUZ") + $(stat -c %s "$INITRAMFS") ))
max_bytes=$(( ARTIFACT_MAX_MiB * 1024 * 1024 ))
total_mib=$(( (total_bytes + 1048575) / 1048576 ))
if [ "$total_bytes" -gt "$max_bytes" ]; then
echo "ERROR: artifact size ${total_mib} MiB exceeds ${ARTIFACT_MAX_MiB} MiB gate" >&2
echo " Set MICROVM_ARTIFACT_MAX_MiB=N to override during development." >&2
exit 1
fi
echo "$tag artifact size gate: PASS (${total_mib} MiB / ${ARTIFACT_MAX_MiB} MiB)"
# --- Guest-RAM initramfs gate (uncompressed) ---
# The kernel unpacks the whole initramfs into RAM before init, so the
# UNCOMPRESSED size — not the gzip artifact — sets the guest memory floor.
UNCOMPRESSED_MAX_MiB="${MICROVM_INITRAMFS_UNCOMPRESSED_MAX_MiB:-96}"
uncompressed_bytes=$(zcat "$INITRAMFS" | wc -c)
uncompressed_mib=$(( (uncompressed_bytes + 1048575) / 1048576 ))
umax_bytes=$(( UNCOMPRESSED_MAX_MiB * 1024 * 1024 ))
if [ "$uncompressed_bytes" -gt "$umax_bytes" ]; then
echo "ERROR: uncompressed initramfs ${uncompressed_mib} MiB exceeds ${UNCOMPRESSED_MAX_MiB} MiB guest-RAM gate" >&2
echo " The kernel unpacks this into guest RAM before init; a larger" >&2
echo " footprint panics before userspace. Slim the initramfs, or raise the" >&2
echo " instance memory AND MICROVM_INITRAMFS_UNCOMPRESSED_MAX_MiB together." >&2
exit 1
fi
echo "$tag initramfs guest-RAM gate: PASS (${uncompressed_mib} MiB / ${UNCOMPRESSED_MAX_MiB} MiB uncompressed)"
# --- Publish ---
# Two renames are not atomic as a pair, so the old initramfs goes first and the
# new one lands last. Stopped in between, the initramfs is absent: no mixed pair
# exists and the grouped make target is missing, so make rebuilds.
mkdir -p "$OUT_DIR"
rm -f "$OUT_DIR/initramfs.cpio.gz"
mv -f "$VMLINUZ" "$OUT_DIR/vmlinuz"
mv -f "$INITRAMFS" "$OUT_DIR/initramfs.cpio.gz"
echo "$tag published: $OUT_DIR/vmlinuz $OUT_DIR/initramfs.cpio.gz"
@@ -0,0 +1,196 @@
#!/bin/sh
# sqs-store-microvm-publish_test.sh — a staged SQS store microVM pair reaches
# the output directory only when every gate passes, and a failed build cannot
# leave a pair that make then takes as up to date.
#
# Artifacts are small fake archives listing the gated paths; no image is built.
set -eu
LIB_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
PUBLISH="$LIB_DIR/sqs-store-microvm-publish.sh"
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
fails=0
pass() { echo " ok - $1"; }
fail() { echo " FAIL - $1"; fails=$((fails + 1)); }
echo "-- lib/sqs-store-microvm-publish.sh"
for tool in cpio gzip make; do
if ! command -v "$tool" >/dev/null 2>&1; then
echo " FAIL - required tool not found: $tool"
exit 1
fi
done
# stage <dir> [omit-path] — a fake staged pair; omit-path is left out of the archive.
stage() {
dir=$1 omit=${2:-}
root="$TMP/root.$$.$(date +%s%N)"
for p in init etc/inittab usr/local/bin/nats-server sbin/mkfs.ext4 sbin/e2fsck \
usr/local/lib/sqs-store/sqs-store-lib.sh usr/local/lib/sqs-store/sqs-store-prepare \
usr/local/lib/sqs-store/sqs-store-run usr/local/lib/sqs-store/sqs-store-stop \
dev/console dev/null lib/modules/6.12-virt/kernel/fs/ext4/ext4.ko \
lib/modules/6.12-virt/kernel/drivers/acpi/tiny-power-button.ko; do
[ "$p" = "$omit" ] && continue
mkdir -p "$root/$(dirname "$p")"
echo "$p" > "$root/$p"
done
# pad=N appends N files after the gated ones, as a real image's listing has.
if [ "${pad:-0}" -gt 0 ]; then
mkdir -p "$root/zz"
(cd "$root/zz" && seq "$pad" | xargs touch)
fi
mkdir -p "$dir"
(cd "$root" && find . -mindepth 1 | sed 's|^\./||' | sort | cpio --quiet -o -H newc) | gzip > "$dir/initramfs.cpio.gz"
echo kernel > "$dir/vmlinuz"
rm -rf "$root"
}
# fingerprint <dir> — content and mtime of both outputs, or "absent".
fingerprint() {
for f in "$1/vmlinuz" "$1/initramfs.cpio.gz"; do
if [ -e "$f" ]; then
printf '%s %s ' "$(cksum < "$f")" "$(stat -c %Y "$f")"
else
printf 'absent '
fi
done
}
# --- A valid pair is published and leaves the stage ---
stage "$TMP/ok/stage"
if bash "$PUBLISH" "$TMP/ok/stage" "$TMP/ok/out" >/dev/null 2>&1 \
&& [ -s "$TMP/ok/out/vmlinuz" ] && [ -s "$TMP/ok/out/initramfs.cpio.gz" ] \
&& [ ! -e "$TMP/ok/stage/vmlinuz" ] && [ ! -e "$TMP/ok/stage/initramfs.cpio.gz" ]; then
pass "valid pair is published"
else
fail "valid pair is published"
fi
# --- A large listing with the modules early still passes the module gate ---
pad=20000 stage "$TMP/large/stage"
if bash "$PUBLISH" "$TMP/large/stage" "$TMP/large/out" >/dev/null 2>&1; then
pass "large archive with early modules is published"
else
fail "large archive with early modules is published"
fi
# --- Each failing gate keeps the previous valid pair exactly ---
for case in nats-server store-stop ext4 size; do
d="$TMP/keep-$case"
stage "$d/prev"
bash "$PUBLISH" "$d/prev" "$d/out" >/dev/null 2>&1
before=$(fingerprint "$d/out")
max=50
case $case in
nats-server) stage "$d/stage" usr/local/bin/nats-server ;;
store-stop) stage "$d/stage" usr/local/lib/sqs-store/sqs-store-stop ;;
ext4) stage "$d/stage" lib/modules/6.12-virt/kernel/fs/ext4/ext4.ko ;;
size) stage "$d/stage"; max=0 ;;
esac
if MICROVM_ARTIFACT_MAX_MiB=$max bash "$PUBLISH" "$d/stage" "$d/out" >/dev/null 2>&1; then
fail "$case gate failure is refused"
elif [ "$(fingerprint "$d/out")" = "$before" ]; then
pass "$case gate failure keeps the previous pair"
else
fail "$case gate failure keeps the previous pair"
fi
done
# --- With no previous pair, a failed gate publishes nothing ---
stage "$TMP/none/stage" usr/local/bin/nats-server
if bash "$PUBLISH" "$TMP/none/stage" "$TMP/none/out" >/dev/null 2>&1; then
fail "failed gate with no previous pair is refused"
elif [ "$(fingerprint "$TMP/none/out")" = "absent absent " ]; then
pass "failed gate with no previous pair publishes nothing"
else
fail "failed gate with no previous pair publishes nothing"
fi
# --- make cannot take a failed rebuild's pair as up to date ---
# The same grouped-target shape as the Makefile; the builder stages a pair
# missing nats-server once BAD exists, the way a failed real build would.
m="$TMP/make"
mkdir -p "$m/out"
cat > "$m/build.sh" <<EOF
#!/bin/sh
set -eu
rm -rf "$m/stage"
. "$m/build.sh.lib"
if [ -e "$m/BAD" ]; then
stage "$m/stage" usr/local/bin/nats-server
else
stage "$m/stage"
fi
bash "$PUBLISH" "$m/stage" "$m/out"
EOF
{
echo "TMP=\"$TMP\""
sed -n '/^stage() {/,/^}/p' "$0"
} > "$m/build.sh.lib"
printf 'out/vmlinuz out/initramfs.cpio.gz &: input\n\tsh build.sh\n' > "$m/Makefile"
echo v1 > "$m/input"
if (cd "$m" && make -s out/vmlinuz >/dev/null 2>&1) && [ -s "$m/out/vmlinuz" ]; then
pass "make builds the first valid pair"
else
fail "make builds the first valid pair"
echo " $fails failure(s)"; exit 1
fi
good=$(fingerprint "$m/out")
touch "$m/BAD"
# Age the published pair so the input is strictly newer, without a future mtime.
past="@$(( $(date +%s) - 10 ))"
touch -d "$past" "$m/out/vmlinuz" "$m/out/initramfs.cpio.gz"
touch "$m/input"
good=$(fingerprint "$m/out")
if (cd "$m" && make -s out/vmlinuz >/dev/null 2>&1); then
fail "make reports the failed rebuild"
else
pass "make reports the failed rebuild"
fi
if (cd "$m" && make -q out/vmlinuz out/initramfs.cpio.gz); then
fail "after a failed rebuild make still sees the pair as stale"
else
pass "after a failed rebuild make still sees the pair as stale"
fi
if [ "$(fingerprint "$m/out")" = "$good" ]; then
pass "failed rebuild leaves the previous valid pair"
else
fail "failed rebuild leaves the previous valid pair"
fi
# --- A publish stopped after the kernel lands leaves no mixed pair ---
# A stub mv lets the first rename through and fails the second: the point at
# which an interrupt would leave a new kernel beside an old initramfs.
i="$TMP/interrupt"
mkdir -p "$i/bin"
real_mv=$(command -v mv)
{
echo '#!/bin/sh'
echo "if [ -e '$i/moved' ]; then exit 1; fi"
echo ": > '$i/moved'"
echo "exec '$real_mv' \"\$@\""
} > "$i/bin/mv"
chmod +x "$i/bin/mv"
stage "$i/prev"
bash "$PUBLISH" "$i/prev" "$i/out" >/dev/null 2>&1
stage "$i/stage"
echo new-kernel > "$i/stage/vmlinuz"
if PATH="$i/bin:$PATH" bash "$PUBLISH" "$i/stage" "$i/out" >/dev/null 2>&1; then
fail "interrupted publish is reported"
elif [ "$(cat "$i/out/vmlinuz")" = new-kernel ] && [ ! -e "$i/out/initramfs.cpio.gz" ]; then
pass "interrupted publish leaves no initramfs beside the new kernel"
else
fail "interrupted publish leaves no initramfs beside the new kernel"
fi
printf 'out/vmlinuz out/initramfs.cpio.gz &: input\n\ttrue\n' > "$i/Makefile"
touch -d "@$(( $(date +%s) - 10 ))" "$i/input"
if (cd "$i" && make -q out/vmlinuz out/initramfs.cpio.gz); then
fail "make does not accept the interrupted publish"
else
pass "make does not accept the interrupted publish"
fi
[ "$fails" -eq 0 ] || { echo " $fails failure(s)"; exit 1; }
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# stage-sqs-store-microvm.sh <image-dir> <dist-root>: copy a built SQS store
# microVM image into a release tree as <dist-root>/microvm-sqs-store. Without a
# complete image it stages nothing and says so, as the load balancer image does.
set -eu
src=$1 dest=$2/microvm-sqs-store
# An image staged by an earlier build must not ship with this one. Only the
# two image files are removed; anything else in the directory is left alone.
rm -f "$dest/vmlinuz" "$dest/initramfs.cpio.gz"
if [ -s "$src/vmlinuz" ] && [ -s "$src/initramfs.cpio.gz" ]; then
echo "[distro] staging the SQS store microVM image into the tarball"
mkdir -p "$dest"
cp "$src/vmlinuz" "$src/initramfs.cpio.gz" "$dest/"
else
[ ! -d "$dest" ] || rmdir "$dest" 2> /dev/null || true
echo "[distro] WARNING: SQS store microVM image missing; the tarball will not include it"
echo "[distro] run 'make build-sqs-store-microvm-image' first"
fi
+28 -5
View File
@@ -190,7 +190,7 @@ run sudo systemctl reset-failed 'spinifex-*' 2>/dev/null || true
# the wipe and before the verification, failing the reset on a file the script
# had already deleted. update-nodes.sh carries the same wait.
if ! $DRY_RUN; then
for unit in spinifex-predastore spinifex-viperblock spinifex-sqs-store spinifex-nats; do
for unit in spinifex-predastore spinifex-viperblock spinifex-nats; do
if systemctl is-active --quiet "$unit"; then
sudo systemctl stop "$unit" || true
fi
@@ -273,6 +273,33 @@ if [ -n "$OVS_UNIT" ]; then
fi
run sudo rm -f /etc/openvswitch/system-id.conf
# --- BEGIN ovs nss nicknames ---
# ovs_nss_nicknames — the entries ovs-monitor-ipsec imported, read from
# `certutil -L` on stdin: ovs_certkey_* is this node's certificate and key,
# ovs_cert_* the CA and any peer certificates. Everything else is someone else's.
ovs_nss_nicknames() {
awk '$1 ~ /^ovs_cert(key)?_/ {print $1}' | LC_ALL=C sort -u
}
# --- END ovs nss nicknames ---
# A node rejoining another cluster must not keep trusting this one's CA. Only
# the NSS entries go: other identities and /etc/ipsec.d/*.conf are left alone.
if [ -x /usr/libexec/ipsec/pluto ] && command -v certutil >/dev/null 2>&1; then
log "removing Spinifex IPsec identities from libreswan's NSS database"
# A running ovs-monitor-ipsec imports them again from other_config.
run sudo systemctl stop openvswitch-ipsec.service 2>/dev/null || true
for nss in /var/lib/ipsec/nss /etc/ipsec.d; do
sudo test -e "$nss/cert9.db" || continue
for nick in $(sudo certutil -L -d "sql:$nss" 2>/dev/null | ovs_nss_nicknames); do
log " deleting $nick from $nss"
delete=-D
case "$nick" in ovs_certkey_*) delete=-F ;; esac
run sudo certutil "$delete" -d "sql:$nss" -n "$nick" ||
log " NOTE: could not delete $nick from $nss; remove it with certutil by hand"
done
done
fi
# Delete the OVN DBs outright — a caller re-running setup-ovn.sh gets fresh
# empty ones. This is what clears stale chassis rows and port bindings, which
# otherwise accumulate across resets and wedge ovn-controller in a commit loop.
@@ -401,10 +428,6 @@ if ! $KEEP_DATA && [ -d "$DATA_DIR/nats/jetstream" ]; then
log "removing the JetStream store"
run sudo rm -rf "$DATA_DIR/nats/jetstream"
fi
if ! $KEEP_DATA && [ -d "$DATA_DIR/sqs-store/jetstream" ]; then
log "removing the SQS store JetStream data"
run sudo rm -rf "$DATA_DIR/sqs-store/jetstream"
fi
# Directories may survive — a mountpoint cannot be removed, and neither can the
# path leading down to one. Files may not: a surviving file is state that would
+28 -1
View File
@@ -1,7 +1,8 @@
#!/bin/sh
# node-reset_test.sh — tests the QEMU process match node-reset.sh uses to stop
# guests before it deletes Viperblock state, against real processes, and the
# instance and mounted-volume counts it and uninstall-spx.sh report before deleting.
# instance and mounted-volume counts it and uninstall-spx.sh report before deleting,
# and the libreswan NSS entries it deletes.
#
# Each fake guest is a copy of sleep named like a QEMU binary, so the kernel
# gives it the same comm, including the 15-character truncation.
@@ -129,6 +130,32 @@ mkdir -p "$empty"
expect "counts no instances without a state file" "$(count count_instances "$empty")" 0
expect "counts no mounted volumes without a viperblock directory" "$(count count_mounted_volumes "$empty")" 0
echo "-- node-reset.sh libreswan NSS nicknames"
sed -n '/^# --- BEGIN ovs nss nicknames ---$/,/^# --- END ovs nss nicknames ---$/p' \
"$SCRIPT_DIR/node-reset.sh" > "$TMP/nss.sh"
# `certutil -L` as it prints a database holding an operator's own identity and
# CA beside what ovs-monitor-ipsec imported, one peer listed twice.
cat > "$TMP/certutil-L" <<'EOF'
Certificate Nickname Trust Attributes
SSL,S/MIME,JAR/XPI
ovs_certkey_node1 u,u,u
ovs_cert_cacert CT,,
ovs_cert_node2 P,P,P
ovs_cert_node2 P,P,P
site-vpn u,u,u
corp-ca CT,C,C
ovs_certificate_store ,,
EOF
if [ ! -s "$TMP/nss.sh" ]; then
fail "no ovs nss nicknames block in node-reset.sh"
else
got=$(bash -c '. "$1"; ovs_nss_nicknames < "$2"' _ "$TMP/nss.sh" "$TMP/certutil-L" | tr '\n' ' ')
expect "selects only ovs-monitor-ipsec's entries, once each" "$got" "ovs_cert_cacert ovs_cert_node2 ovs_certkey_node1 "
fi
if [ "$fails" -gt 0 ]; then
echo "$fails failure(s)"
exit 1
+72 -31
View File
@@ -172,6 +172,8 @@ OVN_DBDIR="${OVN_DBDIR:-/var/lib/ovn}"
# Seconds to wait for the database servers to exit, then for a SIGKILL to land.
OVN_DB_STOP_WAIT="${OVN_DB_STOP_WAIT:-30}"
OVN_DB_KILL_WAIT="${OVN_DB_KILL_WAIT:-10}"
# Seconds to wait for a restarted clustered NB or SB member to rejoin its cluster.
OVN_RAFT_REJOIN_WAIT="${OVN_RAFT_REJOIN_WAIT:-60}"
# Records that --management set this node up. Nodes set up before it existed
# carry only the legacy marker, OVN_CTL_OPTS in /etc/default/ovn-central.
OVN_ROLE_FILE=/etc/spinifex/ovn-role
@@ -757,6 +759,42 @@ stop_ovn_databases() {
exit 1
}
# db_clients — sets NBCTL/SBCTL. A clustered DB has no unix socket to fall back
# on, and a follower refuses to answer at all unless leader-only is turned off;
# writes through a follower are forwarded to the leader.
db_clients() {
NBCTL=(ovn-nbctl)
SBCTL=(ovn-sbctl)
if [ -n "$DB_CLUSTER_LOCAL_ADDR" ]; then
NBCTL=(ovn-nbctl --db="tcp:$DB_CLUSTER_LOCAL_ADDR:6641" --no-leader-only)
SBCTL=(ovn-sbctl --db="tcp:$DB_CLUSTER_LOCAL_ADDR:6642" --no-leader-only)
fi
}
# set_client_connections — the loopback client listeners. A rerun's restart can
# hand the leadership away, so this goes through NBCTL/SBCTL, not the socket.
set_client_connections() {
sudo "${NBCTL[@]}" set-connection ptcp:6641:127.0.0.1
sudo "${SBCTL[@]}" set-connection ptcp:6642:127.0.0.1
}
# wait_for_raft_member <ctl> <schema> — waits until this server is a cluster
# member that knows its leader, which a restarted member is once it rejoins.
# Returns 1 on timeout.
wait_for_raft_member() {
local ctl=$1 schema=$2 status i
for i in $(seq 1 "$OVN_RAFT_REJOIN_WAIT"); do
status=$(sudo ovs-appctl -t "$ctl" cluster/status "$schema" 2>/dev/null || true)
if grep -qx 'Status: cluster member' <<<"$status" &&
grep -q '^Leader: ' <<<"$status" && ! grep -qx 'Leader: unknown' <<<"$status"; then
return 0
fi
echo " Waiting for $schema to rejoin its RAFT cluster... ($i/$OVN_RAFT_REJOIN_WAIT)"
sleep 1
done
return 1
}
# --- Step 2: Enable services ---
# ovn-ctl consults the RAFT flags only when it creates a database, so any
# existing DB file is served as it stands and the cluster flags are ignored.
@@ -996,16 +1034,9 @@ EOF
fi
fi
# A clustered DB has no unix socket to fall back on, and a follower refuses
# to answer at all unless leader-only is turned off. Without both of these
# the waits below can never succeed on a clustered node: they burn their
# full timeout, gate nothing, and the run still continues.
NBCTL=(ovn-nbctl)
SBCTL=(ovn-sbctl)
if [ -n "$DB_CLUSTER_LOCAL_ADDR" ]; then
NBCTL=(ovn-nbctl --db="tcp:$DB_CLUSTER_LOCAL_ADDR:6641" --no-leader-only)
SBCTL=(ovn-sbctl --db="tcp:$DB_CLUSTER_LOCAL_ADDR:6642" --no-leader-only)
fi
# Without these the waits below can never succeed on a clustered node:
# they burn their full timeout, gate nothing, and the run still continues.
db_clients
# Wait for OVN NB DB socket to become available
for i in $(seq 1 15); do
@@ -1067,29 +1098,34 @@ EOF
# with no join step to absorb the window — attaching before the leader is
# elected (and before northd writes the gateway logical flows) leaves it with
# a partial datapath that never reconverges. Gate on SB reachable and, when
# clustered, an elected leader.
# clustered, both members back in their clusters under an elected leader.
for i in $(seq 1 30); do
if sudo "${SBCTL[@]}" --timeout=2 show >/dev/null 2>&1; then
if [ -z "$DB_CLUSTER_LOCAL_ADDR" ]; then
break
fi
SB_LEADER=$(sudo ovs-appctl -t /var/run/ovn/ovnsb_db.ctl \
cluster/status OVN_Southbound 2>/dev/null \
| awk '/^Leader:/{print $2; exit}')
if [ -n "$SB_LEADER" ] && [ "$SB_LEADER" != "unknown" ]; then
break
fi
fi
echo " Waiting for OVN SB DB leader... ($i/30)"
sudo "${SBCTL[@]}" --timeout=2 show >/dev/null 2>&1 && break
echo " Waiting for OVN SB DB... ($i/30)"
sleep 1
done
# The restart above took both of this node's members down at once. Returning
# before they rejoin lets a rerun on the next database node take a second
# member of each cluster down, and one of three left is below quorum.
if [ -n "$DB_CLUSTER_LOCAL_ADDR" ]; then
for member in "/var/run/ovn/ovnnb_db.ctl OVN_Northbound" "/var/run/ovn/ovnsb_db.ctl OVN_Southbound"; do
# shellcheck disable=SC2086 # two words: the ctl socket and the schema
if ! wait_for_raft_member $member; then
echo "ERROR: this node's ${member#* } server is not back in its RAFT cluster after ${OVN_RAFT_REJOIN_WAIT}s." >&2
echo " Restarting OVN central on another database node now would leave the cluster" >&2
echo " without quorum. Check: sudo ovs-appctl -t ${member% *} cluster/status ${member#* }" >&2
exit 1
fi
done
echo " RAFT: NB and SB members rejoined, leader elected"
fi
# set-connection replicates through RAFT, so it only runs on the create
# node. Scoped to loopback, not a wildcard ptcp:6641, because 127.0.0.1
# is valid on every node; the differing LAN address is set above instead.
if [ -z "$DB_CLUSTER_REMOTE_ADDR" ]; then
sudo ovn-nbctl set-connection ptcp:6641:127.0.0.1
sudo ovn-sbctl set-connection ptcp:6642:127.0.0.1
set_client_connections
if [ -n "$LAN_ADDR" ]; then
echo " OVN NB DB listening on tcp:127.0.0.1:6641, tcp:$LAN_ADDR:6641"
echo " OVN SB DB listening on tcp:127.0.0.1:6642, tcp:$LAN_ADDR:6642"
@@ -1958,16 +1994,21 @@ echo "Step 10: Enabling OVN auto-start on boot..."
sudo systemctl enable "$OVS_UNIT" 2>/dev/null || true
sudo systemctl enable ovn-controller 2>/dev/null || true
printf ' %-21s enabled on boot\n' "${OVS_UNIT%.service}:" ovn-controller:
if distro_has_libreswan; then
# OVN IPsec does not run on libreswan yet, so it stays off here. Starting
# openvswitch-ipsec would also start pluto, which listens on UDP 500/4500.
if distro_has_libreswan && [ "$(systemctl is-active openvswitch-ipsec.service 2>/dev/null)" = active ]; then
# The daemon turned IPsec on; stopping it here would drop live tunnels.
printf ' %-21s %s\n' openvswitch-ipsec: "active: IPsec is on, left to the daemon" ipsec: "active: IPsec is on, left to the daemon"
elif distro_has_libreswan; then
# Off until the daemon asks: pluto listens on UDP 500/4500 once started.
# Enabled under the mask, so the daemon's unmask also brings both back on boot.
IPSEC_UNITS=(ipsec.service)
distro_unit_exists openvswitch-ipsec.service && IPSEC_UNITS+=(openvswitch-ipsec.service)
if ! sudo systemctl mask --now "${IPSEC_UNITS[@]}" >/dev/null; then
echo "ERROR: could not stop and mask ${IPSEC_UNITS[*]}; IPsec must stay off on libreswan" >&2
if ! sudo systemctl unmask "${IPSEC_UNITS[@]}" >/dev/null 2>&1 ||
! sudo systemctl enable "${IPSEC_UNITS[@]}" >/dev/null 2>&1 ||
! sudo systemctl mask --now "${IPSEC_UNITS[@]}" >/dev/null; then
echo "ERROR: could not enable, stop and mask ${IPSEC_UNITS[*]}; IPsec must stay off until the daemon turns it on" >&2
exit 1
fi
printf ' %-21s %s\n' openvswitch-ipsec: "masked: IPsec stays off on libreswan" ipsec: "masked: IPsec stays off on libreswan"
printf ' %-21s %s\n' openvswitch-ipsec: "masked: IPsec is off, left to the daemon" ipsec: "masked: IPsec is off, left to the daemon"
elif [ "$(systemctl is-enabled openvswitch-ipsec.service 2>/dev/null)" = masked ]; then
# The daemon masks it while IPsec is off and unmasks it to turn IPsec on.
printf ' %-21s %s\n' openvswitch-ipsec: "masked: IPsec is off, left to the daemon"
+68
View File
@@ -454,6 +454,47 @@ case "$RC:$OUT" in
*) fail "no recreate-db: standalone DB rc=$RC out=$OUT" ;;
esac
# --------------------------------------------------------------------------
# A rerun returns only once both of this node's RAFT members have rejoined.
# --------------------------------------------------------------------------
# A rerun restarts the node's NB and SB members together, so returning early
# lets the next database node's rerun take a second member of each down.
awk '$0 == "wait_for_raft_member() {" { on = 1 } on { print } on && $0 == "}" { exit }' "$SETUP" >"$TMP/raft_fn.sh"
mkdir -p "$TMP/raftbin"
printf '#!/bin/sh\nexit 0\n' >"$TMP/raftbin/sleep"
printf '#!/bin/sh\n[ -f "%s" ] || exit 1\ncat "%s"\n' "$TMP/cluster-status" "$TMP/cluster-status" >"$TMP/raftbin/ovs-appctl"
chmod +x "$TMP/raftbin/sleep" "$TMP/raftbin/ovs-appctl"
# raft_member <Status:> <Leader:> — runs wait_for_raft_member against a
# cluster/status in that state, or none when Status is "absent"; sets RC.
raft_member() {
rm -f "$TMP/cluster-status"
if [ "$1" != absent ]; then
printf 'a1b2\nName: OVN_Northbound\nStatus: %s\nRole: follower\nTerm: 4\nLeader: %s\nVote: c3d4\n\nServers:\n a1b2 (a1b2 at tcp:10.0.0.1:6643) (self)\n c3d4 (c3d4 at tcp:10.0.0.2:6643)\n' \
"$1" "$2" >"$TMP/cluster-status"
fi
RC=0
PATH="$TMP/raftbin:$PATH" bash -c 'sudo() { "$@"; }; OVN_RAFT_REJOIN_WAIT=2; . "$1"
wait_for_raft_member /var/run/ovn/ovnnb_db.ctl OVN_Northbound' _ "$TMP/raft_fn.sh" >/dev/null 2>&1 || RC=$?
}
if [ ! -s "$TMP/raft_fn.sh" ]; then
fail "raft: no wait_for_raft_member in setup-ovn.sh"
else
raft_member "cluster member" c3d4
if [ "$RC" = 0 ]; then pass "raft: a member following a known leader has rejoined"; else fail "raft: follower with leader rc=$RC"; fi
raft_member "cluster member" self
if [ "$RC" = 0 ]; then pass "raft: a member that is the leader has rejoined"; else fail "raft: leader rc=$RC"; fi
raft_member "cluster member" unknown
if [ "$RC" != 0 ]; then pass "raft: a member that has not found its leader has not rejoined"; else fail "raft: unknown leader accepted"; fi
raft_member "disconnected from the cluster (election timeout)" c3d4
if [ "$RC" != 0 ]; then pass "raft: a disconnected member that remembers a leader has not rejoined"; else fail "raft: disconnected member accepted"; fi
raft_member "joining cluster" c3d4
if [ "$RC" != 0 ]; then pass "raft: a member still joining has not rejoined"; else fail "raft: joining member accepted"; fi
raft_member absent ""
if [ "$RC" != 0 ]; then pass "raft: a server that does not answer has not rejoined"; else fail "raft: unanswered cluster/status accepted"; fi
fi
rm -rf "$TMP/dbdir"
mkdir -p "$TMP/dbdir"
ensure_db true
@@ -478,6 +519,33 @@ else
fi
printf '#!/bin/sh\nexit 1\n' >"$TMP/bin/pgrep"
# A rerun restarts this node's members, which can hand the leadership to a
# peer, so the create node's set-connection must still land as a follower.
for fn in db_clients set_client_connections; do
awk -v f="$fn() {" '$0 == f { on = 1 } on { print } on && $0 == "}" { exit }' "$SETUP" >>"$TMP/conn_fn.sh"
done
mkdir -p "$TMP/followerbin"
for ctl in ovn-nbctl ovn-sbctl; do
cat >"$TMP/followerbin/$ctl" <<EOF
#!/bin/sh
case " \$* " in
*" --no-leader-only "*) echo "$ctl \$*" >>"$TMP/conn.log" ;;
*) echo "$ctl: unix:/var/run/ovn/db.sock: database connection failed ()" >&2; exit 1 ;;
esac
EOF
chmod +x "$TMP/followerbin/$ctl"
done
: >"$TMP/conn.log"
RC=0
PATH="$TMP/followerbin:$PATH" bash -c 'set -e; sudo() { "$@"; }; DB_CLUSTER_LOCAL_ADDR=10.0.0.1; . "$1"
db_clients; set_client_connections' _ "$TMP/conn_fn.sh" >/dev/null 2>&1 || RC=$?
if [ "$RC" = 0 ] && [ "$(cat "$TMP/conn.log")" = "ovn-nbctl --db=tcp:10.0.0.1:6641 --no-leader-only set-connection ptcp:6641:127.0.0.1
ovn-sbctl --db=tcp:10.0.0.1:6642 --no-leader-only set-connection ptcp:6642:127.0.0.1" ]; then
pass "connections: the create node sets the client listeners while a follower"
else
fail "connections: as a follower rc=$RC calls [$(cat "$TMP/conn.log")]"
fi
if [ "$fails" -ne 0 ]; then
echo " setup-ovn.sh: $fails failure(s)"
exit 1
+131 -24
View File
@@ -283,7 +283,6 @@ create_service_users() {
# Create per-service users with correct home directories
declare -A SERVICE_HOMES=(
[nats]="/var/lib/spinifex/nats"
[sqsstore]="/var/lib/spinifex/sqs-store"
[gw]="/var/lib/spinifex/awsgw"
[daemon]="/var/lib/spinifex/spinifex"
[storage]="/var/lib/spinifex/predastore"
@@ -292,7 +291,7 @@ create_service_users() {
[vpcd]="/var/lib/spinifex"
[ui]="/var/lib/spinifex"
)
for svc in nats sqsstore gw daemon storage northstar viperblock vpcd ui; do
for svc in nats gw daemon storage northstar viperblock vpcd ui; do
local user="spinifex-${svc}"
if ! id "$user" > /dev/null 2>&1; then
$SUDO useradd --system --no-create-home \
@@ -324,7 +323,7 @@ create_service_users() {
# Daemon consumes viperblock's NBD socket — join the producer-typed group.
$SUDO usermod -aG spinifex-viperblock spinifex-daemon
info "Service users created (spinifex-{nats,sqsstore,gw,daemon,storage,northstar,viperblock,vpcd,ui})"
info "Service users created (spinifex-{nats,gw,daemon,storage,northstar,viperblock,vpcd,ui})"
}
# --- Install scoped sudoers rules ---
@@ -390,10 +389,68 @@ install_ipsec_state_helper() {
set -eu
if [ "$#" -ne 1 ]; then
echo "usage: $0 <on|off>" >&2
echo "usage: $0 <on|off|guard|unguard>" >&2
exit 2
fi
# libreswan drops a tunnel's xfrm policies while IKE fails, and pluto flushes
# the whole xfrm table when it starts or stops, so Geneve from the encap address
# is dropped in nft unless the route carries an SA.
GUARD_TABLE="inet spinifex_ipsec_guard"
unguard() {
printf 'table %s\ndelete table %s\n' "$GUARD_TABLE" "$GUARD_TABLE" | nft -f -
}
want=""
want_src() {
case "$1" in
*.*.*.*) case "$1" in *[!0-9.]*) src=0.0.0.0/0 ;; *) src="$1/32" ;; esac ;;
*) src=0.0.0.0/0 ;;
esac
case " $want " in *" $src "*) ;; *) want="$want $src" ;; esac
}
# One source per local address of a tunnel with a remote_name, which
# ovn-controller sets only while NB_Global.ipsec is on. A tunnel without a
# usable local_ip is guarded from every source rather than left open.
guard() {
ifaces=$(ovs-vsctl --timeout=5 --bare --columns=name find Interface type=geneve)
for iface in $ifaces; do
peer=$(ovs-vsctl --timeout=5 --if-exists get Interface "$iface" options:remote_name)
[ -n "$peer" ] || continue
want_src "$(ovs-vsctl --timeout=5 --if-exists get Interface "$iface" options:local_ip | tr -d '"')"
done
# At boot pluto is up before ovn-controller builds the tunnels, and its
# callers guard only while encryption is wanted, so guard the encap address
# until the tunnels say otherwise.
if [ -z "$ifaces" ]; then
encap=$(ovs-vsctl --timeout=5 --if-exists get Open_vSwitch . external_ids:ovn-encap-ip | tr -d '"')
for ip in $(echo "$encap" | tr ',' ' '); do want_src "$ip"; done
[ -n "$want" ] || want_src ""
fi
if [ -z "$want" ]; then
unguard
return
fi
# One transaction, so the old set is never gone before the new one is in.
nft -f - << NFT
table $GUARD_TABLE
delete table $GUARD_TABLE
table $GUARD_TABLE {
set srcs {
type ipv4_addr
flags interval
elements = { $(echo $want | tr ' ' ',') }
}
chain out {
type filter hook output priority 0; policy accept;
ip saddr @srcs udp dport 6081 rt ipsec missing drop
}
}
NFT
}
# mask/unmask rather than disable/enable. The daemon's unit sets
# ProtectSystem=full, so /etc is read-only in the namespace its children inherit,
# and disabling a unit that also ships a SysV script shells out to update-rc.d
@@ -401,12 +458,24 @@ fi
# ovs-monitor-ipsec execs the strongSwan starter itself rather than going through
# this unit, so leaving it enabled only contends for UDP 500/4500. Off in both
# states. Absent on a host without strongswan, which is not an error.
systemctl mask --now strongswan-starter.service >/dev/null 2>&1 || true
# states. Masking a unit no package ships leaves a stray /dev/null link, so a
# host without strongSwan gets none, and loses one an older helper left.
if [ -e /usr/lib/systemd/system/strongswan-starter.service ] || [ -e /lib/systemd/system/strongswan-starter.service ]; then
systemctl mask --now strongswan-starter.service >/dev/null 2>&1 || true
elif [ "$(systemctl is-enabled strongswan-starter.service 2>/dev/null)" = masked ]; then
systemctl unmask strongswan-starter.service >/dev/null 2>&1 || true
fi
case "$1" in
on)
systemctl unmask openvswitch-ipsec.service
if [ -x /usr/libexec/ipsec/pluto ]; then
# ovs-monitor-ipsec drives pluto over its control socket but does
# not start it, so pluto comes up first under its own unit.
systemctl unmask ipsec.service openvswitch-ipsec.service
systemctl start ipsec.service
else
systemctl unmask openvswitch-ipsec.service
fi
exec systemctl start openvswitch-ipsec.service
;;
off)
@@ -415,8 +484,15 @@ case "$1" in
# On Debian that name is strongswan-starter's alias, masked above.
if [ -x /usr/libexec/ipsec/pluto ]; then
systemctl mask --now ipsec.service
unguard
fi
;;
guard)
guard
;;
unguard)
unguard
;;
*)
echo "state not permitted: $1" >&2
exit 2
@@ -624,7 +700,7 @@ table inet spinifex_filter {
# inventory and running instances to anyone who asks. 8660 is
# predastore's unauthenticated /healthz and /readyz, which name the
# peers a gate cannot reach, so it belongs here for the same reason.
ip saddr $spinifex_peers tcp dport { 4222, 4223, 4248, 4249, 4432, 5300, 6641, 6642, 6643, 6644, 8660 } accept
ip saddr $spinifex_peers tcp dport { 4222, 4248, 4432, 5300, 6641, 6642, 6643, 6644, 8660 } accept
ip saddr $spinifex_peers udp dport { 5300, 6660, 7660 } accept
# Encap plane, peer-scoped: Geneve, IKE, NAT-T and ESP. Geneve is a
@@ -1466,6 +1542,41 @@ install_files() {
$SUDO cp "$EXTRACT_DIR/microvm/"* /usr/share/spinifex/microvm/
info " /usr/share/spinifex/microvm/*"
fi
install_sqs_store_image
}
# The SQS store image ships beside the load balancer's, not inside it: an older
# installer copies microvm/* without -r and would stop at a subdirectory.
install_sqs_store_image() {
local src="$EXTRACT_DIR/microvm-sqs-store" f
local dest="${SPINIFEX_MICROVM_DIR:-/usr/share/spinifex/microvm}/sqs-store"
# A previously installed image belongs to an older release, and this
# release's daemon must not boot it. Only the two image files are removed.
if [ ! -d "$src" ]; then
remove_sqs_store_image "$dest"
warn "This release has no SQS store microVM image; SQS store launches will be refused"
return 0
fi
for f in vmlinuz initramfs.cpio.gz; do
if [ ! -s "$src/$f" ]; then
remove_sqs_store_image "$dest"
fatal "The SQS store microVM image in this release is incomplete: $f is missing"
fi
done
# The initramfs goes last, so an interrupted install leaves no pair the
# daemon would boot: it refuses a launch while either file is missing.
$SUDO install -d "$dest"
$SUDO rm -f "$dest/initramfs.cpio.gz"
$SUDO install -m 0644 "$src/vmlinuz" "$dest/vmlinuz"
$SUDO install -m 0644 "$src/initramfs.cpio.gz" "$dest/initramfs.cpio.gz"
info " $dest/vmlinuz, $dest/initramfs.cpio.gz"
}
# Running store VMs keep their already-loaded kernel; the files are read at boot.
remove_sqs_store_image() {
[ -e "$1/initramfs.cpio.gz" ] || [ -e "$1/vmlinuz" ] || return 0
$SUDO rm -f "$1/initramfs.cpio.gz" "$1/vmlinuz"
warn "Removed the SQS store microVM image left by an earlier install from $1"
}
# --- Create directories ---
@@ -1521,12 +1632,6 @@ TMPEOF
$SUDO chown "spinifex-nats:$SPINIFEX_GROUP" /etc/spinifex/nats
$SUDO chmod 0750 /etc/spinifex/nats
# The SQS store holds its own token: 0700 keeps every other spinifex-*
# service in the shared group out.
$SUDO mkdir -p /etc/spinifex/sqs-store
$SUDO chown "spinifex-sqsstore:$SPINIFEX_GROUP" /etc/spinifex/sqs-store
$SUDO chmod 0700 /etc/spinifex/sqs-store
$SUDO mkdir -p /etc/spinifex/predastore
$SUDO chown "spinifex-storage:$SPINIFEX_GROUP" /etc/spinifex/predastore
$SUDO chmod 0750 /etc/spinifex/predastore
@@ -1554,10 +1659,6 @@ TMPEOF
$SUDO chown "spinifex-nats:$SPINIFEX_GROUP" /var/lib/spinifex/nats
$SUDO chmod 0700 /var/lib/spinifex/nats
$SUDO mkdir -p /var/lib/spinifex/sqs-store
$SUDO chown "spinifex-sqsstore:$SPINIFEX_GROUP" /var/lib/spinifex/sqs-store
$SUDO chmod 0700 /var/lib/spinifex/sqs-store
$SUDO mkdir -p /var/lib/spinifex/spinifex
$SUDO chown "spinifex-daemon:$SPINIFEX_GROUP" /var/lib/spinifex/spinifex
$SUDO chmod 0700 /var/lib/spinifex/spinifex
@@ -1639,7 +1740,6 @@ fix_file_ownership() {
# Per-service data dirs — recursive chown so existing files are accessible
for entry in \
nats:spinifex-nats \
sqs-store:spinifex-sqsstore \
predastore:spinifex-storage \
northstar:spinifex-northstar \
spinifex:spinifex-daemon \
@@ -1658,11 +1758,6 @@ fix_file_ownership() {
$SUDO chown -R "spinifex-nats:$SPINIFEX_GROUP" /etc/spinifex/nats \
|| fatal "Failed to set ownership on /etc/spinifex/nats"
fi
if [ -d /etc/spinifex/sqs-store ]; then
$SUDO chown -R "spinifex-sqsstore:$SPINIFEX_GROUP" /etc/spinifex/sqs-store \
|| fatal "Failed to set ownership on /etc/spinifex/sqs-store"
$SUDO chmod 0700 /etc/spinifex/sqs-store
fi
if [ -d /etc/spinifex/predastore ]; then
$SUDO chown -R "spinifex-storage:$SPINIFEX_GROUP" /etc/spinifex/predastore \
|| fatal "Failed to set ownership on /etc/spinifex/predastore"
@@ -1769,6 +1864,18 @@ CPUWeight=300
EOF
info " /etc/systemd/system/system.slice.d/spinifex-reserve.conf"
# The plaintext Geneve guard is not persisted, so it goes in when pluto
# starts at boot, before ovn-controller builds the tunnels. `-`: the guard
# must never fail the unit, and the daemon re-asserts it each pass.
if [ -x /usr/libexec/ipsec/pluto ]; then
$SUDO mkdir -p /etc/systemd/system/ipsec.service.d
$SUDO tee /etc/systemd/system/ipsec.service.d/spinifex-guard.conf > /dev/null << EOF
[Service]
ExecStartPost=-${IPSEC_STATE_HELPER} guard
EOF
info " /etc/systemd/system/ipsec.service.d/spinifex-guard.conf"
fi
# daemon-reload / enable require a running systemd — skip inside the ISO
# chroot. Unit files are still dropped into place; firstboot enables them.
if [ "${ISO_BUILD:-0}" = "1" ]; then
+190
View File
@@ -0,0 +1,190 @@
#!/bin/sh
# setup_sqs_store_image_test.sh — tests for shipping the SQS store microVM
# image: staging it into a release tree and installing it with setup.sh.
#
# setup.sh is sourced with INSTALL_SPINIFEX_LIB_ONLY=1 so main never runs, and
# installs into a temporary SPINIFEX_MICROVM_DIR with SUDO cleared.
set -eu
SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
SETUP="$SCRIPT_DIR/setup.sh"
STAGE="$SCRIPT_DIR/lib/stage-sqs-store-microvm.sh"
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
fails=0
pass() { echo " ok - $1"; }
fail() { echo " FAIL - $1"; fails=$((fails + 1)); }
echo "-- SQS store microVM image release and install"
# image <dir> <tag>: a fake built image whose bytes name its tag.
image() {
mkdir -p "$1"
printf 'kernel-%s\n' "$2" > "$1/vmlinuz"
printf 'initramfs-%s\n' "$2" > "$1/initramfs.cpio.gz"
}
# release <dir>: a release tree with the load balancer image, as distro-amd64 builds it.
release() {
rm -rf "$1"
mkdir -p "$1/microvm"
printf 'lb-kernel\n' > "$1/microvm/vmlinuz"
printf 'lb-initramfs\n' > "$1/microvm/initramfs.cpio.gz"
printf 'qboot\n' > "$1/microvm/qboot.rom"
}
# install_image <extract-dir> <microvm-dir> [path-prefix]: runs
# install_sqs_store_image and sets RC and OUT.
install_image() {
RC=0
OUT=$(PATH="${3:-}$PATH" EXTRACT_DIR="$1" SPINIFEX_MICROVM_DIR="$2" INSTALL_SPINIFEX_LIB_ONLY=1 \
bash -c '. "$1"; SUDO=""; install_sqs_store_image' _ "$SETUP" 2>&1) || RC=$?
}
same() { cmp -s "$1" "$2"; }
# --- staging ---
image "$TMP/built" v1
release "$TMP/rel"
sh "$STAGE" "$TMP/built" "$TMP/rel" > "$TMP/stage.out"
if same "$TMP/built/vmlinuz" "$TMP/rel/microvm-sqs-store/vmlinuz" \
&& same "$TMP/built/initramfs.cpio.gz" "$TMP/rel/microvm-sqs-store/initramfs.cpio.gz"; then
pass "stages the built image beside the load balancer's"
else
fail "staged image differs from the build"
fi
if [ ! -e "$TMP/rel/microvm/sqs-store" ] && [ "$(ls "$TMP/rel/microvm" | wc -l)" -eq 3 ]; then
pass "leaves the load balancer's microvm directory as it was"
else
fail "load balancer directory changed: $(ls "$TMP/rel/microvm")"
fi
release "$TMP/rel-none"
mkdir -p "$TMP/half"; printf 'k\n' > "$TMP/half/vmlinuz"
OUT=$(sh "$STAGE" "$TMP/half" "$TMP/rel-none")
if [ ! -e "$TMP/rel-none/microvm-sqs-store" ] && echo "$OUT" | grep -q 'WARNING: SQS store microVM image missing'; then
pass "stages nothing from an incomplete build, and says so"
else
fail "incomplete build staged or unannounced: $OUT"
fi
# --- an older installer meets a release that carries the store image ---
# It copies microvm/* without -r; the sibling directory must not reach it.
mkdir -p "$TMP/old-dest"
if cp "$TMP/rel/microvm/"* "$TMP/old-dest/" 2> "$TMP/old.err" && [ ! -e "$TMP/old-dest/sqs-store" ]; then
pass "an older installer's copy still succeeds and ignores the store image"
else
fail "older installer copy failed: $(cat "$TMP/old.err")"
fi
mkdir -p "$TMP/nested/microvm/sqs-store" "$TMP/nested-dest"
printf 'x\n' > "$TMP/nested/microvm/vmlinuz"
if cp "$TMP/nested/microvm/"* "$TMP/nested-dest/" 2> /dev/null; then
fail "control: a nested directory did not break the older copy, so the test proves nothing"
else
pass "control: a nested directory would have broken the older copy"
fi
# --- install ---
install_image "$TMP/rel" "$TMP/mv"
if [ "$RC" = 0 ] && same "$TMP/built/vmlinuz" "$TMP/mv/sqs-store/vmlinuz" \
&& same "$TMP/built/initramfs.cpio.gz" "$TMP/mv/sqs-store/initramfs.cpio.gz"; then
pass "installs the staged image where the daemon looks"
else
fail "install rc=$RC: $OUT"
fi
mode=$(stat -c '%a' "$TMP/mv/sqs-store/initramfs.cpio.gz" 2> /dev/null || echo none)
if [ "$mode" = 644 ]; then pass "installs the image 0644"; else fail "initramfs mode $mode"; fi
image "$TMP/built2" v2
release "$TMP/rel2"
sh "$STAGE" "$TMP/built2" "$TMP/rel2" > /dev/null
install_image "$TMP/rel2" "$TMP/mv"
if [ "$RC" = 0 ] && same "$TMP/built2/vmlinuz" "$TMP/mv/sqs-store/vmlinuz" \
&& same "$TMP/built2/initramfs.cpio.gz" "$TMP/mv/sqs-store/initramfs.cpio.gz"; then
pass "an upgrade replaces both files"
else
fail "upgrade rc=$RC: $OUT"
fi
# A release without the store image: nothing installed, and a clear warning.
install_image "$TMP/rel-none" "$TMP/mv-none"
if [ "$RC" = 0 ] && [ ! -e "$TMP/mv-none/sqs-store" ] && echo "$OUT" | grep -q 'no SQS store microVM image; SQS store launches will be refused'; then
pass "a release without the image installs nothing and warns"
else
fail "release without image: rc=$RC exists=$([ -e "$TMP/mv-none/sqs-store" ] && echo yes || echo no) $OUT"
fi
# installed <dir>: a store image from an earlier install, plus an unrelated file.
installed() {
image "$1/sqs-store" old
printf 'keep\n' > "$1/sqs-store/operator-note"
}
gone() { [ ! -e "$1/sqs-store/vmlinuz" ] && [ ! -e "$1/sqs-store/initramfs.cpio.gz" ]; }
kept() { [ "$(cat "$1/sqs-store/operator-note" 2> /dev/null)" = keep ]; }
# Upgrading to a release without the image must not leave the old one usable.
installed "$TMP/mv-up"
install_image "$TMP/rel-none" "$TMP/mv-up"
if [ "$RC" = 0 ] && gone "$TMP/mv-up" && kept "$TMP/mv-up" \
&& echo "$OUT" | grep -q 'Removed the SQS store microVM image left by an earlier install' \
&& echo "$OUT" | grep -q 'SQS store launches will be refused'; then
pass "a release without the image removes the earlier one, keeps other files, and warns"
else
fail "release without image over an installed one: rc=$RC $OUT"
fi
# An incomplete store image refuses and removes the earlier pair, because the
# binaries this release installed before it would otherwise boot the old one.
installed "$TMP/mv-bad"
cp -r "$TMP/rel2" "$TMP/rel-bad"
rm "$TMP/rel-bad/microvm-sqs-store/initramfs.cpio.gz"
install_image "$TMP/rel-bad" "$TMP/mv-bad"
if [ "$RC" != 0 ] && echo "$OUT" | grep -q 'incomplete: initramfs.cpio.gz is missing' \
&& gone "$TMP/mv-bad" && kept "$TMP/mv-bad"; then
pass "an incomplete image is refused and the earlier pair is removed"
else
fail "incomplete image: rc=$RC $OUT"
fi
# Restaging from a missing or incomplete build drops an image staged earlier.
for case in missing incomplete; do
image "$TMP/built-$case" new
release "$TMP/rel-$case"
sh "$STAGE" "$TMP/built" "$TMP/rel-$case" > /dev/null
if [ "$case" = missing ]; then rm -r "$TMP/built-$case"; else rm "$TMP/built-$case/initramfs.cpio.gz"; fi
OUT=$(sh "$STAGE" "$TMP/built-$case" "$TMP/rel-$case")
if [ ! -e "$TMP/rel-$case/microvm-sqs-store" ] && echo "$OUT" | grep -q 'tarball will not include it'; then
pass "restaging from a $case build ships no earlier image"
else
fail "restaging from a $case build left: $(ls -R "$TMP/rel-$case/microvm-sqs-store" 2> /dev/null)"
fi
done
mkdir -p "$TMP/rel-other/microvm-sqs-store"
image "$TMP/rel-other/microvm-sqs-store" old
printf 'keep\n' > "$TMP/rel-other/microvm-sqs-store/note"
sh "$STAGE" "$TMP/no-such-build" "$TMP/rel-other" > /dev/null
if [ ! -e "$TMP/rel-other/microvm-sqs-store/vmlinuz" ] && [ "$(cat "$TMP/rel-other/microvm-sqs-store/note")" = keep ]; then
pass "restaging removes only the image files"
else
fail "restaging touched more than the image files"
fi
# An install that stops at the initramfs leaves no pair the daemon would boot.
mkdir -p "$TMP/bin"
cat > "$TMP/bin/install" << 'EOF'
#!/bin/sh
for a in "$@"; do last=$a; done
case "$last" in */initramfs.cpio.gz) echo "install: stopped" >&2; exit 1 ;; esac
exec /usr/bin/install "$@"
EOF
chmod +x "$TMP/bin/install"
install_image "$TMP/rel" "$TMP/mv" "$TMP/bin:"
if [ "$RC" != 0 ] && same "$TMP/built/vmlinuz" "$TMP/mv/sqs-store/vmlinuz" && [ ! -e "$TMP/mv/sqs-store/initramfs.cpio.gz" ]; then
pass "an interrupted install leaves the initramfs missing, not mismatched"
else
fail "interrupted install: rc=$RC initramfs=$([ -e "$TMP/mv/sqs-store/initramfs.cpio.gz" ] && echo present || echo missing)"
fi
[ "$fails" = 0 ] || { echo "FAIL: $fails"; exit 1; }
echo " setup_sqs_store_image_test ok"
+12 -5
View File
@@ -237,7 +237,7 @@ fi
log "stopping services"
run sudo systemctl stop spinifex.target 2>/dev/null || true
if ! $DRY_RUN; then
for unit in spinifex-predastore spinifex-viperblock spinifex-sqs-store spinifex-nats; do
for unit in spinifex-predastore spinifex-viperblock spinifex-nats; do
if systemctl is-active --quiet "$unit"; then
sudo systemctl stop "$unit" || true
fi
@@ -362,9 +362,10 @@ rm_path /etc/systemd/system/openvswitch-switch.service.d/spinifex-perms.conf \
/etc/systemd/system/ovn-controller.service.d/log-level.conf \
/etc/systemd/system/openvswitch-ipsec.service.d/spinifex-perms.conf \
/etc/systemd/system/ovn-northd.service.d/spinifex-perms.conf \
/etc/systemd/system/ovn-northd.service.d/no-manage-ovsdb.conf
/etc/systemd/system/ovn-northd.service.d/no-manage-ovsdb.conf \
/etc/systemd/system/ipsec.service.d/spinifex-guard.conf
# Only if we emptied them — another package may own the same override dir.
for d in openvswitch-switch ovs-vswitchd ovn-controller openvswitch-ipsec ovn-northd; do
for d in openvswitch-switch ovs-vswitchd ovn-controller openvswitch-ipsec ovn-northd ipsec; do
dir="/etc/systemd/system/${d}.service.d"
if sudo test -d "$dir" && [ -z "$(sudo ls -A "$dir" 2>/dev/null)" ]; then
rm_path "$dir"
@@ -431,6 +432,11 @@ if [ -z "$PLUGINDIR" ]; then
fi
[ -n "$PLUGINDIR" ] && rm_path "$PLUGINDIR/nbdkit-viperblock-plugin.so"
# A leftover guard table drops all Geneve from this host's encap address until
# reboot, and the helper is the one place that names it.
if [ -x /usr/local/lib/spinifex/spinifex-set-ipsec-state ]; then
run sudo /usr/local/lib/spinifex/spinifex-set-ipsec-state unguard || true
fi
rm_path /usr/local/bin/spx \
/usr/local/share/spinifex \
/usr/local/lib/spinifex \
@@ -493,7 +499,7 @@ fi
# userdel warns about a missing home. Order here is cosmetic, not correctness.
# ---------------------------------------------------------------------------
log "removing service users and groups"
for svc in nats sqsstore gw daemon storage northstar viperblock vpcd ui; do
for svc in nats gw daemon storage northstar viperblock vpcd ui; do
user="spinifex-${svc}"
if id -u "$user" >/dev/null 2>&1; then
run sudo userdel "$user" 2>/dev/null || log " NOTE: could not remove user $user"
@@ -619,6 +625,7 @@ if ! $DRY_RUN; then
/etc/NetworkManager/conf.d/*spinifex* \
/etc/systemd/system/*.service.d/spinifex-perms.conf \
/etc/systemd/system/ovn-northd.service.d/no-manage-ovsdb.conf \
/etc/systemd/system/ipsec.service.d/spinifex-guard.conf \
/etc/systemd/system/ovn-controller.service.d/log-level.conf; do
exists "$p" && LEFT+=("$p")
done
@@ -628,7 +635,7 @@ if ! $DRY_RUN; then
for u in "${RESTART_UNITS[@]}"; do
systemctl is-failed --quiet "$u" 2>/dev/null && LEFT+=("${u%.service}.service is failed")
done
for svc in nats sqsstore gw daemon storage northstar viperblock vpcd ui; do
for svc in nats gw daemon storage northstar viperblock vpcd ui; do
id -u "spinifex-${svc}" >/dev/null 2>&1 && LEFT+=("user spinifex-${svc}")
done
if command -v nft >/dev/null 2>&1 && sudo nft list table inet spinifex_filter >/dev/null 2>&1; then
@@ -0,0 +1,128 @@
package tokenwebhook
import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
"net"
"net/http"
"net/url"
"os"
"sync"
"time"
"github.com/mulgadc/bluebottle/pkg/tlsconfig"
)
const (
readinessTimeout = 2 * time.Second
readinessTTL = 2 * time.Second
)
// defaultAPIServerAddr is the local k3s apiserver the readiness check dials.
const defaultAPIServerAddr = "127.0.0.1:6443"
// gatewayProbe reports whether this control plane can serve: the gateway it
// relays to accepts a TLS handshake and the local apiserver accepts a TCP
// connection. It sends no credentials and caches the result so frequent load
// balancer probes never reach either more than once per ttl.
type gatewayProbe struct {
addr string
apiAddr string
tlsCfg *tls.Config
timeout time.Duration
ttl time.Duration
now func() time.Time
mu sync.Mutex
checked time.Time
ok bool
}
func newGatewayProbe(gatewayURL, caPath, apiAddr string) (*gatewayProbe, error) {
u, err := url.Parse(gatewayURL)
if err != nil {
return nil, fmt.Errorf("parse gateway URL %q: %w", gatewayURL, err)
}
host, port := u.Hostname(), u.Port()
if host == "" {
return nil, fmt.Errorf("gateway URL %q has no host", gatewayURL)
}
if port == "" {
port = "443"
}
cfg := &tls.Config{MinVersion: tls.VersionTLS13, CurvePreferences: tlsconfig.Curves}
if caPath != "" {
pem, err := os.ReadFile(caPath)
if err != nil {
return nil, fmt.Errorf("read gateway CA %q: %w", caPath, err)
}
pool := x509.NewCertPool()
if !pool.AppendCertsFromPEM(pem) {
return nil, fmt.Errorf("gateway CA %q has no usable certificates", caPath)
}
cfg.RootCAs = pool
}
if apiAddr == "" {
apiAddr = defaultAPIServerAddr
}
return &gatewayProbe{
addr: net.JoinHostPort(host, port),
apiAddr: apiAddr,
tlsCfg: cfg,
timeout: readinessTimeout,
ttl: readinessTTL,
now: time.Now,
}, nil
}
// ready returns the cached result while it is younger than ttl, else probes.
// Concurrent callers wait for one probe and share its result.
func (p *gatewayProbe) ready() bool {
p.mu.Lock()
defer p.mu.Unlock()
if !p.checked.IsZero() && p.now().Sub(p.checked) < p.ttl {
return p.ok
}
p.ok = p.probe()
p.checked = p.now()
return p.ok
}
func (p *gatewayProbe) probe() bool {
ctx, cancel := context.WithTimeout(context.Background(), p.timeout)
defer cancel()
d := tls.Dialer{NetDialer: &net.Dialer{}, Config: p.tlsCfg}
conn, err := d.DialContext(ctx, "tcp", p.addr)
if err != nil {
return false
}
_ = conn.Close()
// A control plane whose apiserver is down must leave rotation too.
api, err := (&net.Dialer{}).DialContext(ctx, "tcp", p.apiAddr)
if err != nil {
return false
}
_ = api.Close()
return true
}
// handle serves 200 when the gateway and apiserver are reachable, else 503.
func (p *gatewayProbe) handle(w http.ResponseWriter, _ *http.Request) {
if p.ready() {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))
return
}
http.Error(w, "not ready", http.StatusServiceUnavailable)
}
// readinessHandler serves only /readyz; the listener it backs is plain HTTP and
// reachable beyond loopback, so it must never expose /authenticate.
func readinessHandler(p *gatewayProbe) http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("/readyz", p.handle)
return mux
}
@@ -0,0 +1,251 @@
package tokenwebhook
import (
"crypto/tls"
"net"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// tlsGateway is a loopback TLS listener standing in for the gateway. It counts
// accepted connections and can be stopped and restarted on the same address.
type tlsGateway struct {
t *testing.T
api *fakeAPIServer
addr string
cert tls.Certificate
caPath string
ln net.Listener
accepts atomic.Int32
}
func newTLSGateway(t *testing.T) *tlsGateway {
t.Helper()
dir := t.TempDir()
cert, certPEM, err := ensureServingCert(filepath.Join(dir, "c.pem"), filepath.Join(dir, "k.pem"))
require.NoError(t, err)
caPath := filepath.Join(dir, "ca.pem")
require.NoError(t, os.WriteFile(caPath, certPEM, 0o600))
g := &tlsGateway{t: t, cert: cert, caPath: caPath, api: newFakeAPIServer(t)}
g.start("127.0.0.1:0")
t.Cleanup(g.stop)
return g
}
func (g *tlsGateway) start(addr string) {
g.t.Helper()
ln, err := tls.Listen("tcp", addr, serverTLSConfig(g.cert))
require.NoError(g.t, err)
g.ln = ln
g.addr = ln.Addr().String()
go func() {
for {
c, err := ln.Accept()
if err != nil {
return
}
g.accepts.Add(1)
go func() {
if tc, ok := c.(*tls.Conn); ok {
_ = tc.Handshake()
}
_ = c.Close()
}()
}
}()
}
func (g *tlsGateway) stop() {
if g.ln != nil {
_ = g.ln.Close()
g.ln = nil
}
}
// fakeAPIServer is a plain TCP listener standing in for the local apiserver.
type fakeAPIServer struct {
addr string
ln net.Listener
}
func newFakeAPIServer(t *testing.T) *fakeAPIServer {
t.Helper()
a := &fakeAPIServer{}
a.start("127.0.0.1:0", t)
t.Cleanup(a.stop)
return a
}
func (a *fakeAPIServer) start(addr string, t *testing.T) {
t.Helper()
ln, err := net.Listen("tcp", addr)
require.NoError(t, err)
a.ln = ln
a.addr = ln.Addr().String()
go func() {
for {
c, err := ln.Accept()
if err != nil {
return
}
_ = c.Close()
}
}()
}
func (a *fakeAPIServer) stop() {
if a.ln != nil {
_ = a.ln.Close()
a.ln = nil
}
}
func (g *tlsGateway) probe(t *testing.T) *gatewayProbe {
t.Helper()
p, err := newGatewayProbe("https://"+g.addr, g.caPath, g.api.addr)
require.NoError(t, err)
return p
}
func TestGatewayProbe_UpAndRefused(t *testing.T) {
g := newTLSGateway(t)
p := g.probe(t)
p.ttl = 0
assert.True(t, p.ready())
g.stop()
assert.False(t, p.ready(), "a closed gateway port is not ready")
}
func TestGatewayProbe_RecoversAfterDown(t *testing.T) {
g := newTLSGateway(t)
p := g.probe(t)
p.ttl = 0
addr := g.addr
g.stop()
require.False(t, p.ready())
g.start(addr)
assert.True(t, p.ready(), "ready again once the gateway is back")
}
func TestGatewayProbe_TimesOutOnStalledHandshake(t *testing.T) {
g := newTLSGateway(t)
// A plain listener that accepts and never answers the TLS handshake.
ln, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
t.Cleanup(func() { _ = ln.Close() })
go func() {
for {
c, err := ln.Accept()
if err != nil {
return
}
t.Cleanup(func() { _ = c.Close() })
}
}()
p, err := newGatewayProbe("https://"+ln.Addr().String(), g.caPath, g.api.addr)
require.NoError(t, err)
p.timeout = 200 * time.Millisecond
p.ttl = 0
start := time.Now()
assert.False(t, p.ready())
assert.Less(t, time.Since(start), 2*time.Second, "the probe gives up at its timeout")
}
func TestGatewayProbe_RejectsUntrustedCertificate(t *testing.T) {
g := newTLSGateway(t)
other := newTLSGateway(t)
p, err := newGatewayProbe("https://"+g.addr, other.caPath, g.api.addr)
require.NoError(t, err)
p.ttl = 0
assert.False(t, p.ready(), "a certificate not signed by the configured CA is not ready")
}
func TestGatewayProbe_CachesWithinTTL(t *testing.T) {
g := newTLSGateway(t)
p := g.probe(t)
clock := time.Unix(1_000_000, 0)
p.now = func() time.Time { return clock }
p.ttl = 2 * time.Second
require.True(t, p.ready())
require.True(t, p.ready())
require.True(t, p.ready())
assert.Equal(t, int32(1), g.accepts.Load(), "calls inside the ttl share one probe")
g.stop()
assert.True(t, p.ready(), "a cached answer is served while the ttl holds")
clock = clock.Add(3 * time.Second)
assert.False(t, p.ready(), "after the ttl the gateway is probed again")
}
func TestGatewayProbe_HandlerStatus(t *testing.T) {
g := newTLSGateway(t)
p := g.probe(t)
p.ttl = 0
w := httptest.NewRecorder()
p.handle(w, httptest.NewRequest(http.MethodGet, "/readyz", nil))
assert.Equal(t, http.StatusOK, w.Code)
g.stop()
w = httptest.NewRecorder()
p.handle(w, httptest.NewRequest(http.MethodGet, "/readyz", nil))
assert.Equal(t, http.StatusServiceUnavailable, w.Code)
}
func TestNewGatewayProbe_DefaultsPortAndRejectsBadInput(t *testing.T) {
p, err := newGatewayProbe("https://gw.example", "", "")
require.NoError(t, err)
assert.Equal(t, "gw.example:443", p.addr)
assert.Equal(t, defaultAPIServerAddr, p.apiAddr)
_, err = newGatewayProbe("https://", "", "")
require.Error(t, err)
_, err = newGatewayProbe("https://gw.example:9999", "/no/such/ca.pem", "")
require.Error(t, err)
}
func TestGatewayProbe_NotReadyWhenAPIServerDown(t *testing.T) {
g := newTLSGateway(t)
p := g.probe(t)
p.ttl = 0
require.True(t, p.ready())
g.api.stop()
assert.False(t, p.ready(), "a dead apiserver must not look ready while the gateway is up")
w := httptest.NewRecorder()
p.handle(w, httptest.NewRequest(http.MethodGet, "/readyz", nil))
assert.Equal(t, http.StatusServiceUnavailable, w.Code)
}
func TestReadinessHandler_ServesOnlyReadyz(t *testing.T) {
g := newTLSGateway(t)
h := readinessHandler(g.probe(t))
for _, path := range []string{"/authenticate", "/healthz", "/"} {
w := httptest.NewRecorder()
h.ServeHTTP(w, httptest.NewRequest(http.MethodPost, path, nil))
assert.Equalf(t, http.StatusNotFound, w.Code, "%s must not be served on the readiness listener", path)
}
w := httptest.NewRecorder()
h.ServeHTTP(w, httptest.NewRequest(http.MethodGet, "/readyz", nil))
assert.Equal(t, http.StatusOK, w.Code)
}
@@ -128,3 +128,58 @@ func TestRunServesUntilCancelled(t *testing.T) {
t.Fatal("Run did not return after cancel")
}
}
func TestRunServesReadinessOnSeparateListener(t *testing.T) {
g := newTLSGateway(t)
cfg := runConfig(t, freeAddr(t))
cfg.GatewayURL = "https://" + g.addr
cfg.GatewayCA = g.caPath
cfg.APIServerAddr = g.api.addr
cfg.ReadyAddr = freeAddr(t)
ctx, cancel := context.WithCancel(context.Background())
done := make(chan error, 1)
go func() { done <- Run(ctx, cfg) }()
client := &http.Client{Timeout: 3 * time.Second}
require.Eventually(t, func() bool {
resp, err := client.Get("http://" + cfg.ReadyAddr + "/readyz")
if err != nil {
return false
}
_ = resp.Body.Close()
return resp.StatusCode == http.StatusOK
}, 10*time.Second, 50*time.Millisecond, "readiness listener never reported ready")
resp, err := client.Post("http://"+cfg.ReadyAddr+"/authenticate", "application/json", strings.NewReader("{}"))
require.NoError(t, err)
_ = resp.Body.Close()
assert.Equal(t, http.StatusNotFound, resp.StatusCode, "the readiness listener must not serve /authenticate")
cancel()
select {
case err := <-done:
require.NoError(t, err)
case <-time.After(5 * time.Second):
t.Fatal("Run did not return after cancel")
}
}
func TestRunReportsReadinessListenFailure(t *testing.T) {
l, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
defer l.Close()
cfg := runConfig(t, freeAddr(t))
cfg.ReadyAddr = l.Addr().String()
done := make(chan error, 1)
go func() { done <- Run(context.Background(), cfg) }()
select {
case err := <-done:
require.Error(t, err)
assert.True(t, strings.HasPrefix(err.Error(), "serve readiness: "), err.Error())
case <-time.After(10 * time.Second):
t.Fatal("Run kept serving after the readiness listener failed")
}
}
+42 -6
View File
@@ -43,6 +43,10 @@ type Config struct {
CertPath string
KeyPath string
Kubeconfig string
// ReadyAddr, when set, is a plain-HTTP listener serving only /readyz for
// load balancer health checks. APIServerAddr defaults to the local k3s.
ReadyAddr string
APIServerAddr string
}
// Run writes the serving certificate and apiserver kubeconfig, then serves
@@ -63,6 +67,11 @@ func Run(ctx context.Context, cfg Config) error {
return fmt.Errorf("build gateway client: %w", err)
}
probe, err := newGatewayProbe(cfg.GatewayURL, cfg.GatewayCA, cfg.APIServerAddr)
if err != nil {
return fmt.Errorf("build readiness probe: %w", err)
}
authr := &authenticator{
accountID: cfg.AccountID,
clusterName: cfg.ClusterName,
@@ -74,6 +83,7 @@ func Run(ctx context.Context, cfg Config) error {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))
})
mux.HandleFunc("/readyz", probe.handle)
mux.HandleFunc("/authenticate", authr.handle)
server := &http.Server{
@@ -82,12 +92,38 @@ func Run(ctx context.Context, cfg Config) error {
ReadHeaderTimeout: 5 * time.Second,
TLSConfig: serverTLSConfig(tlsCert),
}
stop := context.AfterFunc(ctx, func() { _ = server.Close() })
readyErr := make(chan error, 1)
var readySrv *http.Server
if cfg.ReadyAddr != "" {
readySrv = &http.Server{
Addr: cfg.ReadyAddr,
Handler: readinessHandler(probe),
ReadHeaderTimeout: 5 * time.Second,
}
go func() {
if err := readySrv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
readyErr <- fmt.Errorf("serve readiness: %w", err)
_ = server.Close()
}
}()
defer func() { _ = readySrv.Close() }()
}
stop := context.AfterFunc(ctx, func() {
_ = server.Close()
if readySrv != nil {
_ = readySrv.Close()
}
})
defer stop()
slog.Info("eks-token-webhook listening", "addr", cfg.Addr, "cluster", cfg.ClusterName)
slog.Info("eks-token-webhook listening", "addr", cfg.Addr, "ready_addr", cfg.ReadyAddr, "cluster", cfg.ClusterName)
if err := server.ListenAndServeTLS("", ""); err != nil && !errors.Is(err, http.ErrServerClosed) {
return fmt.Errorf("serve: %w", err)
}
select {
case err := <-readyErr:
return err
default:
}
return nil
}
@@ -101,8 +137,8 @@ type tokenReviewRequest struct {
// gatewayReviewer returns the per-call relay: SigV4-POST {accountId,token} to
// the gateway and decode the resolved identity. A non-2xx / transport error is
// surfaced (handle() turns it into a 5xx so the apiserver retries) rather than a
// silent deny, distinguishing "webhook broker down" from "token rejected".
// surfaced (handle() turns it into a 5xx) rather than a silent deny, which
// distinguishes "webhook broker down" from "token rejected" in the logs.
func gatewayReviewer(client *eksgw.Client, clusterName, accountID string) func(string) (ekscluster.WebhookTokenReviewResult, error) {
path := "/clusters/" + clusterName + "/token-review"
return func(token string) (ekscluster.WebhookTokenReviewResult, error) {
@@ -142,8 +178,8 @@ func (a *authenticator) handle(w http.ResponseWriter, r *http.Request) {
res, err := a.review(review.Spec.Token)
if err != nil {
// Broker fault (gateway down, transport error): a 5xx tells the apiserver
// to retry rather than treating a transient outage as a hard deny.
// Broker fault (gateway down, transport error). The apiserver treats any
// webhook error as an authentication failure and does not retry it.
slog.Error("TokenReview relay failed", "cluster", a.clusterName, "err", err)
http.Error(w, "token review unavailable", http.StatusServiceUnavailable)
return
+6 -1
View File
@@ -22,6 +22,11 @@ type HealthReport struct {
Servers []ServerStatus `json:"servers"`
}
// FailoverServerSuffix marks the unchecked backup copy of a server that HAProxy
// uses only when every checked server is down. '.' cannot appear in a sanitized
// target name, so a copy never collides with a real server.
const FailoverServerSuffix = ".fo"
// queryHAProxyStats reads backend server health from the HAProxy stats socket.
// Parses CSV "show stat" output; cols 0/1/17 = pxname/svname/status.
func queryHAProxyStats(socketPath string) ([]ServerStatus, error) {
@@ -53,7 +58,7 @@ func queryHAProxyStats(socketPath string) ([]ServerStatus, error) {
}
svname := fields[1]
if svname == "FRONTEND" || svname == "BACKEND" {
if svname == "FRONTEND" || svname == "BACKEND" || strings.HasSuffix(svname, FailoverServerSuffix) {
continue
}
+35
View File
@@ -58,3 +58,38 @@ func TestQueryHAProxyStats_SocketNotFound(t *testing.T) {
t.Error("expected error for non-existent socket")
}
}
func TestQueryHAProxyStats_IgnoresFailoverCopies(t *testing.T) {
dir := t.TempDir()
sock := filepath.Join(dir, "haproxy.sock")
ln, err := net.Listen("unix", sock)
if err != nil {
t.Fatalf("listen: %v", err)
}
defer ln.Close()
go func() {
conn, err := ln.Accept()
if err != nil {
return
}
defer conn.Close()
buf := make([]byte, 256)
conn.Read(buf)
csv := "# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight\n"
csv += "bk_tg1,srv_i-aaa111,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,DOWN,1\n"
csv += "bk_tg1,srv_i-aaa111" + FailoverServerSuffix + ",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,UP,1\n"
fmt.Fprint(conn, csv)
}()
servers, err := queryHAProxyStats(sock)
if err != nil {
t.Fatalf("queryHAProxyStats: %v", err)
}
if len(servers) != 1 || servers[0].Server != "srv_i-aaa111" || servers[0].Status != "DOWN" {
t.Fatalf("got %+v, want only srv_i-aaa111/DOWN", servers)
}
}
+21
View File
@@ -3,6 +3,7 @@ package quota
import (
"context"
"errors"
"log/slog"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/elbv2"
@@ -113,3 +114,23 @@ func (s *Service) EnforceRDSInstances(ctx context.Context, natsConn *nats.Conn,
}
return exceeds(len(out.DBInstances), want, limits.RDSInstances)
}
// LoadBalancerLimit is the load balancer cap DescribeAccountLimits reports.
func (s *Service) LoadBalancerLimit(ctx context.Context, accountID string) (int, error) {
// An exempt account has no cap enforced against it, so the AWS default is a
// truer answer than a configured limit nothing consults.
if s.Exempt(accountID) {
return elbv2awsapi.DefaultLoadBalancerLimit, nil
}
_, limits, err := s.GetAccountQuota(ctx, accountID)
if err != nil {
if awserrors.IsErrorCode(err, awserrors.ErrorBlocked) {
return 0, err
}
slog.ErrorContext(ctx, "DescribeAccountLimits: failed to read account quota", "accountID", accountID, "err", err)
return 0, errors.New(awserrors.ErrorInternalError)
}
return limits.LoadBalancers, nil
}
var _ elbv2awsapi.Quota = (*Service)(nil)
@@ -6,6 +6,7 @@ import (
"math"
"testing"
elbv2awsapi "github.com/mulgadc/spinifex/spinifex/domains/elbv2/awsapi"
"github.com/mulgadc/spinifex/spinifex/foundation/aws/errors"
)
@@ -82,3 +83,25 @@ func TestEnforceLiveExemptShortCircuits(t *testing.T) {
})
}
}
func TestLoadBalancerLimit_ExemptAccountReportsAWSDefault(t *testing.T) {
var disabled *Service
got, err := disabled.LoadBalancerLimit(t.Context(), "123456789012")
if err != nil {
t.Fatalf("LoadBalancerLimit: %v", err)
}
if got != elbv2awsapi.DefaultLoadBalancerLimit {
t.Errorf("limit = %d, want the AWS default %d", got, elbv2awsapi.DefaultLoadBalancerLimit)
}
}
func TestLoadBalancerLimit_EnabledAccountReportsConfiguredLimit(t *testing.T) {
svc := New(Limits{Enabled: true, LoadBalancers: 7}, nil)
got, err := svc.LoadBalancerLimit(t.Context(), "123456789012")
if err != nil {
t.Fatalf("LoadBalancerLimit: %v", err)
}
if got != 7 {
t.Errorf("limit = %d, want 7", got)
}
}
@@ -5,6 +5,7 @@ import (
"testing"
"github.com/mulgadc/spinifex/internal/testkit"
"github.com/mulgadc/spinifex/spinifex/foundation/aws/errors"
"github.com/nats-io/nats.go/jetstream"
"github.com/stretchr/testify/require"
)
@@ -134,3 +135,36 @@ func TestPutAccountQuotaWithoutBucket(t *testing.T) {
svc := New(baseLimits(), nil)
require.Error(t, svc.PutAccountQuota(t.Context(), "000000000002", Overrides{VCPUs: ptr(32)}, "operator"))
}
// The cap DescribeAccountLimits reports follows the account's stored override
// and falls back to the configured baseline for an account without one.
func TestLoadBalancerLimit_FollowsPerAccountOverride(t *testing.T) {
svc, _ := newOverrideService(t)
const upgraded, plain = "000000000002", "000000000003"
require.NoError(t, svc.PutAccountQuota(t.Context(), upgraded, Overrides{LoadBalancers: ptr(31)}, "operator"))
got, err := svc.LoadBalancerLimit(t.Context(), upgraded)
require.NoError(t, err)
require.Equal(t, 31, got)
got, err = svc.LoadBalancerLimit(t.Context(), plain)
require.NoError(t, err)
require.Equal(t, baseLimits().LoadBalancers, got)
}
// A sealed account is refused with Blocked, and an unreadable record is an
// InternalError, never a made-up number.
func TestLoadBalancerLimit_RefusesSealedAndUnreadableRecords(t *testing.T) {
svc, kv := newOverrideService(t)
const sealed, corrupt = "000000000004", "000000000005"
_, err := kv.Put(t.Context(), sealed, []byte(`{"state":"sealed"}`))
require.NoError(t, err)
_, err = kv.Put(t.Context(), corrupt, []byte(`not json`))
require.NoError(t, err)
_, err = svc.LoadBalancerLimit(t.Context(), sealed)
require.EqualError(t, err, awserrors.ErrorBlocked)
_, err = svc.LoadBalancerLimit(t.Context(), corrupt)
require.EqualError(t, err, awserrors.ErrorInternalError)
}
@@ -2,9 +2,9 @@ package image
import (
"context"
"errors"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image"
"github.com/mulgadc/spinifex/spinifex/foundation/aws/errors"
@@ -27,74 +27,86 @@ var validRegisterImageBootModes = map[string]bool{
}
// ValidateRegisterImageInput rejects inputs that ask for behaviour spinifex
// doesn't have (PV, S3 bundles, kernel/ramdisk, IMDS/TPM/ENA hints) rather
// than silently discarding them. Registration is pointer-only: caller supplies
// a snapshot and we write a config.json that references it.
// doesn't have (PV, S3 bundles, kernel/ramdisk, IMDS/TPM hints) rather than
// silently discarding them. Registration is pointer-only: caller supplies a
// snapshot and we write a config.json that references it.
func ValidateRegisterImageInput(input *ec2.RegisterImageInput) error {
if input == nil {
return errors.New(awserrors.ErrorMissingParameter)
return awserrors.Errorf(awserrors.ErrorMissingParameter, "The request must contain the parameter Name")
}
if input.Name == nil || *input.Name == "" {
return errors.New(awserrors.ErrorMissingParameter)
return missingParam("Name")
}
if n := len(*input.Name); n < 3 || n > 128 {
return errors.New(awserrors.ErrorInvalidAMINameMalformed)
return invalidParam(awserrors.ErrorInvalidAMINameMalformed, "Name", *input.Name, "AMI names must be between 3 and 128 characters long.")
}
if input.ImageLocation != nil && *input.ImageLocation != "" {
return errors.New(awserrors.ErrorInvalidParameterValue)
if aws.StringValue(input.ImageLocation) != "" {
return unsupportedParam("ImageLocation", *input.ImageLocation)
}
if input.Architecture != nil && *input.Architecture != "" {
if !validRegisterImageArchitectures[*input.Architecture] {
return errors.New(awserrors.ErrorInvalidParameterValue)
}
if arch := aws.StringValue(input.Architecture); arch != "" && !validRegisterImageArchitectures[arch] {
return invalidParam(awserrors.ErrorInvalidParameterValue, "Architecture", arch, "Supported values are x86_64, arm64 and i386.")
}
if input.VirtualizationType != nil && *input.VirtualizationType != "" && *input.VirtualizationType != "hvm" {
return errors.New(awserrors.ErrorInvalidParameterValue)
if virt := aws.StringValue(input.VirtualizationType); virt != "" && virt != "hvm" {
return invalidParam(awserrors.ErrorInvalidParameterValue, "VirtualizationType", virt, "Only hvm is supported.")
}
if input.BootMode != nil && *input.BootMode != "" {
if !validRegisterImageBootModes[*input.BootMode] {
return errors.New(awserrors.ErrorInvalidParameterValue)
}
if mode := aws.StringValue(input.BootMode); mode != "" && !validRegisterImageBootModes[mode] {
return invalidParam(awserrors.ErrorInvalidParameterValue, "BootMode", mode, "Supported values are bios, uefi and uefi-preferred.")
}
if input.KernelId != nil && *input.KernelId != "" {
return errors.New(awserrors.ErrorInvalidParameterValue)
if aws.StringValue(input.KernelId) != "" {
return unsupportedParam("KernelId", *input.KernelId)
}
if input.RamdiskId != nil && *input.RamdiskId != "" {
return errors.New(awserrors.ErrorInvalidParameterValue)
if aws.StringValue(input.RamdiskId) != "" {
return unsupportedParam("RamdiskId", *input.RamdiskId)
}
if input.TpmSupport != nil && *input.TpmSupport != "" {
return errors.New(awserrors.ErrorInvalidParameterValue)
if aws.StringValue(input.TpmSupport) != "" {
return unsupportedParam("TpmSupport", *input.TpmSupport)
}
if input.ImdsSupport != nil && *input.ImdsSupport != "" {
return errors.New(awserrors.ErrorInvalidParameterValue)
if aws.StringValue(input.ImdsSupport) != "" {
return unsupportedParam("ImdsSupport", *input.ImdsSupport)
}
if input.EnaSupport != nil {
return errors.New(awserrors.ErrorInvalidParameterValue)
}
if input.SriovNetSupport != nil && *input.SriovNetSupport != "" {
return errors.New(awserrors.ErrorInvalidParameterValue)
if aws.StringValue(input.SriovNetSupport) != "" {
return unsupportedParam("SriovNetSupport", *input.SriovNetSupport)
}
if len(input.BlockDeviceMappings) == 0 {
return errors.New(awserrors.ErrorMissingParameter)
return missingParam("BlockDeviceMapping")
}
root := selectRootBlockDeviceMapping(input.BlockDeviceMappings, input.RootDeviceName)
if root == nil || root.Ebs == nil || root.Ebs.SnapshotId == nil || *root.Ebs.SnapshotId == "" {
return errors.New(awserrors.ErrorMissingParameter)
if name := aws.StringValue(input.RootDeviceName); name != "" && root == nil {
return awserrors.Errorf(awserrors.ErrorMissingParameter,
"Value (%s) for parameter RootDeviceName is invalid. No block device mapping has that DeviceName.", name)
}
return missingParam("SnapshotId in the root block device mapping")
}
if !strings.HasPrefix(*root.Ebs.SnapshotId, "snap-") {
return errors.New(awserrors.ErrorInvalidSnapshotIDMalformed)
return invalidParam(awserrors.ErrorInvalidSnapshotIDMalformed, "SnapshotId", *root.Ebs.SnapshotId, "Expected: 'snap-...'.")
}
return nil
}
// missingParam is EC2's wording for an absent required parameter.
func missingParam(name string) error {
return awserrors.Errorf(awserrors.ErrorMissingParameter, "The request must contain the parameter %s", name)
}
// invalidParam is EC2's wording for a parameter value it refuses.
func invalidParam(code, name, value, reason string) error {
return awserrors.Errorf(code, "Value (%s) for parameter %s is invalid. %s", value, name, reason)
}
// unsupportedParam refuses a parameter spinifex has no behaviour for.
func unsupportedParam(name, value string) error {
return invalidParam(awserrors.ErrorInvalidParameterValue, name, value, name+" is not supported.")
}
// selectRootBlockDeviceMapping returns the BDM matching RootDeviceName if set,
// else the first BDM carrying an EBS snapshot reference.
func selectRootBlockDeviceMapping(mappings []*ec2.BlockDeviceMapping, rootDeviceName *string) *ec2.BlockDeviceMapping {
@@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/mulgadc/spinifex/spinifex/foundation/aws/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func validRegisterImageInput() *ec2.RegisterImageInput {
@@ -33,30 +34,37 @@ func TestValidateRegisterImageInput(t *testing.T) {
input *ec2.RegisterImageInput
wantErr bool
errMsg string
// wantIn is the text the message must carry, so the caller can see which
// parameter was refused.
wantIn string
}{
{
name: "NilInput",
input: nil,
wantErr: true,
errMsg: awserrors.ErrorMissingParameter,
wantIn: "parameter Name",
},
{
name: "MissingName",
mutate: func(i *ec2.RegisterImageInput) { i.Name = nil },
wantErr: true,
errMsg: awserrors.ErrorMissingParameter,
wantIn: "parameter Name",
},
{
name: "EmptyName",
mutate: func(i *ec2.RegisterImageInput) { i.Name = aws.String("") },
wantErr: true,
errMsg: awserrors.ErrorMissingParameter,
wantIn: "parameter Name",
},
{
name: "ShortName",
mutate: func(i *ec2.RegisterImageInput) { i.Name = aws.String("ab") },
wantErr: true,
errMsg: awserrors.ErrorInvalidAMINameMalformed,
wantIn: "for parameter Name is invalid",
},
{
name: "LongName",
@@ -69,12 +77,14 @@ func TestValidateRegisterImageInput(t *testing.T) {
},
wantErr: true,
errMsg: awserrors.ErrorInvalidAMINameMalformed,
wantIn: "for parameter Name is invalid",
},
{
name: "MissingBlockDeviceMappings",
mutate: func(i *ec2.RegisterImageInput) { i.BlockDeviceMappings = nil },
wantErr: true,
errMsg: awserrors.ErrorMissingParameter,
wantIn: "parameter BlockDeviceMapping",
},
{
name: "MissingSnapshotIdInRootBDM",
@@ -83,6 +93,7 @@ func TestValidateRegisterImageInput(t *testing.T) {
},
wantErr: true,
errMsg: awserrors.ErrorMissingParameter,
wantIn: "parameter SnapshotId",
},
{
name: "MalformedSnapshotId",
@@ -91,6 +102,7 @@ func TestValidateRegisterImageInput(t *testing.T) {
},
wantErr: true,
errMsg: awserrors.ErrorInvalidSnapshotIDMalformed,
wantIn: "Value (not-a-snapshot) for parameter SnapshotId is invalid",
},
{
name: "RootDeviceNameWithNoMatchingBDM",
@@ -99,6 +111,7 @@ func TestValidateRegisterImageInput(t *testing.T) {
},
wantErr: true,
errMsg: awserrors.ErrorMissingParameter,
wantIn: "Value (/dev/xvda) for parameter RootDeviceName is invalid",
},
{
name: "InvalidArchitecture",
@@ -107,6 +120,7 @@ func TestValidateRegisterImageInput(t *testing.T) {
},
wantErr: true,
errMsg: awserrors.ErrorInvalidParameterValue,
wantIn: "Value (riscv) for parameter Architecture is invalid",
},
{
name: "ParavirtualVirtualizationRejected",
@@ -115,6 +129,7 @@ func TestValidateRegisterImageInput(t *testing.T) {
},
wantErr: true,
errMsg: awserrors.ErrorInvalidParameterValue,
wantIn: "Value (paravirtual) for parameter VirtualizationType is invalid",
},
{
name: "ImageLocationRejected",
@@ -123,6 +138,7 @@ func TestValidateRegisterImageInput(t *testing.T) {
},
wantErr: true,
errMsg: awserrors.ErrorInvalidParameterValue,
wantIn: "for parameter ImageLocation is invalid. ImageLocation is not supported",
},
{
name: "BootModeAcceptedBios",
@@ -144,42 +160,52 @@ func TestValidateRegisterImageInput(t *testing.T) {
mutate: func(i *ec2.RegisterImageInput) { i.BootMode = aws.String("legacy-bios") },
wantErr: true,
errMsg: awserrors.ErrorInvalidParameterValue,
wantIn: "Value (legacy-bios) for parameter BootMode is invalid",
},
{
name: "KernelIdRejected",
mutate: func(i *ec2.RegisterImageInput) { i.KernelId = aws.String("aki-123") },
wantErr: true,
errMsg: awserrors.ErrorInvalidParameterValue,
wantIn: "Value (aki-123) for parameter KernelId is invalid. KernelId is not supported",
},
{
name: "RamdiskIdRejected",
mutate: func(i *ec2.RegisterImageInput) { i.RamdiskId = aws.String("ari-123") },
wantErr: true,
errMsg: awserrors.ErrorInvalidParameterValue,
wantIn: "Value (ari-123) for parameter RamdiskId is invalid. RamdiskId is not supported",
},
{
name: "TpmSupportRejected",
mutate: func(i *ec2.RegisterImageInput) { i.TpmSupport = aws.String("v2.0") },
wantErr: true,
errMsg: awserrors.ErrorInvalidParameterValue,
wantIn: "Value (v2.0) for parameter TpmSupport is invalid. TpmSupport is not supported",
},
{
name: "ImdsSupportRejected",
mutate: func(i *ec2.RegisterImageInput) { i.ImdsSupport = aws.String("v2.0") },
wantErr: true,
errMsg: awserrors.ErrorInvalidParameterValue,
wantIn: "Value (v2.0) for parameter ImdsSupport is invalid. ImdsSupport is not supported",
},
{
name: "EnaSupportRejected",
name: "EnaSupportAcceptedTrue",
mutate: func(i *ec2.RegisterImageInput) { i.EnaSupport = aws.Bool(true) },
wantErr: true,
errMsg: awserrors.ErrorInvalidParameterValue,
wantErr: false,
},
{
name: "EnaSupportAcceptedFalse",
mutate: func(i *ec2.RegisterImageInput) { i.EnaSupport = aws.Bool(false) },
wantErr: false,
},
{
name: "SriovNetSupportRejected",
mutate: func(i *ec2.RegisterImageInput) { i.SriovNetSupport = aws.String("simple") },
wantErr: true,
errMsg: awserrors.ErrorInvalidParameterValue,
wantIn: "Value (simple) for parameter SriovNetSupport is invalid. SriovNetSupport is not supported",
},
{
name: "ValidWithExplicitArch",
@@ -230,8 +256,12 @@ func TestValidateRegisterImageInput(t *testing.T) {
err := ValidateRegisterImageInput(input)
if tt.wantErr {
assert.Error(t, err)
assert.Equal(t, tt.errMsg, err.Error())
require.Error(t, err)
code, msg, ok := awserrors.ResolveErrorDetail(err)
require.True(t, ok, "the error must carry a registered code")
assert.Equal(t, tt.errMsg, code)
assert.NotEmpty(t, msg, "the response must say what was refused")
assert.Contains(t, msg, tt.wantIn)
} else {
assert.NoError(t, err)
}
@@ -243,8 +273,10 @@ func TestRegisterImage_GatewayValidationFailureReturnsEarly(t *testing.T) {
// nil natsConn is fine here: validation rejects the input before any
// NATS round-trip is attempted, so we exercise the early-exit path.
_, err := RegisterImage(context.Background(), &ec2.RegisterImageInput{}, nil, "000000000001")
assert.Error(t, err)
assert.Equal(t, awserrors.ErrorMissingParameter, err.Error())
require.Error(t, err)
code, ok := awserrors.ResolveErrorCode(err)
require.True(t, ok)
assert.Equal(t, awserrors.ErrorMissingParameter, code)
}
func TestSelectRootBlockDeviceMapping_NoRootDeviceName(t *testing.T) {
@@ -747,3 +747,27 @@ func TestResolveAndAuthorizeProfile_CanonicalLookupError(t *testing.T) {
})
}
}
// Current behaviour, not a statement of what AWS does: a profile whose role no
// longer exists surfaces the store's NoSuchEntity unchanged and PassRole is
// never evaluated.
func TestResolveAndAuthorizeProfile_DanglingRoleSurfacesNoSuchEntityBeforePassRole(t *testing.T) {
t.Parallel()
svc := &fakeIAMService{
resolveFn: func(string, string) (*iamdomain.InstanceProfile, error) { return profileWithRole(), nil },
canonicalFn: func(string, arn.IAMResourceType, string) (string, error) {
return "", errors.New(awserrors.ErrorIAMNoSuchEntity)
},
}
checkCalled := false
check := func(string) error {
checkCalled = true
return nil
}
_, err := resolveAndAuthorizeProfile(
&ec2.IamInstanceProfileSpecification{Name: aws.String(testProfileNameApp)},
svc, testGwAccountID, check)
require.Error(t, err)
assert.Equal(t, awserrors.ErrorIAMNoSuchEntity, err.Error())
assert.False(t, checkCalled, "a dangling role is reported without evaluating iam:PassRole")
}
@@ -104,6 +104,7 @@ type AMI struct {
VolumeSizeGiB uint64 `json:"volume_size_gib"`
SnapshotID string `json:"snapshot_id,omitempty"`
BootMode string `json:"boot_mode,omitempty"`
EnaSupport *bool `json:"ena_support,omitempty"`
Distro string `json:"distro,omitempty"`
DistroFamily string `json:"distro_family,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
+1 -1
View File
@@ -181,7 +181,7 @@ func (s *EIPServiceImpl) ReleaseAddress(ctx context.Context, input *ec2.ReleaseA
// Cannot release an EIP that is still associated.
if record.State == "associated" {
return nil, errors.New(awserrors.ErrorInvalidAddressLocked)
return nil, awserrors.Errorf(awserrors.ErrorInvalidIPAddressInUse, "Address %s is in use.", record.PublicIp)
}
// Release IP back to IPAM pool. User-driven release of an already-detached
@@ -169,8 +169,11 @@ func TestEIP_ReleaseWhileAssociated(t *testing.T) {
_, err = svc.ReleaseAddress(context.Background(), &ec2.ReleaseAddressInput{
AllocationId: aws.String(allocID),
}, testAccountID)
assert.Error(t, err)
assert.Contains(t, err.Error(), "InvalidAddress.Locked")
require.Error(t, err)
code, message, ok := awserrors.ResolveErrorDetail(err)
require.True(t, ok, "error must carry a registered code: %v", err)
assert.Equal(t, awserrors.ErrorInvalidIPAddressInUse, code)
assert.Equal(t, "Address "+record.PublicIp+" is in use.", message)
}
func TestEIP_ReleaseByInstanceID_ReclaimsAssociatedEIP(t *testing.T) {
@@ -193,3 +193,32 @@ func TestCreateImageFromInstance_DoesNotInheritSourceDigest(t *testing.T) {
assert.Equal(t, "uefi", ami.BootMode, "the source AMI must have been read")
assert.Nil(t, ami.SourceDigest)
}
// AWS takes an image's EnaSupport from the instance it was made from, and every
// instance here reports it, so the source AMI's value is not inherited.
func TestCreateImageFromInstance_SetsEnaSupportFromInstance(t *testing.T) {
svc, _, provider := setupProviderSnapshotImageService(t)
doc := seedProviderVolume(t, svc, provider, "vol-ena001", 8)
require.NoError(t, svc.MetadataStore().PutAMI(context.Background(), ebsmetadata.AMI{
ImageID: "ami-src-ena",
Name: "no-ena",
ImageOwnerAlias: testAccountID,
EnaSupport: aws.Bool(false),
}))
out, err := svc.CreateImageFromInstance(CreateImageParams{
Input: &ec2.CreateImageInput{
InstanceId: aws.String("i-ena001"),
Name: aws.String("from-no-ena"),
},
RootVolumeID: doc.VolumeID,
SourceImageID: "ami-src-ena",
IsRunning: false,
}, testAccountID)
require.NoError(t, err)
ami, err := svc.MetadataStore().GetAMI(context.Background(), aws.StringValue(out.ImageId))
require.NoError(t, err)
require.NotNil(t, ami.EnaSupport)
assert.True(t, *ami.EnaSupport)
}
+20 -2
View File
@@ -324,6 +324,11 @@ func renderVisibleImage(amiMeta ebsmetadata.AMI, input *ec2.DescribeImagesInput,
image.BootMode = aws.String(amiMeta.BootMode)
}
// EnaSupport is optional on RegisterImage; AWS omits it when never set.
if amiMeta.EnaSupport != nil {
image.EnaSupport = aws.Bool(*amiMeta.EnaSupport)
}
if bdms := synthesizeRootBlockDeviceMapping(amiMeta, encryptedAtRest); bdms != nil {
image.RootDeviceName = aws.String("/dev/sda1")
image.BlockDeviceMappings = bdms
@@ -496,8 +501,10 @@ func (s *ImageServiceImpl) CreateImageFromInstance(params CreateImageParams, acc
RootDeviceType: ec2.DeviceTypeEbs,
ImageOwnerAlias: accountID,
BootMode: sourceAMI.BootMode,
Distro: sourceAMI.Distro,
DistroFamily: sourceAMI.DistroFamily,
// Every instance reports ENA support, and AWS takes the image's from the instance.
EnaSupport: aws.Bool(true),
Distro: sourceAMI.Distro,
DistroFamily: sourceAMI.DistroFamily,
// Snapshot succeeded before this point, so the image is complete.
State: "available",
}
@@ -901,6 +908,7 @@ func (s *ImageServiceImpl) CopyImage(ctx context.Context, input *ec2.CopyImageIn
ImageOwnerAlias: accountID,
CreationDate: time.Now().UTC(),
BootMode: srcMeta.BootMode,
EnaSupport: copyBoolPtr(srcMeta.EnaSupport),
Distro: srcMeta.Distro,
DistroFamily: srcMeta.DistroFamily,
Tags: tags,
@@ -1110,6 +1118,7 @@ func (s *ImageServiceImpl) RegisterImage(ctx context.Context, input *ec2.Registe
CreationDate: time.Now().UTC(),
Tags: tags,
BootMode: aws.StringValue(input.BootMode),
EnaSupport: copyBoolPtr(input.EnaSupport),
// The referenced snapshot already exists (checked above), so the
// image is complete as soon as this config is written.
State: "available",
@@ -1124,6 +1133,15 @@ func (s *ImageServiceImpl) RegisterImage(ctx context.Context, input *ec2.Registe
return &ec2.RegisterImageOutput{ImageId: aws.String(amiID)}, nil
}
// copyBoolPtr returns a pointer to a copy of *b, or nil, so two AMI records
// never share one flag.
func copyBoolPtr(b *bool) *bool {
if b == nil {
return nil
}
return aws.Bool(*b)
}
// pickRootSnapshotBDM returns the BDM matching RootDeviceName (if set) that
// carries a non-empty EBS snapshot reference, else the first such BDM.
func pickRootSnapshotBDM(mappings []*ec2.BlockDeviceMapping, rootDeviceName *string) *ec2.BlockDeviceMapping {
@@ -2,11 +2,13 @@ package image
import (
"context"
"fmt"
awsidentifiers "github.com/mulgadc/spinifex/spinifex/foundation/aws/identifiers"
"io"
"log/slog"
"net/http"
"net/http/httptest"
"strconv"
"strings"
"testing"
"time"
@@ -1329,6 +1331,42 @@ func TestRegisterImage_HappyPath(t *testing.T) {
assert.Equal(t, testAccountID, *img.OwnerId)
}
func TestRegisterImage_EnaSupport(t *testing.T) {
tests := []struct {
name string
in *bool
want *bool
}{
{"true is stored and described", aws.Bool(true), aws.Bool(true)},
{"false is stored and described", aws.Bool(false), aws.Bool(false)},
{"unset is omitted", nil, nil},
}
for i, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
svc, store := setupTestImageService(t)
snapID := fmt.Sprintf("snap-ena%03d", i)
putTestSnapshotConfig(t, store, snapID, 8, testAccountID)
input := validRegisterImageServiceInput(snapID)
input.EnaSupport = tt.in
out, err := svc.RegisterImage(context.Background(), input, testAccountID)
require.NoError(t, err)
desc, err := svc.DescribeImages(context.Background(), &ec2.DescribeImagesInput{
ImageIds: []*string{out.ImageId},
}, testAccountID)
require.NoError(t, err)
require.Len(t, desc.Images, 1)
if tt.want == nil {
assert.Nil(t, desc.Images[0].EnaSupport, "an image registered without EnaSupport must omit the member")
return
}
require.NotNil(t, desc.Images[0].EnaSupport)
assert.Equal(t, *tt.want, *desc.Images[0].EnaSupport)
})
}
}
func TestRegisterImage_DuplicateName(t *testing.T) {
svc, store := setupTestImageService(t)
@@ -1798,12 +1836,41 @@ func TestCopyImage_InheritsSourceFields(t *testing.T) {
assert.Equal(t, uint64(32), newMeta.VolumeSizeGiB)
assert.Equal(t, "ebs", newMeta.RootDeviceType)
assert.Equal(t, "uefi", newMeta.BootMode, "CopyImage must propagate BootMode from source")
assert.Nil(t, newMeta.EnaSupport, "an unset EnaSupport stays unset on the copy")
assert.Equal(t, "debian-12", newMeta.Distro, "CopyImage must propagate Distro from source")
assert.Equal(t, "debian", newMeta.DistroFamily, "cloud-init family detection reads DistroFamily")
assert.Equal(t, digest, newMeta.SourceDigest, "a zero-copy share still holds the source artifact")
assert.False(t, newMeta.CreationDate.Before(before), "CreationDate must be refreshed on copy, not inherited")
}
func TestCopyImage_CarriesEnaSupport(t *testing.T) {
for _, want := range []bool{true, false} {
t.Run(strconv.FormatBool(want), func(t *testing.T) {
svc, store := setupTestImageService(t)
putTestSnapshotDoc(t, store, ebsmetadata.Snapshot{
SnapshotID: "snap-ena-src", VolumeID: "vol-ena", VolumeSize: 8,
State: "completed", Progress: "100%", OwnerID: testAccountID,
})
putTestAMIConfigWithSnapshot(t, store, "ami-ena-src", "ena-source", testAccountID, "snap-ena-src", ebsmetadata.AMI{
Architecture: "x86_64",
PlatformDetails: "Linux/UNIX",
Virtualization: "hvm",
VolumeSizeGiB: 8,
RootDeviceType: "ebs",
EnaSupport: aws.Bool(want),
})
out, err := svc.CopyImage(context.Background(), validCopyImageServiceInput("ami-ena-src", "ena-copy"), testAccountID)
require.NoError(t, err)
newMeta, err := svc.GetAMIConfig(context.Background(), *out.ImageId)
require.NoError(t, err)
require.NotNil(t, newMeta.EnaSupport)
assert.Equal(t, want, *newMeta.EnaSupport)
})
}
}
func TestCopyImage_NewSnapshotSharesSourceVolumeID(t *testing.T) {
svc, store := setupTestImageService(t)
@@ -11,6 +11,11 @@ import (
"github.com/mulgadc/spinifex/spinifex/runtime/compute/vm"
)
// instanceEnaSupport is what every instance reports for ENA. Guests use virtio
// NICs, and DescribeInstances, RunInstances and DescribeInstanceAttribute all
// answer from this one value.
const instanceEnaSupport = true
// InstanceProjection carries the caller-scoped values ProjectInstance needs.
// All fields are plain data so the projection stays pure and table-testable.
type InstanceProjection struct {
@@ -169,6 +174,7 @@ func ProjectInstance(v *vm.VM, cfg InstanceProjection) (inst *ec2.Instance, stat
// aws_instance ever settled. Interfaces are copied rather than mutated
// because instanceCopy shares their pointers with the stored instance.
instanceCopy.SourceDestCheck = aws.Bool(true)
instanceCopy.EnaSupport = aws.Bool(instanceEnaSupport)
if len(instanceCopy.NetworkInterfaces) > 0 {
nics := make([]*ec2.InstanceNetworkInterface, 0, len(instanceCopy.NetworkInterfaces))
for _, nic := range instanceCopy.NetworkInterfaces {

Some files were not shown because too many files have changed in this diff Show More