You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/10/17 01:05:21 UTC
svn commit: r1399037 - in /incubator/mesos/trunk: src/launcher/launcher.cpp
third_party/libprocess/include/stout/net.hpp
third_party/libprocess/include/stout/os.hpp
Author: benh
Date: Tue Oct 16 23:05:20 2012
New Revision: 1399037
URL: http://svn.apache.org/viewvc?rev=1399037&view=rev
Log:
Updated some error messages and bug fixes for net::download.
From: Vinod Kone <vi...@gmail.com>
Review: https://reviews.apache.org/r/7454
Modified:
incubator/mesos/trunk/src/launcher/launcher.cpp
incubator/mesos/trunk/third_party/libprocess/include/stout/net.hpp
incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp
Modified: incubator/mesos/trunk/src/launcher/launcher.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/launcher/launcher.cpp?rev=1399037&r1=1399036&r2=1399037&view=diff
==============================================================================
--- incubator/mesos/trunk/src/launcher/launcher.cpp (original)
+++ incubator/mesos/trunk/src/launcher/launcher.cpp Tue Oct 16 23:05:20 2012
@@ -177,12 +177,14 @@ int ExecutorLauncher::run()
// if requested.
int ExecutorLauncher::fetchExecutors()
{
- cerr << "Fetching executors into " << workDirectory << endl;
+ cerr << "Fetching resources into " << workDirectory << endl;
foreach(const CommandInfo::URI& uri, commandInfo.uris()) {
string resource = uri.value();
bool executable = uri.has_executable() && uri.executable();
+ cerr << "Fetching resource " << resource << endl;
+
// Some checks to make sure using the URI value in shell commands
// is safe. TODO(benh): These should be pushed into the scheduler
// driver and reported to the user.
Modified: incubator/mesos/trunk/third_party/libprocess/include/stout/net.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/stout/net.hpp?rev=1399037&r1=1399036&r2=1399037&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/stout/net.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/stout/net.hpp Tue Oct 16 23:05:20 2012
@@ -21,7 +21,7 @@
// Network utilities.
namespace net {
-// Returns the return code resulting from attempting to download the
+// Returns the HTTP response code resulting from attempting to download the
// specified HTTP or FTP URL into a file at the specified path.
inline Try<int> download(const std::string& url, const std::string& path)
{
@@ -48,6 +48,10 @@ inline Try<int> download(const std::stri
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
FILE* file = fdopen(fd.get(), "w");
+ if (file == NULL) {
+ return Try<int>::error(
+ "Failed to open file handle of '" + path + "': " + strerror(errno));
+ }
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
CURLcode curlErrorCode = curl_easy_perform(curl);
@@ -61,8 +65,9 @@ inline Try<int> download(const std::stri
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
curl_easy_cleanup(curl);
- if (!fclose(file)) {
- return Try<int>::error("Failed to close file handle");
+ if (fclose(file) != 0) {
+ return Try<int>::error(
+ "Failed to close file handle of '" + path + "': " + strerror(errno));
}
return Try<int>::some(code);
Modified: incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp?rev=1399037&r1=1399036&r2=1399037&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/stout/os.hpp Tue Oct 16 23:05:20 2012
@@ -199,8 +199,7 @@ inline Try<std::string> mktemp(const std
return result;
} else {
delete temp;
- return Try<std::string>::error(
- std::string("Cannot create temporary file: ") + strerror(errno));
+ return Try<std::string>::error(strerror(errno));
}
}
@@ -230,8 +229,8 @@ inline Try<Nothing> write(const std::str
Try<int> fd = os::open(path, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IRWXO);
if (fd.isError()) {
- return Try<Nothing>::error("Failed to open file " + path + " : " +
- strerror(errno));
+ return Try<Nothing>::error(
+ "Failed to open file '" + path + "' : " + strerror(errno));
}
Try<Nothing> result = write(fd.get(), message);
@@ -324,8 +323,7 @@ inline Try<std::string> basename(const s
char* result = ::basename(::strcpy(temp, path.c_str()));
if (result == NULL) {
delete temp;
- return Try<std::string>::error(
- "Error getting basename of '" + path + "': " + strerror(errno));
+ return Try<std::string>::error(strerror(errno));
}
std::string s(result);
@@ -340,8 +338,7 @@ inline Try<std::string> dirname(const st
char* result = ::dirname(::strcpy(temp, path.c_str()));
if (result == NULL) {
delete temp;
- return Try<std::string>::error(
- "Error getting dirname of '" + path + "': " + strerror(errno));
+ return Try<std::string>::error(strerror(errno));
}
std::string s(result);
@@ -354,9 +351,7 @@ inline Try<std::string> realpath(const s
{
char temp[PATH_MAX];
if (::realpath(path.c_str(), temp) == NULL) {
- return Try<std::string>::error(
- "Failed to canonicalize '" + path + "' into an absolute path: "
- + strerror(errno));
+ return Try<std::string>::error(strerror(errno));
}
return std::string(temp);
}
@@ -401,7 +396,8 @@ inline Try<long> mtime(const std::string
struct stat s;
if (::stat(path.c_str(), &s) < 0) {
- return Try<long>::error(strerror(errno));
+ return Try<long>::error(
+ "Error invoking stat for '" + path + "': " + strerror(errno));
}
return s.st_mtime;
@@ -447,8 +443,7 @@ inline Try<std::string> mkdtemp(const st
return result;
} else {
delete temp;
- return Try<std::string>::error(
- std::string("Cannot create temporary directory: ") + strerror(errno));
+ return Try<std::string>::error(strerror(errno));
}
}
@@ -526,8 +521,7 @@ inline bool chown(const std::string& use
inline bool chmod(const std::string& path, int mode)
{
if (::chmod(path.c_str(), mode) < 0) {
- PLOG(ERROR) << "Failed to changed the mode of the path " << path
- << " due to " << strerror(errno);
+ PLOG(ERROR) << "Failed to changed the mode of the path '" << path << "'";
return false;
}
@@ -538,7 +532,7 @@ inline bool chmod(const std::string& pat
inline bool chdir(const std::string& directory)
{
if (::chdir(directory.c_str()) < 0) {
- PLOG(ERROR) << "Failed to change directory, chdir";
+ PLOG(ERROR) << "Failed to change directory";
return false;
}
@@ -693,7 +687,8 @@ inline Try<double> usage(const std::stri
{
struct statvfs buf;
if (statvfs(fs.c_str(), &buf) < 0) {
- return Try<double>::error(strerror(errno));
+ return Try<double>::error(
+ "Error invoking statvfs of '" + fs + "': " + strerror(errno));
}
return (double) (buf.f_blocks - buf.f_bfree) / buf.f_blocks;
}
@@ -804,8 +799,7 @@ inline Try<std::list<std::string> > glob
if (status == GLOB_NOMATCH) {
return result; // Empty list.
} else {
- return Try<std::list<std::string> >::error(
- "Error globbing pattern '" + pattern + "':" + strerror(errno));
+ return Try<std::list<std::string> >::error(strerror(errno));
}
}
@@ -864,8 +858,7 @@ inline Try<UTSInfo> uname()
struct utsname name;
if (::uname(&name) < 0) {
- return Try<UTSInfo>::error(
- "Failed to get system information: " + std::string(strerror(errno)));
+ return Try<UTSInfo>::error(strerror(errno));
}
UTSInfo info;