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

Function createExecutorDirectory

src/slave/paths.cpp:812–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

810
811
812Try<string> createExecutorDirectory(
813 const string& rootDir,
814 const SlaveID& slaveId,
815 const FrameworkID& frameworkId,
816 const ExecutorID& executorId,
817 const ContainerID& containerId,
818 const Option<string>& user)
819{
820 // These IDs should be valid as they are either assigned by the
821 // master/agent or validated by the master but we do a sanity check
822 // here before using them to create a directory.
823 CHECK_NONE(common::validation::validateSlaveID(slaveId));
824 CHECK_NONE(common::validation::validateFrameworkID(frameworkId));
825 CHECK_NONE(common::validation::validateExecutorID(executorId));
826 CHECK_NONE(slave::validation::container::validateContainerId(containerId));
827
828 const string directory =
829 getExecutorRunPath(rootDir, slaveId, frameworkId, executorId, containerId);
830
831 if (user.isSome()) {
832 LOG(INFO) << "Creating sandbox '" << directory << "'"
833 << " for user '" << user.get() << "'";
834 } else {
835 LOG(INFO) << "Creating sandbox '" << directory << "'";
836 }
837
838 Try<Nothing> mkdir = createSandboxDirectory(directory, user);
839 if (mkdir.isError()) {
840 return Error(
841 "Failed to create executor directory '" + directory + "': " +
842 mkdir.error());
843 }
844
845 // Remove the previous "latest" symlink.
846 const string latest =
847 getExecutorLatestRunPath(rootDir, slaveId, frameworkId, executorId);
848
849 if (os::exists(latest)) {
850 CHECK_SOME(os::rm(latest))
851 << "Failed to remove latest symlink '" << latest << "'";
852 }
853
854 // Symlink the new executor directory to "latest".
855 Try<Nothing> symlink = ::fs::symlink(directory, latest);
856 if (symlink.isError()) {
857 return Error(
858 "Failed to symlink '" + directory + "' to '" + latest + "': " +
859 symlink.error());
860 }
861
862 return directory;
863}
864
865
866// Given a directory path and an optional user, create a directory

Callers 3

TEST_FFunction · 0.85
addExecutorMethod · 0.85
checkpointExecutorMethod · 0.85

Calls 15

validateContainerIdFunction · 0.85
getExecutorRunPathFunction · 0.85
createSandboxDirectoryFunction · 0.85
getExecutorLatestRunPathFunction · 0.85
errorMethod · 0.65
validateSlaveIDFunction · 0.50
validateFrameworkIDFunction · 0.50
validateExecutorIDFunction · 0.50
ErrorFunction · 0.50
existsFunction · 0.50
rmFunction · 0.50
symlinkFunction · 0.50

Tested by 1

TEST_FFunction · 0.68