Two follow-ups hectorvent flagged on #4619, approved but marked as
separate-PR material:
Compares an existing asset's persisted SHA-256 instead of reading its
bytes. The hash is normal metadata (not @JsonIgnore like the content
field), so this needs no disk read, no in-memory-store lookup, and no
special case for a backing file that happens to be missing - a stored
hash never "goes missing" the way a file can, and a genuinely different
republish still conflicts even when the file is gone, closing a gap the
previous byte-comparison approach had.
Extends the idempotent-retry allowance to an already-Published version.
AWS's "Overwriting package assets" rule isn't scoped to Unfinished, and
the terminal publish call (the one that actually finishes a version) is
the likeliest one a client retries after a dropped response. A brand-new
asset name against a Published version still always conflicts; only a
byte-identical replay of an asset that's already there is idempotent.
PublishPackageVersion silently overwrote a generic-format asset's stored
bytes whenever the same asset name was republished to an Unfinished
package version, with no comparison against what was already there. AWS's
own docs ("Overwriting package assets" in the CodeArtifact packages
overview) say a republish is only rejected when the content actually
differs from what's already stored; byte-identical content succeeds
idempotently. Compares the new upload against the existing asset's real
bytes (read the same way GetPackageVersionAsset does, not the in-memory
PackageAsset.content field, which is @JsonIgnore and unreliable after a
reload) and now returns ConflictException on a genuine mismatch instead of
silently replacing the content.
GetRepositoryEndpoint for format=npm now returns a working registry
endpoint: real npm/yarn/pnpm clients can publish to and install from it,
proxied straight through to a real Verdaccio instance rather than
reimplemented. Every request needs Authorization: Bearer <token> from
GetAuthorizationToken, matching npm's own _authToken config and, unlike
Maven's HTTP Basic support, Bearer only.
Unlike Reposilite, Verdaccio has no native concept of multiple named
repositories inside one instance, so each CodeArtifact repository gets
its own container instead of sharing one, started lazily on first use
and identified by a fresh id assigned at CreateRepository time so a
repository deleted and recreated under the same name never inherits the
previous one's packages. Each container is started with
VERDACCIO_PUBLIC_URL set to that repository's own proxy URL so package
metadata it returns (dist.tarball) points back through Floci instead of
the container's own internal, client-unreachable address.
VerdaccioSidecarManager implements the RepositorySidecarManager
interface CodeArtifactService already generalized DeleteRepository's
cleanup over, so a deleted repository's Verdaccio container is stopped
and removed the same generic way Maven's Reposilite storage is released.
The per-key container lifecycle (map of running containers, per-key
start lock, health poll, restart-on-unhealthy, stop-all) has nothing
Verdaccio-specific in it, so it is pulled out into PerKeyContainerPool
for a future per-repository sidecar to reuse directly.
CodeArtifactNpmDataPlane is a raw streaming proxy rather than a JAX-RS
controller, since npm's wire protocol has no fixed path shape the way
Maven's GAV layout does; Verdaccio already speaks that protocol
correctly, so this only needs to authenticate the request and forward
it. The publish/fetch integration test replays a real request the npm
CLI sent during manual verification, captured with a tiny Node.js
capture server, so it exercises the exact envelope shape (including a
real gzip tarball attachment) npm publish actually produces; the full
round trip was additionally verified by hand with the real npm CLI
against a live Floci instance.
DeleteRepository never cleaned up the Reposilite-side storage of a deleted
repository; it was left behind, wasting space over a long-running process.
Reposilite has no bulk-delete endpoint, but DELETE on a path recursively
removes everything under it in one call, so this deletes each of the
repository's top-level entries before removing it from the shared settings
list, verified against a live instance. Order matters: the repository must
stay registered while its files are deleted, since Reposilite 404s every
path, including DELETE, for an id absent from its settings.
Release is best-effort: the CodeArtifact-side metadata delete already
committed by the time it runs, matching real CodeArtifact's own
DeleteRepository (synchronous, always succeeds once the repository exists).
A sidecar that is unreachable must not turn an already-successful delete
into a 500, and must not leave the repository stuck, since a retry would
just 404 against the already-deleted record.
Introduces RepositorySidecarManager, a small interface every per-format
sidecar can implement, and CodeArtifactSidecarRegistry, which discovers
implementations via CDI. CodeArtifactService.deleteRepository releases
storage generically over whatever formats a repository has sidecar ids
for, so a future format's sidecar needs no change here. Reposilite is the
first and only implementation for now; CodeArtifactRepository's
mavenRepositoryId field becomes a sidecarContainerIds map for the same
reason.
GetRepositoryEndpoint for format=maven now returns a URL real Maven clients
(mvn deploy, mvn dependency:get, Gradle) can publish to and resolve from
directly, backed by a shared Reposilite sidecar container started lazily on
first use. A CodeArtifact repository maps to its own Reposilite repository,
provisioned automatically and never reused even across delete/recreate of a
same-named repository, so a fresh repository can never inherit a previous
one's artifacts.
Adds GetAuthorizationToken (a token scoped to a domain, with the 900-43200s
custom range; 0 falls back to 12 hours) and requires it on every Maven proxy
request, either as the password of HTTP Basic credentials, the form AWS's
Maven guide configures with username aws, or as a Bearer token. Maven
requests are not SigV4-signed, so the region and account come from the token.
Also enforces AWS's 5 GB asset size quota on the Maven endpoint, matching the
existing PublishPackageVersion check. Artifacts do not survive a Floci
restart; the service page documents this as a known limitation.
AWS returns ResourceNotFoundException (404) when DeleteDomain targets a
domain that does not exist, even though the API reference leaves it out
of the operation's error list. Keep that behaviour, pin it with unit and
integration tests, and note it in the docs and next to requireDomain.
Closes#4000
Every ConflictException, ResourceNotFoundException, and ServiceQuotaExceededException
the service threw carried a message only, but the wire model declares
resourceId/resourceType on all three, and the AWS SDK exposes them as typed
accessors. Populate them consistently using the resource's locally-unique name
(domain name, repository name, package version, or asset name) as resourceId.
Populating resourceId this way exposed a real crash: Map.of() rejects null
values, so any request missing a required identifier (domain, repository,
package, packageVersion, asset) turned what used to be a wrong-status
ResourceNotFoundException into a raw NullPointerException / HTTP 500. Fixed
by validating required identifiers up front (returning ValidationException,
matching AWS) and by making the extendedData-building helper itself
null-safe against a missing resourceId, so no single overlooked call site
can reintroduce a 500.
CreateDomain and CreateRepository accepted an unlimited number of domains and
repositories, but AWS caps an account at 10 domains per Region and a domain at
1,000 repositories, returning ServiceQuotaExceededException once reached.
Adds PublishPackageVersion, DescribePackageVersion, and GetPackageVersionAsset
for CodeArtifact's generic package format, matching AWS's own wire restriction
that PublishPackageVersion accepts only the generic format. Includes real
asset hashing (MD5, SHA-1, SHA-256, SHA-512), SHA-256 integrity verification
against the caller's x-amz-content-sha256 header, correct Unfinished/Published
status transitions, and the documented AWS quotas for this action (350 assets
per version, 5 GB max asset size), all returning ServiceQuotaExceededException
when exceeded.
Asset bytes are kept out of the JSON/WAL-backed package-version store
(@JsonIgnore on PackageAsset.content) and instead go through a dedicated
asset store, a disk file in persistent/hybrid/wal mode or a side map in
memory mode, the same split S3Object/S3Service already uses for object
bytes. Without this, a publish rewrote every asset of every package version
on disk each time, growing quadratically under this action's own
350-asset/5GB quotas. The asset name is also validated against the wire
model's AssetName pattern (no control characters), not just its length,
since it is echoed back verbatim in the X-AssetName response header on
GetPackageVersionAsset.
Verified against the real botocore service-2.json wire model and the AWS
CodeArtifact User Guide (including its PDF for the quotas table, since the
HTML quotas page is JS-rendered). Live-verified with the real AWS CLI and
the AWS SDK for Java v2 against a running Floci instance, including an exact
byte-for-byte asset round-trip and the real ConflictException when
republishing an already-Published version.
Floci had zero CodeArtifact support: no service package, no docs, nothing.
Any terraform apply touching aws_codeartifact_domain, aws_codeartifact_repository,
or either permissions-policy resource failed outright. This adds the full
CodeArtifact control plane: domain and repository CRUD, resource policies with
optimistic-locking revisions, tags, and the fixed set of real AWS-hosted
external (upstream) connections (public:npmjs, public:pypi, public:maven-central,
etc.).
Package publish/fetch endpoints per format (npm, PyPI, Maven, NuGet, generic)
are intentionally out of scope here: this closes the terraform apply gap, not
real package serving.
ListTagsForResource (POST /v1/tags?resourceArn=) is CodeArtifact's one tag
operation that addresses the resource with a query parameter on the bare path
rather than a path segment, unlike every other V1TagsController/SharedTagsController
handler. That method lives on V1TagsController itself rather than the shared
AbstractTagsController base: SharedTagsController (mounted at /tags) already
declares its own bare POST (tagResourceByBody, for TagResource), so a bare POST
on the shared base collides with it and Quarkus refuses to start. CodeArtifact's
handler is @V1Tags-qualified and only ever registered against V1TagsController,
so the method belongs there. core/common stays service-free: CodeArtifactTagHandler
registers itself as a bean the same way MskTagHandler does, and TagHandler gained
a default for the lowercase key/value entry names CodeArtifact uses instead of
AWS's usual capitalized Key/Value.
Known, documented limitations (see docs/services/codeartifact.md): no cycle
detection across upstream chains, no referential-integrity check when deleting
a repository other repositories reference as an upstream, and no authorization
check on cross-account domainOwner addressing (consistent with Floci's opt-in
IAM enforcement elsewhere).
Verified against the real botocore codeartifact service-2.json (protocol, exact
querystring vs. body placement per operation, exact ARN format, epoch-seconds
timestamps, real error shapes) and the live AWS API docs for behavioral rules
not in the wire model (DeleteDomain blocked while repositories exist, the real
fixed external-connection name/format list, PutDomainPermissionsPolicy's
all-body field placement vs. the sibling repository operation's querystring
placement).
Live-verified three ways:
- Unit tests including a concurrent-create race test proving the synchronized
guard actually holds under contention, plus full-stack QuarkusTest/RestAssured
integration tests.
- A real terraform init/apply/plan/destroy cycle against a running Floci
instance, independently confirming destroy actually tore the domain down via
a follow-up describe-domain call.
- A live AWS SDK v2 Java test exercising the real CodeartifactClient against a
live instance.