Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use a toolbox container until after it has been configured
It was possible to have 'podman exec' invoked against a toolbox container before the entry point had finished initializing it. This could lead to situations where '$USER' didn't yet exist inside the container when 'podman exec' attempted running a binary as that user, which would end up failing 'toolbox enter'. There are a number of corner cases that need to be kept in mind while implementing any kind of synchronization. First, older containers don't use 'toolbox init-container' as their entry point. This might mean that their start-up can't be synchronized but they should still be kept working in their current state. Second, once a container has been started, subsequent 'podman start' invocations are NOPs. They won't lead to newer instances of the entry point process being launched. Third, the entry point process can crash or get killed due to an out-of-band 'podman stop'. In such cases, 'toolbox enter' should not get confused or deadlocked. It should give a meaningful error message to the user. Fourth, it would be nice to not have to touch the 'create' command so that toolbox containers created with Toolbox 0.0.10 onwards can have their start-up synchronized. This means that the host can't add any new environment variable or bind mount to the container to agree upon a path that's keyed by the container's identity and shared with the host. Given all these considerations, a timed busy loop that looks for the presence of a stamp file, keyed by the entry point's PID, is the most robust solution that can be verified as correct. Anything involving file locks becomes increasingly complicated and hard to verify. Under normal circumstances, the loop isn't expected to last more than a few iterations. In case the entry point dies, the loop will time out after approximately 25 seconds, the same interval as the default for D-Bus method calls. Some changes by Debarshi Ray based on an idea from Jan Hlaváč. #305
- Loading branch information