Repository navigation
feat(storage): rotate the bucket and keys live, probed before the swap - #119
Merged
Merged
Conversation
jayleaton
force-pushed
the
feat/storage-ingestion
branch
from
October 23, 2026 09:31
bd62053 to
0828bd2
Compare
jayleaton
force-pushed
the
feat/storage-key-rotation
branch
from
October 23, 2026 09:33
218da75 to
e06734f
Compare
jayleaton
force-pushed
the
feat/storage-ingestion
branch
from
October 23, 2026 09:40
0828bd2 to
cdf6fa0
Compare
jayleaton
force-pushed
the
feat/storage-key-rotation
branch
from
October 23, 2026 09:41
e06734f to
a0a7eba
Compare
jayleaton
force-pushed
the
feat/storage-ingestion
branch
from
October 23, 2026 10:17
cdf6fa0 to
aa575cc
Compare
jayleaton
force-pushed
the
feat/storage-key-rotation
branch
from
October 23, 2026 10:18
a0a7eba to
e06caef
Compare
jayleaton
force-pushed
the
feat/storage-ingestion
branch
from
October 23, 2026 10:25
aa575cc to
c29526e
Compare
jayleaton
force-pushed
the
feat/storage-key-rotation
branch
from
October 23, 2026 10:25
e06caef to
71c2eac
Compare
jayleaton
force-pushed
the
feat/storage-ingestion
branch
2 times, most recently
from
October 23, 2026 11:18
c5d06db to
5217d43
Compare
STORAGE_S3_ENDPOINT/BUCKET/ACCESS_KEY_ID/SECRET_ACCESS_KEY already come from the secrets manager; now a change takes effect without a restart. config.Secrets.OnStorage calls the hook once per distinct set of the four names (like OnKeyring). cmd/server builds a client for the new set and probes it with one signed HEAD on the bucket through storage.Live.Swap, which switches atomically only if the probe passes and closes the old client's idle connections. A failed probe keeps the old client; the manager logs the rejection with fingerprints and retries after each later fetch. Removing all four upstream keeps the current client. Source: jayleaton/auto-visuals#41 (storage part). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jayleaton
force-pushed
the
feat/storage-key-rotation
branch
from
October 23, 2026 11:21
71c2eac to
4e18f4c
Compare
jayleaton
marked this pull request as ready for review
October 23, 2026 11:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sits on #114. There, the storage bucket and keys are live secrets but are read only at boot, so rotating a key or moving buckets meant a restart. Now a change in the secrets provider takes effect live, and only after the new set has proven it works. Source: jayleaton/auto-visuals#41 (storage part only).
Summary
Files:
packages/storage/live.go(new, mirrorsdatabase.Pool.Swap),config.Secrets.OnStorage, the hook incmd/server/storage.go, and theserver.ObjectStoreadapter now over*storage.Live. Docs:docs/storage.md"Rotate keys" (the zero-downtime key runbook) and the row indocs/secrets.md. If storage was off at boot and turns on upstream, that is logged: mounting the routes needs a restart.Evidence
The real binary (
make build, static), one process (PID 1258316) for the whole run, onSECRETS_PROVIDER=dopplerwithSECRETS_REFRESH_INTERVAL=10s.DOPPLER_API_URLpointed at a local stand-in that serves Doppler's download JSON from a file, so the real manager polled, validated and ran the hooks. Two local S3 servers (RustFS) had different root keys: S3 #2 answers S3 #1's keys withInvalidAccessKeyId. Everything was removed afterwards.Before (#114): a new set was used only after a restart.
After:
appstorage: bucket reachable storage=endpoint:fp:e368ecdf,bucket:fp:95426130,…ERROR secrets: consumer rejected change, keeping its previous client … err="storage: new bucket/keys …secret:fp:81a9f3c3 failed their probe, keeping …secret:fp:c2e30b05: storage: access denied: head 403 Forbidden"app2storage: bucket/keys rotated from=endpoint:fp:e368ecdf,… to=endpoint:fp:21a3ccdc,bucket:fp:7174bae6,key:fp:75e6372e,secret:fp:a7ad4dc8app2→app2-movedrotated … to=…bucket:fp:154d36cd…WARN storage: STORAGE_S3_* removed upstream; keeping the current bucket client until restartSame PID at the end,
/healthz{"status":"ok"}. A grep of both server logs for every secret value, key id, bucket name and endpointhost:port: 0 hits.Checks:
make check-fastok. After the naming pass (JJ code rules: no single-letter names, no magic numbers) and the rebase onto #114 at0828bd2, the run was repeated on the rebuilt binary (PID 1789590): the wrong secret was rejected with the old client kept, then a new endpoint + keys + bucket swapped live (rotated from=endpoint:fp:f5533671,… to=endpoint:fp:6aefb589,…), the upload landed on S3 #2, and 0 values were in the log. No new tests: the swap lives inpackages/storage, andcmd/configare outside the test boundaries (the same asdatabase.Pool.Swap). It was proven by the run above.Merge Danger
Door: two-way. No state; a revert puts back the read-at-boot behaviour.
Blast Radius: storage. This only matters when storage is on. A bad upstream value can no longer break uploads (it is probed first). A good one switches every instance at its next poll, so copy the objects before moving to a new bucket (documented).
Rebased onto #114 at
c29526e(banded resize, the image routes on the access gate, main24be189).newImagesnow takes the gate; the rotation code is unchanged. Re-checked live on the rebuilt binary (one process): a wrong secret pushed upstream was rejected withaccess denied: head 403 Forbiddenand the old client kept; a new endpoint + keys + bucket rotated (storage: bucket/keys rotated from=endpoint:fp:d9be5b40,… to=endpoint:fp:71791828,…), the next upload landed on the second server, and the log carried 0 secret values. CI green on71c2eac(second attempt; the first hit the samepackages/authscrypt test-time flake as #114).🤖 Generated with Claude Code