You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Andrew Schwartzmeyer <an...@schwartzmeyer.com> on 2017/02/07 02:30:59 UTC

Review Request 56362: Windows: Create the `WindowsLauncher`.

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/
-----------------------------------------------------------

Review request for mesos, Alex Clemmer and Joseph Wu.


Bugs: MESOS-6892
    https://issues.apache.org/jira/browse/MESOS-6892


Repository: mesos


Description
-------

Instead of deriving `WindowsLauncher` from `PosixLauncher`,
this commit implements a separate `WindowsLauncher` derived
from `Launcher` parallel to the `PosixLauncher`.

The purpose of this is to setup for refactoring the `WindowsLauncher`
into a `Launcher` that uses Windows' "Job Objects,"
which are similar to Linux's cgroups, and enable us to reason
about a group of processes. It is necessary to do this in the
`WindowsLaucher` because the current implementation uses the POSIX
idea of a process hierarchy to list and kill all processes
associated with a task. We have found this model to not work on
Windows, and the solution is to use Job Objects.

Because this is preparation work, it is a straight copy of the
current "working" implementation. That is, the `PosixLauncher`
has been copied to create the `WindowsLauncher`, instead of
the latter deriving the former.


Diffs
-----

  src/CMakeLists.txt c09bcde3c14a73ab0b296c400f79f6a775da2470 
  src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
  src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
  src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
  src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
  src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/56362/diff/


Testing
-------


Thanks,

Andrew Schwartzmeyer


Re: Review Request 56362: Windows: Create the `WindowsLauncher`.

Posted by Joseph Wu <jo...@mesosphere.io>.

> On Feb. 7, 2017, 4 a.m., Ilya Pronin wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, line 105
> > <https://reviews.apache.org/r/56362/diff/1/?file=1625893#file1625893line105>
> >
> >     Systemd on Windows? ;)
> 
> Andrew Schwartzmeyer wrote:
>     This iteration is the copy of the existing implementation. It was refactored into the real `WindowsLauncher` in [#56365](https://reviews.apache.org/r/56365/).

You should consider squashing #56365 into this review.  You end up modifying the bulk of this copied code, so the diff-of-a-diff ends up distracting from the review.


- Joseph


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review164490
-----------------------------------------------------------


On Feb. 7, 2017, 10:54 a.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 7, 2017, 10:54 a.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> The purpose of this is to setup for refactoring the `WindowsLauncher`
> into a `Launcher` that uses Windows' "Job Objects,"
> which are similar to Linux's cgroups, and enable us to reason
> about a group of processes. It is necessary to do this in the
> `WindowsLaucher` because the current implementation uses the POSIX
> idea of a process hierarchy to list and kill all processes
> associated with a task. We have found this model to not work on
> Windows, and the solution is to use Job Objects.
> 
> Because this is preparation work, it is a straight copy of the
> current "working" implementation. That is, the `PosixLauncher`
> has been copied to create the `WindowsLauncher`, instead of
> the latter deriving the former.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt c09bcde3c14a73ab0b296c400f79f6a775da2470 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the `WindowsLauncher`.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.

> On Feb. 7, 2017, noon, Ilya Pronin wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, line 105
> > <https://reviews.apache.org/r/56362/diff/1/?file=1625893#file1625893line105>
> >
> >     Systemd on Windows? ;)

