-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unique container names are bad #17
Comments
Thanks for reporting this and sorry it caused you some pain! Since you have a workaround, I'd like to take the time to fully understand the issues you're facing so we can work out the right solution :-)
The rationale behind unique container names is that we needed to support parallel builds on the same machine. I was under the impression that this was a safer default than having parallel builds interfere with each other (this has also caused me lost days to debug in other circumstances). Note: there is no reason to use the PID specifically, just some value that is locally unique for the duration of the test run.
I agree that we should try to honour At the very least, I think we should honour Would that work for you?
Using fixed container names prevents build-up, which provides a partial solution to your problem, but I'm not sure we can solve the CTRL-C issue within a pytest plug-in. I get proper cleanup when tests fail. What do you mean by "if test runs fail"?
Do you also see build-up when using fixed container names? I automate daily cleanup of dangling images on all my machines that should run unsupervised for long periods of time (see this gist for several recipes). I wish the Docker daemon did this automatically because it really helps all projects, not just tests run using |
Ah ok. Admittedly, I haven't tested parallel builds on my dev machine, even though I need that for our CI server.
I'll read up / test and get back to you. I am not sure what it does tbh.
True, but having unique names limits the problem to one set.
Sorry, this was unspecific. During getting started with docker and pytest, we had many tests failing during setup rather than test run. For example, problems in the docker-compose file etc. Those aren't cleaned up properly afaik. However, I would need to re-test for details, after days of trial and error everything become a bit hazy ;) Re images: Admittedly this is the smallest problem and can be easily solved with a script like you mention. The main issue for us was using a static network. I've chosen to put our docker networks on a rarely used network as I constantly had problems with overlaps of local networks, vpns, wifis etc. I don't know how other people deal with this (I am rather new to docker), but I configured this as follows:
This configuration supports only a single instance, and thus fails with multiple instances with unique names due to a subnet overlap error. |
Just thinking out loud - would this be better handled by having unique tags and repeatable image names? I don't believe
Of course this would require a new |
@danodonovan I'm not sure I understand how your proposal works. Can you tell me more? |
Sorry for delay. The idea would be to have a static image name (ie the project name sans pid) and then have unique tags for different builds (to cover the support for parallel builds).
But, having investigated further, TL;DR I don't think this will work with |
Wouldn't it make more sense to use labels to group containers, and have a garbage collection step identifying running containers associated with test runs where the test process has terminated? |
@mikemol ... and you would identify the test runs where the test process has terminated from the Who would execute the garbage collection step? If it's the test process then it's containers are still valid (as the PID is still valid) - and so wouldn't get cleared. |
I know I can override container names, but I think the default implementation is bad.
Currently containers are named
"pytest{}".format(os.getpid())
. This leads to the following problems:This cost me days to debug (no docker wiz here).
Is there a specific reason why to use the pid-based naming? I would follow simply the behavior of docker-compose:
The text was updated successfully, but these errors were encountered: