Commit Graph
3 Commits
Author SHA1 Message Date
0b7bd23647 s3api: stop at startup when the -s3.config KMS block doesn't load (#13380)
* s3api: stop at startup when the -s3.config KMS block doesn't load

A kms block in the -s3.config file that failed to load was only logged,
so S3 came up healthy with SSE-KMS off. Every SSE-KMS write and every
read of an SSE-KMS object then failed with 500, and nothing at startup
pointed at the config.

loadS3ApiConfigurationFromFile now returns the KMS error once it has
applied the identities, and startup already stops on any error it
returns. A SIGHUP reload still applies the identities, so a revoked
key stops working, keeps the previous KMS providers and logs the error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: shorten the KMS load-order comment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
2026-12-04 11:07:11 -08:00
9c214d0ff5 kms: close replaced providers after a grace period (#13359)
* kms: close replaced providers after a grace period

A reload closed each provider it replaced or removed right away, while S3
requests that had fetched it just before could still be using it. Those
requests failed. A replaced or removed provider now stays open for a grace
period of a minute and is then closed once, however often it was retired.
The manager's Close closes the ones still waiting.

The global provider is now the manager's default one, looked up on each
use, so a reload can't leave it pointing at a closed instance. A provider
set with SetGlobalKMSProvider still takes its place until the next load,
which clears it. Passing nil hands it back to the manager's default, where
before it turned KMS off until the next load. While a retired provider is
global, its retirement is held with no timer, and it starts again once it
isn't. SetGlobalKMSProvider no longer closes the provider it replaces,
since the caller owns what it passes. A provider InitializeGlobalKMS
created belongs to the package, so it's closed once another global
provider replaces it. The manager's Close clears the global provider if
it's one the manager closes, so it isn't used closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* kms: read the global override and the default provider under one lock

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* kms: check the replaced global instance is held before unsetting it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* kms/openbao: close the reload test's providers through the manager

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
2026-12-03 23:14:53 -08:00
7c41ed0635 kms: swap a reload's providers in as a whole, after S3 parses its identities (#13344)
* kms: build every provider before a reload swaps them in

A reload replaced the providers one at a time, closing each old instance
as its replacement went in, and kept the providers and bucket mappings
the config no longer listed. Between closing the old default instance and
setting the new global provider, S3 could get the closed instance. A
reload now builds every provider first and swaps the whole set in at
once, along with the default, the bucket mappings and the global
provider. The default provider failing still fails the reload, and then
nothing changes. Any other provider that fails keeps its previous
instance. Providers the config no longer lists are dropped, and a bucket
mapped to one falls back to the default. A manager other than the global
one no longer sets the global provider. The manager no longer keeps the
provider configurations, which nothing read. Each load health-checks
every provider once, after the swap, for filer.toml as for the identities
file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: parse the identities before loading KMS

Loading the S3 config loaded KMS before parsing the identities, so a file
whose identities didn't parse still replaced the KMS providers. A file
without a kms block left the previous providers in place, and one with a
number out of float64 range, which protojson accepts, skipped KMS without
an error.

The identities are now parsed first, and a file that fails there changes
neither. A file without a kms block drops the providers, so a reload that
took the block out turns SSE-KMS off. A file encoding/json can't read
fails the KMS load with an error that doesn't quote it, as it could quote
key material. A KMS load that fails is logged as an error, not a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* kms: skip a bucket mapping with an empty bucket name

SetBucketKMSProvider refused an empty bucket name, which the rebuilt
mappings no longer went through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* kms: check a rejected load leaves the installed provider open

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
2026-12-03 10:34:45 -08:00