Make MinIO bucket creation wait for readiness and fail loudly - #268
Conversation
sublime_create_buckets raced MinIO startup with a blind `sleep 15` and swallowed all errors via an unconditional `exit 0`. When MinIO was slow to accept connections, mc alias set / mc mb would fail, but the container still exited 0, so `docker compose up --wait` was satisfied and the stack came up with no buckets. Consumers then hit a confusing PutObject -> 404 (NoSuchBucket) far from the real cause. Replace the fixed sleep with a bounded readiness retry loop (60 attempts x 2s) against `mc alias set`, which performs a real authenticated round-trip. Use `mc mb --ignore-existing` so re-runs against a populated s3_data volume stay idempotent, and drop the unconditional exit 0 so genuine failures propagate and --wait gates on success. Pin minio/minio and minio/mc to explicit tags instead of `latest` so startup timing and CLI behavior don't drift. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
There was a problem hiding this comment.
Pull request overview
This PR hardens local/self-hosted MinIO bucket provisioning by replacing a fixed startup delay with a bounded readiness check and ensuring bucket-creation failures correctly fail the sublime_create_buckets container (so docker compose up --wait doesn’t report success when buckets were not created).
Changes:
- Pin
minio/minioandminio/mcto explicit release tags instead of relying onlatest. - Replace
sleep 15with a bounded retry loop that waits for an authenticatedmc alias setround-trip to succeed. - Make bucket creation idempotent via
mc mb --ignore-existingand remove the unconditionalexit 0so genuine failures propagate.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
cameron-dunn-sublime
left a comment
There was a problem hiding this comment.
Nice!
This probably isn't important for main, but it's also not a bad idea. It's not important just because if there's a human in the loop it's generally going to be plenty of down time as someone goes through setup.
Yup, that's what I figured. |
(HUMAN): Gimlet diagnosed a flake that struck a few times today, where we make a bucket, sleep for 15s, and then just hope it worked in time. Use a retry loop to ensure creation has succeeded. Opted to make this change for dev only since I'm unsure how much it matters for prod (if creation is just slow then it doesn't really matter the same way it matters for tests). The rest of the description is all Claude.
Summary
sublime_create_bucketscurrently races MinIO startup with a blindsleep 15and swallows all errors via an unconditionalexit 0. When MinIO is slow to accept connections,mc alias set/mc mbfail, but the container still exits 0,docker compose up --waitis satisfied, and the stack comes up with no buckets. Consumers then hit a confusingPutObject→ 404 (NoSuchBucket) far from the real cause — this is how the issue surfaced as a go-mantis unit-test flake inTestQuantumHuntPhaseOneProcessor_StartQuantumHunt.This replaces the fixed sleep with a bounded readiness retry loop and makes genuine failures fail the container, while keeping re-runs against an existing
s3_datavolume idempotent.sleep 15with a bounded retry loop (60 attempts × 2s) pollingmc alias set— a real authenticated round-trip against the endpoint.;-separatedmc mbcalls with&&-chained,--ignore-existinginvocations so pre-existing buckets on a persistents3_datavolume are a no-op rather than a failure.exit 0so real failures propagate and--waitactually gates on success.minio/minioandminio/mcto explicit tags (previously unpinnedlatest), matching what was currently resolving.Scope / who this affects
dev'sdocker-compose.ymlis not the customer-facing installer path —install-and-launch.sh(the public installer atcurl -sL https://sublimesecurity.com/install.sh | sh) does a plaingit clonewith no branch flag, so it checks out the repo's default branch (main).main's compose includes the realsublime_mantis/sublime_bora_liteservices at pinned release versions;dev's compose omits both (dashboard points athost.docker.internal:8000), becausedevis the dependency stack Sublime engineers and go-mantis CI use to run mantis/bora from source against containerized dependencies (postgres, redis, minio, strelka, tika, azurite, hydra, localstack).So this change is scoped to that internal dev/CI dependency stack, not the shipped customer product. Installs that previously "succeeded" while silently failing bucket creation will now fail loudly instead for engineers/CI running the dev stack — that's the intended correction, not a regression.
A forward-port of this same fix to
mainshould follow as a separate PR, since that's the branch with actual customer-facing risk (existing installs with a populateds3_datavolume must stay idempotent there too).Context
minio,create_buckets,healthchecksearch terms and all 8 open PRs).Follow-ups (not in this PR)
main(see Scope note above).sublimes3+condition: service_healthywas considered but deferred — no probe binary has been verified against the pinnedminio/miniotag (recent images droppedcurl), and a wrong probe would mark the whole stack unhealthy. The retry loop is sufficient on its own.TestMainso a missing bucket reports itself directly instead of surfacing as a 404 inside an unrelated test.dev: the "Validate Platform Installation" check has failed on every push todevsince at least April 2026 (Bora container not found) becauseinstall-and-launch.sh's health check looks forsublime_bora_lite, which only exists onmain's compose. Not touched by this PR.Test plan
docker compose up -d --wait sublimes3 sublime_create_bucketson a running dev stack with a populateds3_datavolume: retry loop absorbed one connection-refused attempt,--ignore-existingtreated all pre-existing buckets as no-ops, container exited 0,--waitreported healthy.latestcurrently resolves to.--ignore-existingis supported by the pinnedmcbuild.max_attemptsrather than hanging.main-*CI shards over the next several days for absence of recurrence (this was an intermittent race — a single green run doesn't prove the fix).🤖 Generated with Claude Code