You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mesos.apache.org by Wenzhao Zhang <wz...@ncsu.edu> on 2017/06/05 19:17:29 UTC

What is the scheduler for the Command Executor

Hi, All:

I'm studying Mesos code, become very confused about the internal working
flow of executing a simple docker image,
such as  "mesos-execute  --master=XXX  --containerizer=docker  --name=test
 --docker_image=XXX --shell=false".
I believe "mesos-1.2.0/src/cli/*execute.cpp*" is the implementation of this
"mesos-execute", which is called "Command Executor" in the official
document.

I see "*execute.cpp*" internally setups a "CommandScheduler", which has a
"received()" function that listens for events from the master. If it
receives an "*Event::OFFERS*", it will start the procedure of executing the
tasks on the offered resources (slaves).

However, I cannot find exactly where is the resource offered to the client
executable.
I see there is an "offer()" function in "mesos-1.2.0/src/master/*master.cpp*".
But it sends a "*ResourceOffersMessage*", not an event, and no transforming
the event to a message.
I find that only "mesos-1.2.0/src/sched/*sched.cpp*" can receive and
process this type of message. But I don't see how is "*sched.cpp*" used in
other code....

So, I cannot find the exact workflow of sending the offered resource (from
master), to the Command Executor.  What's the scheduler for this Command
Executor?
Could someone help me to understand?

Thanks

Re: What is the scheduler for the Command Executor

Posted by Vinod Kone <vi...@apache.org>.
Hey Wenzhao.

Sorry for the delay in response to your earlier email. Looks like this
email is a duplicate of that, so I'll just answer this one. Please feel
free to ask further questions on this email thread.

I'm studying Mesos code, become very confused about the internal working
> flow of executing a simple docker image,
> such as  "mesos-execute  --master=XXX  --containerizer=docker  --name=test
>  --docker_image=XXX --shell=false".
> I believe "mesos-1.2.0/src/cli/*execute.cpp*" is the implementation of
> this "mesos-execute", which is called "Command Executor" in the official
> document.
>

Your understanding is partially correct. `cli/execute.cpp` which gets
compiled into `mesos-execute` is a scheduler. It is responsible for
registering with mesos master and launching tasks. `mesos-execute` uses
either 1) command executor 2) docker executor or 3) default executor
depending on the arguments passed to it to execute the tasks. For running a
simple docker image 2) is typically used.



> I see "*execute.cpp*" internally setups a "CommandScheduler", which has a
> "received()" function that listens for events from the master. If it
> receives an "*Event::OFFERS*", it will start the procedure of executing
> the tasks on the offered resources (slaves).
>
> However, I cannot find exactly where is the resource offered to the client
> executable.
> I see there is an "offer()" function in "mesos-1.2.0/src/master/
> *master.cpp*". But it sends a "*ResourceOffersMessage*", not an event,
> and no transforming the event to a message.
>

Master currently supports old (v0; that understand `ResourceOffersMessage`
for example) and new (v1; that understand `Event::OFFERS` for example)
schedulers.

The transformation/evolution from `ResourceOffersMessage` to
`Event::Offers` (for new schedulers) happens in
https://github.com/apache/mesos/blob/1.2.0/src/master/master.hpp#L289 .

For more info see:
http://mesos.apache.org/documentation/latest/scheduler-http-api/


> I find that only "mesos-1.2.0/src/sched/*sched.cpp*" can receive and
> process this type of message. But I don't see how is "*sched.cpp*" used
> in other code....
>

`mesos-execute` uses the v1 Mesos scheduler library to send Calls and
receive Events. The code for that is in scheduler/scheduler.cpp
<https://github.com/apache/mesos/blob/1.2.0/src/scheduler/scheduler.cpp>.
sched.cpp is used by old v0 schedulers.



> So, I cannot find the exact workflow of sending the offered resource (from
> master), to the Command Executor.  What's the scheduler for this Command
> Executor?
> Could someone help me to understand?
>

As described above, master sends offers to CommandScheduler. Command
scheduler then launches command executor or docker executor or default
executor depending on the args.

Hope that helps,

Vinod