Repository navigation
fix: Run the module startup script after it has been copied completely - #1810
Conversation
β Deploy Preview for testcontainers-dotnet ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. WalkthroughThe change adds a shared ChangesContainer startup scripts
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant ContainerBuilder
participant StartupCallback
participant ContainerFilesystem
participant ShellEntrypoint
ContainerBuilder->>StartupCallback: generate startup script text
StartupCallback-->>ContainerBuilder: return script text
ContainerBuilder->>ContainerFilesystem: write /testcontainers.sh and /testcontainers.ready
ShellEntrypoint->>ContainerFilesystem: wait for ready marker
ContainerFilesystem-->>ShellEntrypoint: return ready marker
ShellEntrypoint->>ContainerFilesystem: clear marker and execute /testcontainers.sh
Suggested labels: Suggested reviewers: Merge Risk:
|
What does this PR do?
The PR adds a protected
WithStartupScriptmethod toContainerBuilder. The Kafka, Pulsar, Redpanda and FakeGcsServer modules now use it. The container's main process waits until a ready file is copied, which happens after the startup script has been copied. It then empties the ready file andexecs the script. The script runs only after it has been copied completely, and it's copied again on every start. A restarted container uses its new mapped ports. Because ofexec, the script runs as the container's main process, so it receives the stop signal and shuts down cleanly.For Kafka in ZooKeeper mode, it sets
KAFKA_CONTROLLED_SHUTDOWN_RETRY_BACKOFF_MS=0. When the container is stopped right after it starts, Kafka may not know its controller yet and waits 5 s per retry. Docker kills it before it unregisters from ZooKeeper, and the next start fails.Why is it important?
Containers could run the startup script before it was fully copied, which failed with
Text file busy. Stopping and starting a container ran the old script with stale ports, or the container failed to start again.Related issues
Summary by CodeRabbit