[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Update on GuixSD containers
From: |
Thompson, David |
Subject: |
Re: Update on GuixSD containers |
Date: |
Fri, 19 Jun 2015 08:29:24 -0400 |
On Fri, Jun 19, 2015 at 8:08 AM, Ludovic Courtès <address@hidden> wrote:
> "Thompson, David" <address@hidden> skribis:
>
>> On Sat, Jun 13, 2015 at 4:19 PM, Ludovic Courtès <address@hidden> wrote:
>>> "Thompson, David" <address@hidden> skribis:
>>>
>>>> On Sat, Jun 13, 2015 at 9:06 AM, Ludovic Courtès <address@hidden> wrote:
>>>>> "Thompson, David" <address@hidden> skribis:
>>>>>
>>>>>> On Fri, Jun 12, 2015 at 11:12 AM, Ludovic Courtès <address@hidden> wrote:
>>>>>>> "Thompson, David" <address@hidden> skribis:
>>>>>>>
>>>>>>>> Yeah, our daemon would do the same thing. We could maybe even have a
>>>>>>>> little Guile library that allows one to evaluate arbitrary scheme code
>>>>>>>> from within the container. :)
>>>>>>>
>>>>>>> Actually, something quite easily feasible would be this:
>>>>>>>
>>>>>>> (eval-in-container #~(system* #$evil-program
>>>>>>> #$(local-file "important-data.txt"))
>>>>>>> #:networking? #f)
>>>>>>>
>>>>>>> ... where the container’s store would be populated with just
>>>>>>> EVIL-PROGRAM and the local file.
>>>>>>>
>>>>>>> Food for thought...
>>>>>>
>>>>>> Ooooh yeah! That would be cool. Though I think we should still spawn
>>>>>> a dmd process as PID 1 to deal with reaping zombie processes. We
>>>>>> could generate a single service that runs the gexp script. How does
>>>>>> that sound?
>>>>>
>>>>> Wouldn’t it be enough to have the Guile process that evaluates the
>>>>> expression be PID 1 in the container, as is the case in guix-daemon
>>>>> containers?
>>>>
>>>> Sure, it would work, but my concern is that a long-running process on
>>>> a user's machine could create and orphan tons of child processes and
>>>> nothing would be able to clean them up until the PID namespace is
>>>> garbage collected.
>>>
>>> My understanding was that killing a container’s PID 1 (from the outside)
>>> effectively killed all the processes of that PID name space. Isn’t it
>>> the case?
>>
>> Yes, that is the case. That triggers the "garbage collection" of that
>> namespace, if you will. My point is that, without a proper PID 1 that
>> can DTRT with orphaned processes, a long running process in a
>> container could potentially create a ton of orphaned child processes
>> with no way for them to be reaped without killing PID 1. I wouldn't
>> be very happy if a program that I was running in a sandbox was
>> polluting the process list. I don't think this is a concern for the
>> build daemon because the build process is a (relatively) short-lived
>> process, but running something like a web browser could go on for
>> days, weeks, etc.
>
> Yes, I understand. This is definitely an important concern for full
> GuixSD containers.
>
> However, ‘eval-in-container’ would be much simpler, synchronous, and
> typically for short-lived processes. So I guess the process that runs
> ‘eval-in-container’ would clone(2) (via ‘call-with-container’) and
> simply waitpid(2) the child process (which is PID 1 in its container).
>
> When the parent process gets a SIGINT or SIGHUP, it could send SIGKILL
> to the child, thereby terminating the container.
>
> Does that make sense?
Yes, crystal clear now. Thanks for bearing with me.
>>> (The daemon works around that by running processes under a separate UID
>>> and doing kill(-1, SIGKILL) under that UID.)
>>
>> So, PID 1 in the build container forks and changes the UID or
>> something?
>
> Yes, with setuid (see build.cc:2180.)
Awesome, thank you.
My current container work is figuring out how to spawn interactive
processes in a container, such as bash or a Guile REPL. Seems I need
to learn how to make a pty and maybe do some dup/dup2 calls to pipe
stdin in the parent process to the child container process. Any
wisdom you have (or anyone else reading this) would be most welcome.
:)
- Dave
- Re: Update on GuixSD containers, (continued)
- Re: Update on GuixSD containers, Thompson, David, 2015/06/11
- Re: Update on GuixSD containers, Ludovic Courtès, 2015/06/12
- Re: Update on GuixSD containers, Thompson, David, 2015/06/12
- Re: Update on GuixSD containers, Ludovic Courtès, 2015/06/13
- Re: Update on GuixSD containers, Thompson, David, 2015/06/13
- Re: Update on GuixSD containers, Ludovic Courtès, 2015/06/13
- Re: Update on GuixSD containers, Thompson, David, 2015/06/16
- Re: Update on GuixSD containers, Ludovic Courtès, 2015/06/19
- Re: Update on GuixSD containers,
Thompson, David <=