This is an automated email from the ASF dual-hosted git repository.

abudnik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new 5cc10d6  Added URI to failure messages in URI fetcher plugins.
5cc10d6 is described below

commit 5cc10d680f85570a0ce1bf695484f5ff7271e1a8
Author: Andrei Budnik <abud...@apache.org>
AuthorDate: Mon Jun 8 14:16:17 2020 +0200

    Added URI to failure messages in URI fetcher plugins.
    
    Review: https://reviews.apache.org/r/72575
---
 src/uri/fetchers/curl.cpp   | 26 +++++++++++++++-----------
 src/uri/fetchers/docker.cpp | 37 +++++++++++++++++++++----------------
 2 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/src/uri/fetchers/curl.cpp b/src/uri/fetchers/curl.cpp
index 1796620..1e6b382 100644
--- a/src/uri/fetchers/curl.cpp
+++ b/src/uri/fetchers/curl.cpp
@@ -153,49 +153,53 @@ Future<Nothing> CurlFetcherPlugin::fetch(
       s->status(),
       io::read(s->out().get()),
       io::read(s->err().get()))
-    .then([](const tuple<
+    .then([uri](const tuple<
         Future<Option<int>>,
         Future<string>,
         Future<string>>& t) -> Future<Nothing> {
       const Future<Option<int>>& status = std::get<0>(t);
       if (!status.isReady()) {
         return Failure(
-            "Failed to get the exit status of the curl subprocess: " +
+            "Failed to get the exit status of the curl subprocess for '" +
+            stringify(uri) + "': " +
             (status.isFailed() ? status.failure() : "discarded"));
       }
 
       if (status->isNone()) {
-        return Failure("Failed to reap the curl subprocess");
+        return Failure("Failed to reap the curl subprocess for '" +
+                       stringify(uri) + "'");
       }
 
       if (status->get() != 0) {
         const Future<string>& error = std::get<2>(t);
         if (!error.isReady()) {
           return Failure(
-              "Failed to perform 'curl'. Reading stderr failed: " +
+              "Failed to perform 'curl' for '" + stringify(uri) +
+              "'. Reading stderr failed: " +
               (error.isFailed() ? error.failure() : "discarded"));
         }
 
-        return Failure("Failed to perform 'curl': " + error.get());
+        return Failure("Failed to perform 'curl' for '" + stringify(uri) +
+                       "': " + error.get());
       }
 
       const Future<string>& output = std::get<1>(t);
       if (!output.isReady()) {
         return Failure(
-            "Failed to read stdout from 'curl': " +
-            (output.isFailed() ? output.failure() : "discarded"));
+            "Failed to read stdout from 'curl' for '" + stringify(uri) +
+            "': " + (output.isFailed() ? output.failure() : "discarded"));
       }
 
       // Parse the output and get the HTTP response code.
       Try<int> code = numify<int>(output.get());
       if (code.isError()) {
-        return Failure("Unexpected output from 'curl': " + output.get());
+        return Failure("Unexpected output from 'curl' for '" + stringify(uri) +
+                       "': " + output.get());
       }
 
       if (code.get() != http::Status::OK) {
-        return Failure(
-            "Unexpected HTTP response code: " +
-            http::Status::string(code.get()));
+        return Failure("Unexpected HTTP response code for '" + stringify(uri) +
+                       "': " + http::Status::string(code.get()));
       }
 
       return Nothing();
diff --git a/src/uri/fetchers/docker.cpp b/src/uri/fetchers/docker.cpp
index 09feb68..ed71495 100644
--- a/src/uri/fetchers/docker.cpp
+++ b/src/uri/fetchers/docker.cpp
@@ -170,36 +170,38 @@ static Future<http::Response> curl(
       s->status(),
       io::read(s->out().get()),
       io::read(s->err().get()))
-    .then([](const tuple<
+    .then([uri](const tuple<
         Future<Option<int>>,
         Future<string>,
         Future<string>>& t) -> Future<http::Response> {
       const Future<Option<int>>& status = std::get<0>(t);
       if (!status.isReady()) {
         return Failure(
-            "Failed to get the exit status of the curl subprocess: " +
-            (status.isFailed() ? status.failure() : "discarded"));
+            "Failed to get the exit status of the curl subprocess for '" +
+            uri + "': " + (status.isFailed() ? status.failure() : 
"discarded"));
       }
 
       if (status->isNone()) {
-        return Failure("Failed to reap the curl subprocess");
+        return Failure("Failed to reap the curl subprocess for '" + uri + "'");
       }
 
       if (status->get() != 0) {
         const Future<string>& error = std::get<2>(t);
         if (!error.isReady()) {
           return Failure(
-              "Failed to perform 'curl'. Reading stderr failed: " +
+              "Failed to perform 'curl' for '" + uri +
+              "'. Reading stderr failed: " +
               (error.isFailed() ? error.failure() : "discarded"));
         }
 
-        return Failure("Failed to perform 'curl': " + error.get());
+        return Failure("Failed to perform 'curl' for '" + uri +
+                       "': " + error.get());
       }
 
       const Future<string>& output = std::get<1>(t);
       if (!output.isReady()) {
         return Failure(
-            "Failed to read stdout from 'curl': " +
+            "Failed to read stdout from 'curl' for '" + uri + "': " +
             (output.isFailed() ? output.failure() : "discarded"));
       }
 
@@ -303,29 +305,31 @@ static Future<int> download(
       const Future<Option<int>>& status = std::get<0>(t);
       if (!status.isReady()) {
         return Failure(
-            "Failed to get the exit status of the curl subprocess: " +
-            (status.isFailed() ? status.failure() : "discarded"));
+            "Failed to get the exit status of the curl subprocess for '" + uri 
+
+            "': " + (status.isFailed() ? status.failure() : "discarded"));
       }
 
       if (status->isNone()) {
-        return Failure("Failed to reap the curl subprocess");
+        return Failure("Failed to reap the curl subprocess for '" + uri + "'");
       }
 
       if (status->get() != 0) {
         const Future<string>& error = std::get<2>(t);
         if (!error.isReady()) {
           return Failure(
-              "Failed to perform 'curl'. Reading stderr failed: " +
+              "Failed to perform 'curl' for '" + uri +
+              "'. Reading stderr failed: " +
               (error.isFailed() ? error.failure() : "discarded"));
         }
 
-        return Failure("Failed to perform 'curl': " + error.get());
+        return Failure("Failed to perform 'curl' for '" + uri +
+                       "': " + error.get());
       }
 
       const Future<string>& output = std::get<1>(t);
       if (!output.isReady()) {
         return Failure(
-            "Failed to read stdout from 'curl': " +
+            "Failed to read stdout from 'curl' for '" + uri + "': " +
             (output.isFailed() ? output.failure() : "discarded"));
       }
 
@@ -335,14 +339,15 @@ static Future<int> download(
       vector<string> tokens = strings::tokenize(output.get(), "\n", 2);
 #endif // __WINDOWS__
       if (tokens.empty()) {
-        return Failure("Unexpected 'curl' output: " + output.get());
+        return Failure("Unexpected 'curl' output for '" + uri +
+                       "': " + output.get());
       }
 
       // Parse the output and get the HTTP response code.
       Try<int> code = numify<int>(tokens[0]);
       if (code.isError()) {
-        return Failure(
-            "Unexpected HTTP response code from 'curl': " + tokens[0]);
+        return Failure("Unexpected HTTP response code from 'curl' for '" + uri 
+
+                       "': " + tokens[0]);
       }
 
       // If there are two tokens, it means that the redirect url

Reply via email to