This iteration is the copy of the existing implementation. It was refactored into the real `WindowsLauncher` in [#56365](https://reviews.apache.org/r/56365/).


> On Feb. 7, 2017, noon, Ilya Pronin wrote:
> > src/slave/containerizer/mesos/launcher.cpp, line 110
> > <https://reviews.apache.org/r/56362/diff/1/?file=1625891#file1625891line110>
> >
> >     I think it would be better to leave `__linux__` check in place. There's no systemd on macOS or FreeBSD.

Sure thing!


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review164490
-----------------------------------------------------------


On Feb. 7, 2017, 2:30 a.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 7, 2017, 2:30 a.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> The purpose of this is to setup for refactoring the `WindowsLauncher`
> into a `Launcher` that uses Windows' "Job Objects,"
> which are similar to Linux's cgroups, and enable us to reason
> about a group of processes. It is necessary to do this in the
> `WindowsLaucher` because the current implementation uses the POSIX
> idea of a process hierarchy to list and kill all processes
> associated with a task. We have found this model to not work on
> Windows, and the solution is to use Job Objects.
> 
> Because this is preparation work, it is a straight copy of the
> current "working" implementation. That is, the `PosixLauncher`
> has been copied to create the `WindowsLauncher`, instead of
> the latter deriving the former.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt c09bcde3c14a73ab0b296c400f79f6a775da2470 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the `WindowsLauncher`.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.

> On Feb. 7, 2017, noon, Ilya Pronin wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, line 105
> > <https://reviews.apache.org/r/56362/diff/1/?file=1625893#file1625893line105>
> >
> >     Systemd on Windows? ;)
> 
> Andrew Schwartzmeyer wrote:
>     This iteration is the copy of the existing implementation. It was refactored into the real `WindowsLauncher` in [#56365](https://reviews.apache.org/r/56365/).
> 
> Joseph Wu wrote:
>     You should consider squashing #56365 into this review.  You end up modifying the bulk of this copied code, so the diff-of-a-diff ends up distracting from the review.

I could do that. Most these comments below don't make sense in the context of this patch, which is, as described, a straight copy of the original implementation.


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review164490
-----------------------------------------------------------


On Feb. 7, 2017, 6:54 p.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 7, 2017, 6:54 p.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> The purpose of this is to setup for refactoring the `WindowsLauncher`
> into a `Launcher` that uses Windows' "Job Objects,"
> which are similar to Linux's cgroups, and enable us to reason
> about a group of processes. It is necessary to do this in the
> `WindowsLaucher` because the current implementation uses the POSIX
> idea of a process hierarchy to list and kill all processes
> associated with a task. We have found this model to not work on
> Windows, and the solution is to use Job Objects.
> 
> Because this is preparation work, it is a straight copy of the
> current "working" implementation. That is, the `PosixLauncher`
> has been copied to create the `WindowsLauncher`, instead of
> the latter deriving the former.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt c09bcde3c14a73ab0b296c400f79f6a775da2470 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the `WindowsLauncher`.

Posted by Ilya Pronin <ip...@twopensource.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review164490
-----------------------------------------------------------




src/slave/containerizer/mesos/launcher.cpp 
<https://reviews.apache.org/r/56362/#comment236262>

    I think it would be better to leave `__linux__` check in place. There's no systemd on macOS or FreeBSD.



src/slave/containerizer/mesos/windows_launcher.cpp (line 105)
<https://reviews.apache.org/r/56362/#comment236264>

    Systemd on Windows? ;)


- Ilya Pronin


On Feb. 7, 2017, 2:30 a.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 7, 2017, 2:30 a.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> The purpose of this is to setup for refactoring the `WindowsLauncher`
> into a `Launcher` that uses Windows' "Job Objects,"
> which are similar to Linux's cgroups, and enable us to reason
> about a group of processes. It is necessary to do this in the
> `WindowsLaucher` because the current implementation uses the POSIX
> idea of a process hierarchy to list and kill all processes
> associated with a task. We have found this model to not work on
> Windows, and the solution is to use Job Objects.
> 
> Because this is preparation work, it is a straight copy of the
> current "working" implementation. That is, the `PosixLauncher`
> has been copied to create the `WindowsLauncher`, instead of
> the latter deriving the former.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt c09bcde3c14a73ab0b296c400f79f6a775da2470 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Joseph Wu <jo...@mesosphere.io>.

> On Feb. 9, 2017, 4:24 p.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, line 185
> > <https://reviews.apache.org/r/56362/diff/3/?file=1627948#file1627948line185>
> >
> >     s/container.get().handle/container->handle/
> 
> Andrew Schwartzmeyer wrote:
>     Ah thanks, didn't know `Option` had `operator->()` defined this way. Why don't we use this elsewhere?

The operator wasn't always available.  We first added it to `Try<>` and then to `Option<>`; for the sake of readability.

We do use it in a couple places, and we like new code to use it where appropriate.


- Joseph


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review165027
-----------------------------------------------------------


On Feb. 9, 2017, 10:50 a.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 9, 2017, 10:50 a.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.

> On Feb. 10, 2017, 12:24 a.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, line 148
> > <https://reviews.apache.org/r/56362/diff/3/?file=1627948#file1627948line148>
> >
> >     Ditto about the constructor.

Ditto on the fix.


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review165027
-----------------------------------------------------------


On Feb. 9, 2017, 6:50 p.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 9, 2017, 6:50 p.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.

> On Feb. 10, 2017, 12:24 a.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, lines 59-60
> > <https://reviews.apache.org/r/56362/diff/3/?file=1627948#file1627948line59>
> >
> >     I recall some talk about dis-allowing certain `std::` helpers on the `hashmap` and `hashset` classes.  In which case, we'd need to rethink https://reviews.apache.org/r/56363
> >     
> >     Anyway, for this method, I'd recommend constructing a `hashset` of PIDs and checking/updating this set while recovering.  Because O(N).

