Unable to use some testcontainers-modules in certain environments
Problem
Hi. I am currently experiencing some problems with some containers from testcontainers-modules - they are just not starting, specifically postgres and vault (current issue is NOT about these modules, I'll send additional issues and PRs to appropriate repo).
What was weird is that they worked fine on my laptop, but didn't work in our company's Gitlab. After some research I found out that our Gitlab CI uses Kubernetes Executor, and for some reason images there output both stdout and stderr into stderr, I am not sure why and who is to blame here, that is not the point.
But Rust implementation of testcontainers is the only one having problems in this situation - Java, Go, Python are fine.I am not sure how testcontainers-rs WaitFor strategy is different from other languages, but it seems to be implemented not the same way.
I had to fork postgres container and remove this line, leaving only stderr check, to make it work.
Proposal
I am proposing to allow customization of ready conditions through ImageExt, this will allow:
- cover such cases with weird environments;
- users to use newer tags (when they need specific software version) where existing ready conditions are simply not working, for example when log line is changed or readiness probe endpoint changed.
Alternative is to introduce LogWaitStrategy::Both, which will read both stdout and stderr and match on combined output.
Hi and thanks for the report 👋
I had to fork postgres container and remove this line, leaving only stderr check, to make it work.
This line exists intentionally because PostgreSQL actually starts twice. I suppose other implementations use the both approach for the conditions.
In general, I don’t mind allowing customizations over ready conditions. However, it should be clearly stated that once a user makes such changes, it’s their own decision and responsibility.
it should be clearly stated that once a user makes such changes, it’s their own decision and responsibility.
I think it should be general note on most methods in ImageExt, since testcontainer is probably tested against specific image, tag, ready conditions, etc.
This line exists intentionally because PostgreSQL actually starts twice. I suppose other implementations use the both approach for the conditions.
Ok, thanks for clarification. I think adding "wait for log in either output" would be a good idea to align waiting behavior with testcontainers implementations in other languages.
I think it should be general note on most methods in ImageExt, since testcontainer is probably tested against specific image, tag, ready conditions, etc.
Yes, that's true. It's applicable to any customization
I split proposed changes into 2 separate PRs because I was not sure if you want new LogStrategy or not. But currently I think this would be way to go in most situations, basically use it unless you need something very specific.
@Flowneee should we consider this issue closed?
Please, re-open if you feel it's still relevant As I can see we merged two PRs previously that should cover this