| 902 | |
| 903 | |
| 904 | string createSlaveDirectory( |
| 905 | const string& rootDir, |
| 906 | const SlaveID& slaveId) |
| 907 | { |
| 908 | // `slaveId` should be valid because it's assigned by the master but |
| 909 | // we do a sanity check here before using it to create a directory. |
| 910 | CHECK_NONE(common::validation::validateSlaveID(slaveId)); |
| 911 | |
| 912 | const string directory = getSlavePath(rootDir, slaveId); |
| 913 | |
| 914 | Try<Nothing> mkdir = os::mkdir(directory); |
| 915 | |
| 916 | CHECK_SOME(mkdir) |
| 917 | << "Failed to create agent directory '" << directory << "'"; |
| 918 | |
| 919 | // Remove the previous "latest" symlink. |
| 920 | const string latest = getLatestSlavePath(rootDir); |
| 921 | |
| 922 | if (os::exists(latest)) { |
| 923 | CHECK_SOME(os::rm(latest)) |
| 924 | << "Failed to remove latest symlink '" << latest << "'"; |
| 925 | } |
| 926 | |
| 927 | // Symlink the new slave directory to "latest". |
| 928 | Try<Nothing> symlink = ::fs::symlink(directory, latest); |
| 929 | |
| 930 | CHECK_SOME(symlink) |
| 931 | << "Failed to symlink directory '" << directory |
| 932 | << "' to '" << latest << "'"; |
| 933 | |
| 934 | return directory; |
| 935 | } |
| 936 | |
| 937 | |
| 938 | string createResourceProviderDirectory( |
no test coverage detected