Is this really a CPU bottleneck on the agent here? The `PosixLauncher` does the [same O(n) operation](https://github.com/andschwa/mesos/blob/master/src/slave/containerizer/mesos/launcher.cpp#L62) (I point it out because this code is pretty much just a derivation of the former).


> On Feb. 10, 2017, 12:24 a.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, line 78
> > <https://reviews.apache.org/r/56362/diff/3/?file=1627948#file1627948line78>
> >
> >     Since you are assigning the `Container` is this way, you don't actually need to specify the constructor in the header.
> >     
> >     So either remove the constructor, or use it in this file.

I'm not sure about this. I didn't add the constructor until I compiled and _couldn't_ brace initialize without it. That said, I have some default member initializers. Jo, are we using C++11 or C++17?

Oh, I forgot I needed to click publish. This is the error you get with MSVC if you use the brace initializer without a constructor:

```
17>C:\Users\andschwa\src\mesos\src\slave\containerizer\mesos\windows_launcher.cpp(78): error C2440: 'initializing': cannot convert from 'initializer list' to 'mesos::internal::slave::WindowsLauncher::Container'
```

Now trying without member initializers...


> On Feb. 10, 2017, 12:24 a.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, line 162
> > <https://reviews.apache.org/r/56362/diff/3/?file=1627948#file1627948line162>
> >
> >     Can you add a TODO here about how executors will die when the agent dies?

Sure, it has been a subject of much debate :D


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review165027
-----------------------------------------------------------


On Feb. 9, 2017, 6:50 p.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 9, 2017, 6:50 p.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.

> On Feb. 10, 2017, 12:24 a.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, line 185
> > <https://reviews.apache.org/r/56362/diff/3/?file=1627948#file1627948line185>
> >
> >     s/container.get().handle/container->handle/

Ah thanks, didn't know `Option` had `operator->()` defined this way. Why don't we use this elsewhere?


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review165027
-----------------------------------------------------------


On Feb. 9, 2017, 6:50 p.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 9, 2017, 6:50 p.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.

> On Feb. 10, 2017, 12:24 a.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, lines 59-60
> > <https://reviews.apache.org/r/56362/diff/3/?file=1627948#file1627948line59>
> >
> >     I recall some talk about dis-allowing certain `std::` helpers on the `hashmap` and `hashset` classes.  In which case, we'd need to rethink https://reviews.apache.org/r/56363
> >     
> >     Anyway, for this method, I'd recommend constructing a `hashset` of PIDs and checking/updating this set while recovering.  Because O(N).
> 
> Andrew Schwartzmeyer wrote:
>     Is this really a CPU bottleneck on the agent here? The `PosixLauncher` does the [same O(n) operation](https://github.com/andschwa/mesos/blob/master/src/slave/containerizer/mesos/launcher.cpp#L62) (I point it out because this code is pretty much just a derivation of the former).

(I don't mind a better operation; where `n` is `containers.size()` and `p` is number of PIDs to check, one time `O(n)` cache of container PIDs to a hashmap upfront, followed by `O(p)` lookups afterward for `O(p)` instead of `O(p*n)`. But then we should do this for the `PosixLauncher` too.)


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review165027
-----------------------------------------------------------


On Feb. 9, 2017, 6:50 p.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 9, 2017, 6:50 p.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.

> On Feb. 10, 2017, 12:24 a.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, line 78
> > <https://reviews.apache.org/r/56362/diff/3/?file=1627948#file1627948line78>
> >
> >     Since you are assigning the `Container` is this way, you don't actually need to specify the constructor in the header.
> >     
> >     So either remove the constructor, or use it in this file.
> 
> Andrew Schwartzmeyer wrote:
>     I'm not sure about this. I didn't add the constructor until I compiled and _couldn't_ brace initialize without it. That said, I have some default member initializers. Jo, are we using C++11 or C++17?
>     
>     Oh, I forgot I needed to click publish. This is the error you get with MSVC if you use the brace initializer without a constructor:
>     
>     ```
>     17>C:\Users\andschwa\src\mesos\src\slave\containerizer\mesos\windows_launcher.cpp(78): error C2440: 'initializing': cannot convert from 'initializer list' to 'mesos::internal::slave::WindowsLauncher::Container'
>     ```
>     
>     Now trying without member initializers...

Yup. I guess we're strictly C++11, and not say C++14. If I'm understanding [this](http://en.cppreference.com/w/cpp/language/aggregate_initialization) correctly, until C++14 you can't aggregate initialize with default memeber initializers. Fixing.


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review165027
-----------------------------------------------------------


On Feb. 9, 2017, 6:50 p.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 9, 2017, 6:50 p.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Joseph Wu <jo...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review165027
-----------------------------------------------------------




src/slave/containerizer/mesos/windows_launcher.cpp (lines 19 - 26)
<https://reviews.apache.org/r/56362/#comment236868>

    Of these, I think only `process/process.hpp` is actually used.



src/slave/containerizer/mesos/windows_launcher.cpp (lines 59 - 60)
<https://reviews.apache.org/r/56362/#comment236867>

    I recall some talk about dis-allowing certain `std::` helpers on the `hashmap` and `hashset` classes.  In which case, we'd need to rethink https://reviews.apache.org/r/56363
    
    Anyway, for this method, I'd recommend constructing a `hashset` of PIDs and checking/updating this set while recovering.  Because O(N).



src/slave/containerizer/mesos/windows_launcher.cpp (line 78)
<https://reviews.apache.org/r/56362/#comment236864>

    Since you are assigning the `Container` is this way, you don't actually need to specify the constructor in the header.
    
    So either remove the constructor, or use it in this file.



src/slave/containerizer/mesos/windows_launcher.cpp (line 148)
<https://reviews.apache.org/r/56362/#comment236865>

    Ditto about the constructor.



src/slave/containerizer/mesos/windows_launcher.cpp (line 162)
<https://reviews.apache.org/r/56362/#comment236869>

    Can you add a TODO here about how executors will die when the agent dies?



src/slave/containerizer/mesos/windows_launcher.cpp (line 185)
<https://reviews.apache.org/r/56362/#comment236866>

    s/container.get().handle/container->handle/


- Joseph Wu


On Feb. 9, 2017, 10:50 a.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 9, 2017, 10:50 a.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/
-----------------------------------------------------------

(Updated March 27, 2017, 3:44 p.m.)


Review request for mesos, Alex Clemmer and Joseph Wu.


Bugs: MESOS-6892
    https://issues.apache.org/jira/browse/MESOS-6892


Repository: mesos


Description
-------

Instead of deriving `WindowsLauncher` from `PosixLauncher`,
this commit implements a separate `WindowsLauncher` derived
from `Launcher` parallel to the `PosixLauncher`.

This launcher is then refactored to use Windows' "Job Objects," which
are similar to Linux's cgroups, and enable us to reason about a group
of processes associated with a task/container as a "Job Object"
instead of a root PID and the tree containing its children. The latter
is not a reasonable approach on Windows, and has been the source of
subtle bugs.

The Job Object approach creates a named job with a one-to-one mapping
to the containerizer, and assigns the first process started for the
task to the job object. After being assigned, the Windows kernel
ensures all spawned child processes
(specifically those made with the `CreateProcess` system call) are
also assigned to the named job object. Thus this job object can then
be used to query the process group's resource usage, kill the process
group, and set limits on the process group.

So instead of seeing a process group as a tree and referring to it by
the root process's PID, the `WindowsLauncher` sees a process group as
a named Job Object, the same way the Windows kernel sees it. However,
the containerizer code which interacts with the launcher still refers
to a task group by the singular PID, and so we have a sort of shim
which maps the initial PID to the name of the job object. This is a an
unfortunate consequence of the shared containerizer code being
originally written for POSIX-like systems.

This abstraction sets us up for implementing resource usage limits on
the process group as a whole.


Diffs
-----

  src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
  src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
  src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
  src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
  src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
  src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 


Diff: https://reviews.apache.org/r/56362/diff/4/


Testing
-------


Thanks,

Andrew Schwartzmeyer


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.

> On Feb. 25, 2017, 1:24 a.m., Joseph Wu wrote:
> > This is definitely the direction we want to head towards (Job objects, without leaking handles).
> > 
> > But, due to the partial duplication of logic in: https://reviews.apache.org/r/56366/
> > I think we should move much of this logic into libprocess.
> > 
> > Here's the gist of what should be done:
> > 
> > * We'll want a new, Windows-only actor that is created in `process::initialize`.  This will look very similar to the `GarbageCollector` process in `include/process/gc.hpp`.  Something like:
> > ```
> > class JobObjectManager : public Process<JobObjectManager>
> > {
> > public:
> >   JobObjectManager() : ProcessBase("__job_object_manager__") {}
> >   virtual ~JobObjectManager() {}
> > 
> >   // NOTE: Maybe you'll want the actor to create the JobObject itself.
> >   // You could even move the CREATE_JOB parent hook into this file.
> >   void manage(const pid_t pid, const std::string& name, const SharedHandle& handle)
> >   {
> >     objects[pid] = {name, handle};
> >     
> >     process::reap(pid)
> >       .onAny(lambda::bind(&Self::cleanup, lambda::_1, pid));
> >   }
> > 
> > protected:
> >   virtual void cleanup(Future<Option<int>> exit_code, const pid_t pid)
> >   {
> >     CHECK(!exit_code.isPending());
> >     CHECK(!exit_code.isDiscarded());
> > 
> >     Try<Nothing> killJobResult = os::kill_job(objects[pid].handle.get());
> >     CHECK(!killJobResult.isError())
> >       << "Failed to kill job object: " + killJobResult.error();
> > 
> >     objects.erase(pid);
> >   }
> > 
> > private:
> >   struct JobData {
> >     std::string name;
> >     SharedHandle handle;
> >   }
> >   std::map<pid, JobData> objects;
> > };
> > ```
> > * You can either expose the actor's methods via `process.hpp` or via moving the ParentHook into the new actor.
> > * The WindowsLauncher would become a thin wrapper around the new actor.
> > * https://reviews.apache.org/r/56366/ should become much simpler.

Hm, okay, I like your idea. Let's chat and go over the design you're proposing.


> On Feb. 25, 2017, 1:24 a.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, lines 50-62
> > <https://reviews.apache.org/r/56362/diff/4/?file=1630626#file1630626line50>
> >
> >     Erm... saving the set of PIDs in a prior loop guarantees that the `pids.contains(pid)` condition will be met.

containers != containerStates

The containers is what's already tracked in the launcher; the states is what's being recovered from disk.


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review166640
-----------------------------------------------------------


On Feb. 11, 2017, 2:04 a.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 11, 2017, 2:04 a.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.

> On Feb. 25, 2017, 1:24 a.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, lines 50-62
> > <https://reviews.apache.org/r/56362/diff/4/?file=1630626#file1630626line50>
> >
> >     Erm... saving the set of PIDs in a prior loop guarantees that the `pids.contains(pid)` condition will be met.
> 
> Andrew Schwartzmeyer wrote:
>     containers != containerStates
>     
>     The containers is what's already tracked in the launcher; the states is what's being recovered from disk.

s/containerStates/states/g


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review166640
-----------------------------------------------------------


On Feb. 11, 2017, 2:04 a.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 11, 2017, 2:04 a.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Joseph Wu <jo...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review166640
-----------------------------------------------------------



This is definitely the direction we want to head towards (Job objects, without leaking handles).

But, due to the partial duplication of logic in: https://reviews.apache.org/r/56366/
I think we should move much of this logic into libprocess.

Here's the gist of what should be done:

* We'll want a new, Windows-only actor that is created in `process::initialize`.  This will look very similar to the `GarbageCollector` process in `include/process/gc.hpp`.  Something like:
```
class JobObjectManager : public Process<JobObjectManager>
{
public:
  JobObjectManager() : ProcessBase("__job_object_manager__") {}
  virtual ~JobObjectManager() {}

  // NOTE: Maybe you'll want the actor to create the JobObject itself.
  // You could even move the CREATE_JOB parent hook into this file.
  void manage(const pid_t pid, const std::string& name, const SharedHandle& handle)
  {
    objects[pid] = {name, handle};
    
    process::reap(pid)
      .onAny(lambda::bind(&Self::cleanup, lambda::_1, pid));
  }

protected:
  virtual void cleanup(Future<Option<int>> exit_code, const pid_t pid)
  {
    CHECK(!exit_code.isPending());
    CHECK(!exit_code.isDiscarded());

    Try<Nothing> killJobResult = os::kill_job(objects[pid].handle.get());
    CHECK(!killJobResult.isError())
      << "Failed to kill job object: " + killJobResult.error();

    objects.erase(pid);
  }

private:
  struct JobData {
    std::string name;
    SharedHandle handle;
  }
  std::map<pid, JobData> objects;
};
```
* You can either expose the actor's methods via `process.hpp` or via moving the ParentHook into the new actor.
* The WindowsLauncher would become a thin wrapper around the new actor.
* https://reviews.apache.org/r/56366/ should become much simpler.


src/slave/containerizer/mesos/windows_launcher.cpp (lines 50 - 62)
<https://reviews.apache.org/r/56362/#comment238647>

    Erm... saving the set of PIDs in a prior loop guarantees that the `pids.contains(pid)` condition will be met.


- Joseph Wu


On Feb. 10, 2017, 6:04 p.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 10, 2017, 6:04 p.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/
-----------------------------------------------------------

(Updated Feb. 11, 2017, 2:04 a.m.)


Review request for mesos, Alex Clemmer and Joseph Wu.


Changes
-------

Requested changes.


Bugs: MESOS-6892
    https://issues.apache.org/jira/browse/MESOS-6892


Repository: mesos


Description
-------

Instead of deriving `WindowsLauncher` from `PosixLauncher`,
this commit implements a separate `WindowsLauncher` derived
from `Launcher` parallel to the `PosixLauncher`.

This launcher is then refactored to use Windows' "Job Objects," which
are similar to Linux's cgroups, and enable us to reason about a group
of processes associated with a task/container as a "Job Object"
instead of a root PID and the tree containing its children. The latter
is not a reasonable approach on Windows, and has been the source of
subtle bugs.

The Job Object approach creates a named job with a one-to-one mapping
to the containerizer, and assigns the first process started for the
task to the job object. After being assigned, the Windows kernel
ensures all spawned child processes
(specifically those made with the `CreateProcess` system call) are
also assigned to the named job object. Thus this job object can then
be used to query the process group's resource usage, kill the process
group, and set limits on the process group.

So instead of seeing a process group as a tree and referring to it by
the root process's PID, the `WindowsLauncher` sees a process group as
a named Job Object, the same way the Windows kernel sees it. However,
the containerizer code which interacts with the launcher still refers
to a task group by the singular PID, and so we have a sort of shim
which maps the initial PID to the name of the job object. This is a an
unfortunate consequence of the shared containerizer code being
originally written for POSIX-like systems.

This abstraction sets us up for implementing resource usage limits on
the process group as a whole.


Diffs (updated)
-----

  src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
  src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
  src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
  src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
  src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
  src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/56362/diff/


Testing
-------


Thanks,

Andrew Schwartzmeyer


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/
-----------------------------------------------------------

(Updated Feb. 9, 2017, 6:50 p.m.)


Review request for mesos, Alex Clemmer and Joseph Wu.


Changes
-------

Remove a required dependency because Review Bot can't handle it.


Bugs: MESOS-6892
    https://issues.apache.org/jira/browse/MESOS-6892


Repository: mesos


Description
-------

Instead of deriving `WindowsLauncher` from `PosixLauncher`,
this commit implements a separate `WindowsLauncher` derived
from `Launcher` parallel to the `PosixLauncher`.

This launcher is then refactored to use Windows' "Job Objects," which
are similar to Linux's cgroups, and enable us to reason about a group
of processes associated with a task/container as a "Job Object"
instead of a root PID and the tree containing its children. The latter
is not a reasonable approach on Windows, and has been the source of
subtle bugs.

The Job Object approach creates a named job with a one-to-one mapping
to the containerizer, and assigns the first process started for the
task to the job object. After being assigned, the Windows kernel
ensures all spawned child processes
(specifically those made with the `CreateProcess` system call) are
also assigned to the named job object. Thus this job object can then
be used to query the process group's resource usage, kill the process
group, and set limits on the process group.

So instead of seeing a process group as a tree and referring to it by
the root process's PID, the `WindowsLauncher` sees a process group as
a named Job Object, the same way the Windows kernel sees it. However,
the containerizer code which interacts with the launcher still refers
to a task group by the singular PID, and so we have a sort of shim
which maps the initial PID to the name of the job object. This is a an
unfortunate consequence of the shared containerizer code being
originally written for POSIX-like systems.

This abstraction sets us up for implementing resource usage limits on
the process group as a whole.


Diffs
-----

  src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
  src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
  src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
  src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
  src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
  src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/56362/diff/


Testing
-------


Thanks,

Andrew Schwartzmeyer


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/
-----------------------------------------------------------

(Updated Feb. 8, 2017, 9:28 p.m.)


Review request for mesos, Alex Clemmer and Joseph Wu.


Changes
-------

Fix dependencies.


Bugs: MESOS-6892
    https://issues.apache.org/jira/browse/MESOS-6892


Repository: mesos


Description
-------

Instead of deriving `WindowsLauncher` from `PosixLauncher`,
this commit implements a separate `WindowsLauncher` derived
from `Launcher` parallel to the `PosixLauncher`.

This launcher is then refactored to use Windows' "Job Objects," which
are similar to Linux's cgroups, and enable us to reason about a group
of processes associated with a task/container as a "Job Object"
instead of a root PID and the tree containing its children. The latter
is not a reasonable approach on Windows, and has been the source of
subtle bugs.

The Job Object approach creates a named job with a one-to-one mapping
to the containerizer, and assigns the first process started for the
task to the job object. After being assigned, the Windows kernel
ensures all spawned child processes
(specifically those made with the `CreateProcess` system call) are
also assigned to the named job object. Thus this job object can then
be used to query the process group's resource usage, kill the process
group, and set limits on the process group.

So instead of seeing a process group as a tree and referring to it by
the root process's PID, the `WindowsLauncher` sees a process group as
a named Job Object, the same way the Windows kernel sees it. However,
the containerizer code which interacts with the launcher still refers
to a task group by the singular PID, and so we have a sort of shim
which maps the initial PID to the name of the job object. This is a an
unfortunate consequence of the shared containerizer code being
originally written for POSIX-like systems.

This abstraction sets us up for implementing resource usage limits on
the process group as a whole.


Diffs
-----

  src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
  src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
  src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
  src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
  src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
  src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/56362/diff/


Testing
-------


Thanks,

Andrew Schwartzmeyer


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/
-----------------------------------------------------------

(Updated Feb. 8, 2017, 9:11 p.m.)


Review request for mesos, Alex Clemmer and Joseph Wu.


Changes
-------

Squash the copy of the `PosixLauncher` and the refactor into one patch; address some review comments.


Summary (updated)
-----------------

Windows: Create the Windows container launcher.


Bugs: MESOS-6892
    https://issues.apache.org/jira/browse/MESOS-6892


Repository: mesos


Description (updated)
-------

Instead of deriving `WindowsLauncher` from `PosixLauncher`,
this commit implements a separate `WindowsLauncher` derived
from `Launcher` parallel to the `PosixLauncher`.

This launcher is then refactored to use Windows' "Job Objects," which
are similar to Linux's cgroups, and enable us to reason about a group
of processes associated with a task/container as a "Job Object"
instead of a root PID and the tree containing its children. The latter
is not a reasonable approach on Windows, and has been the source of
subtle bugs.

The Job Object approach creates a named job with a one-to-one mapping
to the containerizer, and assigns the first process started for the
task to the job object. After being assigned, the Windows kernel
ensures all spawned child processes
(specifically those made with the `CreateProcess` system call) are
also assigned to the named job object. Thus this job object can then
be used to query the process group's resource usage, kill the process
group, and set limits on the process group.

So instead of seeing a process group as a tree and referring to it by
the root process's PID, the `WindowsLauncher` sees a process group as
a named Job Object, the same way the Windows kernel sees it. However,
the containerizer code which interacts with the launcher still refers
to a task group by the singular PID, and so we have a sort of shim
which maps the initial PID to the name of the job object. This is a an
unfortunate consequence of the shared containerizer code being
originally written for POSIX-like systems.

This abstraction sets us up for implementing resource usage limits on
the process group as a whole.


Diffs (updated)
-----

  src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
  src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
  src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
  src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
  src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
  src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/56362/diff/


Testing
-------


Thanks,

Andrew Schwartzmeyer


Re: Review Request 56362: Windows: Create the Windows container launcher.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.

> On Feb. 8, 2017, 2 a.m., Joseph Wu wrote:
> > src/slave/containerizer/mesos/windows_launcher.cpp, lines 109-127
> > <https://reviews.apache.org/r/56362/diff/2/?file=1626817#file1626817line109>
> >
> >     Why are you removing the CREATE_JOB parent hook (https://reviews.apache.org/r/56368/ ) instead of using it here?
> >     
> >     We may want to use JobObjects for other subprocesses in general, rather than just the launcher.  In which case, having a CREATE_JOB helper would be useful.

This lambda can't be done with a `CREATE_JOB` helper, as it captures `[this, containerId]` in order to associate the `SharedHandle` of the job object with the container in the `WindowsLauncher` containers.


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review164575
-----------------------------------------------------------


On Feb. 8, 2017, 9:11 p.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 8, 2017, 9:11 p.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> This launcher is then refactored to use Windows' "Job Objects," which
> are similar to Linux's cgroups, and enable us to reason about a group
> of processes associated with a task/container as a "Job Object"
> instead of a root PID and the tree containing its children. The latter
> is not a reasonable approach on Windows, and has been the source of
> subtle bugs.
> 
> The Job Object approach creates a named job with a one-to-one mapping
> to the containerizer, and assigns the first process started for the
> task to the job object. After being assigned, the Windows kernel
> ensures all spawned child processes
> (specifically those made with the `CreateProcess` system call) are
> also assigned to the named job object. Thus this job object can then
> be used to query the process group's resource usage, kill the process
> group, and set limits on the process group.
> 
> So instead of seeing a process group as a tree and referring to it by
> the root process's PID, the `WindowsLauncher` sees a process group as
> a named Job Object, the same way the Windows kernel sees it. However,
> the containerizer code which interacts with the launcher still refers
> to a task group by the singular PID, and so we have a sort of shim
> which maps the initial PID to the name of the job object. This is a an
> unfortunate consequence of the shared containerizer code being
> originally written for POSIX-like systems.
> 
> This abstraction sets us up for implementing resource usage limits on
> the process group as a whole.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 3a4ace9c8011ac8eec5067cd085fa7fe4166b9ee 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the `WindowsLauncher`.

Posted by Joseph Wu <jo...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/#review164575
-----------------------------------------------------------




src/slave/containerizer/mesos/windows_launcher.hpp (lines 48 - 55)
<https://reviews.apache.org/r/56362/#comment236341>

    Definitely update this comment :)



src/slave/containerizer/mesos/windows_launcher.cpp (lines 92 - 98)
<https://reviews.apache.org/r/56362/#comment236380>

    Unless there's a good reason, you should just return an Error here if either of these arguments are `Some`.



src/slave/containerizer/mesos/windows_launcher.cpp (lines 105 - 106)
<https://reviews.apache.org/r/56362/#comment236381>

    We're definitely not on systemd... on Windows :D



src/slave/containerizer/mesos/windows_launcher.cpp (lines 109 - 127)
<https://reviews.apache.org/r/56362/#comment236382>

    Why are you removing the CREATE_JOB parent hook (https://reviews.apache.org/r/56368/ ) instead of using it here?
    
    We may want to use JobObjects for other subprocesses in general, rather than just the launcher.  In which case, having a CREATE_JOB helper would be useful.



src/slave/containerizer/mesos/windows_launcher.cpp (line 139)
<https://reviews.apache.org/r/56362/#comment236383>

    This is a no-op on Windows.  The intended behavior is to prevent the child process from exiting if the parent exits.
    
    On Windows, we may eventually want to introduce the opposite type of hook (having the child exit if the parent exits).



src/slave/containerizer/mesos/windows_launcher.cpp (lines 155 - 156)
<https://reviews.apache.org/r/56362/#comment236384>

    The reason for this forward declaration is that `_destroy` is not declared in the WindowsLauncher header.  
    
    You should just declare it.



src/slave/containerizer/mesos/windows_launcher.cpp (lines 203 - 207)
<https://reviews.apache.org/r/56362/#comment236385>

    One newline here.


- Joseph Wu


On Feb. 7, 2017, 10:54 a.m., Andrew Schwartzmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/56362/
> -----------------------------------------------------------
> 
> (Updated Feb. 7, 2017, 10:54 a.m.)
> 
> 
> Review request for mesos, Alex Clemmer and Joseph Wu.
> 
> 
> Bugs: MESOS-6892
>     https://issues.apache.org/jira/browse/MESOS-6892
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Instead of deriving `WindowsLauncher` from `PosixLauncher`,
> this commit implements a separate `WindowsLauncher` derived
> from `Launcher` parallel to the `PosixLauncher`.
> 
> The purpose of this is to setup for refactoring the `WindowsLauncher`
> into a `Launcher` that uses Windows' "Job Objects,"
> which are similar to Linux's cgroups, and enable us to reason
> about a group of processes. It is necessary to do this in the
> `WindowsLaucher` because the current implementation uses the POSIX
> idea of a process hierarchy to list and kill all processes
> associated with a task. We have found this model to not work on
> Windows, and the solution is to use Job Objects.
> 
> Because this is preparation work, it is a straight copy of the
> current "working" implementation. That is, the `PosixLauncher`
> has been copied to create the `WindowsLauncher`, instead of
> the latter deriving the former.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt c09bcde3c14a73ab0b296c400f79f6a775da2470 
>   src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
>   src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
>   src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
>   src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/56362/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andrew Schwartzmeyer
> 
>


Re: Review Request 56362: Windows: Create the `WindowsLauncher`.

Posted by Andrew Schwartzmeyer <an...@schwartzmeyer.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/56362/
-----------------------------------------------------------

(Updated Feb. 7, 2017, 6:54 p.m.)


Review request for mesos, Alex Clemmer and Joseph Wu.


Changes
-------

Add `#ifdef __linux__` guard around `systemd` back.


Bugs: MESOS-6892
    https://issues.apache.org/jira/browse/MESOS-6892


Repository: mesos


Description (updated)
-------

Instead of deriving `WindowsLauncher` from `PosixLauncher`,
this commit implements a separate `WindowsLauncher` derived
from `Launcher` parallel to the `PosixLauncher`.

The purpose of this is to setup for refactoring the `WindowsLauncher`
into a `Launcher` that uses Windows' "Job Objects,"
which are similar to Linux's cgroups, and enable us to reason
about a group of processes. It is necessary to do this in the
`WindowsLaucher` because the current implementation uses the POSIX
idea of a process hierarchy to list and kill all processes
associated with a task. We have found this model to not work on
Windows, and the solution is to use Job Objects.

Because this is preparation work, it is a straight copy of the
current "working" implementation. That is, the `PosixLauncher`
has been copied to create the `WindowsLauncher`, instead of
the latter deriving the former.


Diffs (updated)
-----

  src/CMakeLists.txt c09bcde3c14a73ab0b296c400f79f6a775da2470 
  src/slave/containerizer/mesos/containerizer.cpp d2b4f75a55dbe4746bc2dfc180335fa831a554ef 
  src/slave/containerizer/mesos/launcher.hpp 79f6eea0ee8e564e90b36208672df150dbc5d540 
  src/slave/containerizer/mesos/launcher.cpp 5114c130efbfb252dde1e85c081f5174e66f57af 
  src/slave/containerizer/mesos/windows_launcher.hpp PRE-CREATION 
  src/slave/containerizer/mesos/windows_launcher.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/56362/diff/


Testing
-------


Thanks,

Andrew Schwartzmeyer