MCPcopy Create free account
hub / github.com/apache/mesos / addExecutor

Method addExecutor

src/slave/slave.cpp:10310–10451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10308
10309
10310Try<Executor*> Framework::addExecutor(
10311 const ExecutorInfo& executorInfo,
10312 bool isGeneratedForCommandTask)
10313{
10314 // Verify that Resource.AllocationInfo is set, if coming
10315 // from a MULTI_ROLE master this will be set, otherwise
10316 // the agent will inject it when receiving the executor.
10317 foreach (const Resource& resource, executorInfo.resources()) {
10318 CHECK(resource.has_allocation_info());
10319 }
10320
10321 // Generate an ID for the executor's container.
10322 // TODO(idownes) This should be done by the containerizer but we need the
10323 // ContainerID to create the executor's directory and generate the secret.
10324 // Consider fixing this since 'launchExecutor()' is handled asynchronously.
10325 ContainerID containerId;
10326 containerId.set_value(id::UUID::random().toString());
10327
10328 Option<string> user = None();
10329
10330#ifndef __WINDOWS__
10331 if (slave->flags.switch_user) {
10332 // The command (either in form of task or executor command) can
10333 // define a specific user to run as. If present, this precedes the
10334 // framework user value. The selected user will have been verified by
10335 // the master at this point through the active ACLs.
10336 // NOTE: The global invariant is that the executor info at this
10337 // point is (1) the user provided task.executor() or (2) a command
10338 // executor constructed by the slave from the task.command().
10339 // If this changes, we need to check the user in both
10340 // task.command() and task.executor().command() below.
10341 user = info.user();
10342 if (executorInfo.command().has_user()) {
10343 user = executorInfo.command().user();
10344 }
10345 }
10346#endif // __WINDOWS__
10347
10348 // Create a directory for the executor.
10349 Try<string> directory = paths::createExecutorDirectory(
10350 slave->flags.work_dir,
10351 slave->info.id(),
10352 id(),
10353 executorInfo.executor_id(),
10354 containerId,
10355 user);
10356
10357 if (directory.isError()) {
10358 return Error(directory.error());
10359 }
10360
10361 Executor* executor = new Executor(
10362 slave,
10363 id(),
10364 executorInfo,
10365 containerId,
10366 directory.get(),
10367 user,

Callers 1

__runMethod · 0.45

Calls 15

randomFunction · 0.85
NoneClass · 0.85
createExecutorDirectoryFunction · 0.85
getExecutorLatestRunPathFunction · 0.85
getExecutorVirtualPathFunction · 0.85
deferFunction · 0.85
userMethod · 0.80
commandMethod · 0.80
checkpointMethod · 0.80
errorMethod · 0.65
ErrorFunction · 0.50
dispatchFunction · 0.50

Tested by

no test coverage detected