Repository navigation
Start Redpanda only after its config is in place - #1483
alpcanaydin wants to merge 2 commits into
Conversation
✅ Deploy Preview for testcontainers-node ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The delayed-configuration regression is covered, and the normal startup path publishes the configuration before readiness checks. No concrete merge-blocking issue was established. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
85538a5a-76dd-4724-a74b-7028e953fd57
📒 Files selected for processing (2)
packages/modules/redpanda/src/redpanda-container.test.tspackages/modules/redpanda/src/redpanda-container.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Summary
RedpandaContainercan start Redpanda before itsredpanda.yamlis in place.containerStartedcopies two files, one after the other: the starter script, thenredpanda.yamlwith the mapped Kafka port. The container command runs the starter script as soon as the script exists, so it races the second copy. On a busy Docker host (a CI runner running other containers, for example) Redpanda reads the image's default config:The wait strategy still passes, because
Successfully started Redpanda!is logged either way. Two failures follow:127.0.0.1:9092, so produce, consume and admin requests time out (KafkaJSCreateTopicError: Local: Timed out,ERR__TIMED_OUT).redpanda.yamllands while Redpanda is starting, Redpanda exits and the start fails withLog stream ended and message "Successfully started Redpanda!" was not received.We hit both intermittently in our own CI on GitHub-hosted runners.
Change
The container command now waits until
redpanda.yamlholds the# Injected by testcontainersmarker that the template already writes on its first line, thenexecsrpk redpanda startwith the same arguments as before. The starter script and its second copy are gone.containerStartedcopies the config toredpanda.yaml.testcontainersand moves it into place with onemv. Docker writes a copied file in place: it creates the file empty and then writes the body, so a split write could expose the marker line before the rest of the config. A rename on the same filesystem makesredpanda.yamlall-or-nothing, so the starter sees either the image default or the whole file.The marker wait is the approach of the Java and Go modules. Their
entrypoint-tc.shwaits for the same marker before it starts Redpanda:The rename goes one step further than those modules, after review feedback on this PR.
Verification
Regression test
should connect when the config reaches the container late and in partswrites each copied file in two parts, first line then whole file, with a 1 s pause between them, as a busy Docker host can. It then asserts a message round trip.Red, against the original implementation (starter script):
Red, against the marker wait without the rename (the first commit of this PR):
Redpanda started on the first line alone, so it advertised no Kafka address.
An earlier version of the test only delayed each copy by 1 s. Against the original implementation it timed out after 240 s, and Redpanda advertised the image default:
Green, with the marker wait and the rename:
Also run:
npx biome ci --error-on-warnings package.json packages/modules/redpanda: no findings.npx tsc -b packages/testcontainers packages/modules/redpanda: passes.Run on macOS with OrbStack (Docker 29.4.0), Node 24.15.0, image
redpandadata/redpanda:v26.2.3.The first commit of this PR, applied as a
pnpm patchto@testcontainers/redpanda@12.2.0, keeps our CI's previously failing integration suite green. Before the patch, a probe that held the second copy back failed every start once the gap reached 150 ms (15 of 15 starts across 150, 200, 300 and 400 ms). Gaps of 50 and 100 ms passed on this machine. With the patch, the same probe, delaying each copy by 150, 400 or 1000 ms, passed 9 of 9 starts.Note:
vitest.config.tsretries tests 3 times on CI, which can hide this race in this repository's own runs.Semver impact
patch. The public API is unchanged: same class, same methods, same Redpanda arguments. Only the internal start mechanism changes. The removed/testcontainers_start.shfile and theWaiting for script...log line were never part of the API.Suggested labels:
bug,patch.