-
Notifications
You must be signed in to change notification settings - Fork 21
Description
We use read-only filesystems in our docker containers deployed in k8s as a security measure (required by internal policies). I think this would probalby be fine on its own (we bake our python dependencies in at build time), but when combined with PythonCall we run into trouble. I think the root of it is that PythonCall calls envdir to get the location of the CondaPkg-managed executable, here:
That in turn calls resolve (not mentioned in the docstring!) which in turn creates a pidlock file with no way to disable it or control where it gets written (other than always including CondaPkg as a top-level dependency in every project we containerize this way, even if it's just a PythonCall-using package many layers deep in the stack that needs it):
Lines 527 to 532 in 0c84aac
| lock = try | |
| Pidfile.mkpidlock(lock_file; wait = false) | |
| catch | |
| @info "CondaPkg: Waiting for lock to be freed. You may delete this file if no other process is resolving." lock_file | |
| Pidfile.mkpidlock(lock_file; wait = true) | |
| end |
I'd hoped that setting offline mode would disable this kinda stuff but, no dice...that check doesn't get tripped until after the lockfile has been acquired:
Line 582 in 0c84aac
| dry_run |= offline() |
I'm not totally sure this is an issue with CondaPkg per se, but I can think of a few things that CondaPkg might be able to do to play more nicely with read-only filesystems.
- Allow the
meta_dirlocation to be controlled by a preference (then you could use a writeable volume mount in k8s) - Disable the pidlock file in offline mode if no writes are going to take place
- Refactor
envdir+resolveto not callresolvedirectly but instead update the environment information/state directly.
I'll also note that looking at the code for activate! (which PythonCall also calls using the CondaPkg backend), envdir is called again.
EDIT: I just noticed the STATE.frozen check that provides a bail out as well. I think that might provide some help as well, but envdir would still need to have some mechanism for auto-detecting the environment... #115