mesos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Till Toenshoff (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (MESOS-1102) Add ability to process::subprocess to run function within child context
Date Sat, 15 Mar 2014 14:45:43 GMT

     [ https://issues.apache.org/jira/browse/MESOS-1102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Till Toenshoff updated MESOS-1102:
----------------------------------

    Description: 
I would like to propose the addition of a way to run a function within the forked child context
to process::subprocess.

The subprocess implementation is already extremely valuable and will allow us to remove many
scattered, similar implementations within mesos once it is flexible enough.

The recent addition (in review) of adding an environment map is just the right step into that
direction.

However, there still are areas, mostly within containerizer specifics that can not be replaced
by the subprocess implementation as is, IMHO because running a function in the child context
is missing. See e.g. /src/slave/containerizer/launcher.cpp, /src/slave/containerizer/mesos_containerizer.cpp
and last but not least the pluggable_containerizer (in review).

My envisioned approach would look something like this:

{noformat}
// Runs the provided command in a subprocess.
// NOTE: Take extra care about the design of the inChild
// lambda as it must not contain any async unsafe code.
Try<Subprocess> subprocess(
    const std::string& command,
    const std::map<std::string, std::string>& env = std::map<std::string, std::string>(),
    const lambda::function<void()>& inChild = NULL);
{noformat}

Example usage:

{noformat}
struct ChildFunction {
  ChildFunction(const string& directory) : directory(directory) {};
  void operator ()()
  {
    if (::chdir(directory) < 0) {
      ABORT("Failed to chdir");
    }
  }
  const string& directory;
};

Try<Subprocess> external = subprocess(
    "foo",
    map<string, string>(),
    ChildFunction("bar");
{noformat}

Please let me know what you think about this or if I was on a wrong track. 

  was:
I would like to propose the addition of a way to run a function within the forked child context
to process::subprocess.

The subprocess implementation is already extremely valuable and will allow us to remove many
scattered, similar implementations within mesos once it is flexible enough.

The recent addition (in review) of adding an environment map is just the right step into that
direction.

However, there still are areas, mostly within containerizer specifics that can not be replaced
by the subprocess implementation as is, IMHO because running a function in the child context
is missing. See e.g. /src/slave/containerizer/launcher.cpp, /src/slave/containerizer/mesos_containerizer.cpp
and last but not least the pluggable_containerizer (in review).

My envisioned approach would look something like this:

<pre>
// Runs the provided command in a subprocess.
// NOTE: Take extra care about the design of the inChild
// lambda as it must not contain any async unsafe code.
Try<Subprocess> subprocess(
    const std::string& command,
    const std::map<std::string, std::string>& env = std::map<std::string, std::string>(),
    const lambda::function<void()>& inChild = NULL);
</pre>

Please let me know what you think about this or if I was on a wrong track. 


> Add ability to process::subprocess to run function within child context
> -----------------------------------------------------------------------
>
>                 Key: MESOS-1102
>                 URL: https://issues.apache.org/jira/browse/MESOS-1102
>             Project: Mesos
>          Issue Type: Improvement
>          Components: libprocess
>    Affects Versions: 0.19.0
>            Reporter: Till Toenshoff
>            Priority: Minor
>              Labels: libprocess, subprocess
>
> I would like to propose the addition of a way to run a function within the forked child
context to process::subprocess.
> The subprocess implementation is already extremely valuable and will allow us to remove
many scattered, similar implementations within mesos once it is flexible enough.
> The recent addition (in review) of adding an environment map is just the right step into
that direction.
> However, there still are areas, mostly within containerizer specifics that can not be
replaced by the subprocess implementation as is, IMHO because running a function in the child
context is missing. See e.g. /src/slave/containerizer/launcher.cpp, /src/slave/containerizer/mesos_containerizer.cpp
and last but not least the pluggable_containerizer (in review).
> My envisioned approach would look something like this:
> {noformat}
> // Runs the provided command in a subprocess.
> // NOTE: Take extra care about the design of the inChild
> // lambda as it must not contain any async unsafe code.
> Try<Subprocess> subprocess(
>     const std::string& command,
>     const std::map<std::string, std::string>& env = std::map<std::string,
std::string>(),
>     const lambda::function<void()>& inChild = NULL);
> {noformat}
> Example usage:
> {noformat}
> struct ChildFunction {
>   ChildFunction(const string& directory) : directory(directory) {};
>   void operator ()()
>   {
>     if (::chdir(directory) < 0) {
>       ABORT("Failed to chdir");
>     }
>   }
>   const string& directory;
> };
> Try<Subprocess> external = subprocess(
>     "foo",
>     map<string, string>(),
>     ChildFunction("bar");
> {noformat}
> Please let me know what you think about this or if I was on a wrong track. 



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message