abstractdog commented on code in PR #4268:
URL: https://github.com/apache/hive/pull/4268#discussion_r1177128319


##########
itests/util/src/main/java/org/apache/hadoop/hive/ql/externalDB/AbstractExternalDB.java:
##########
@@ -99,41 +98,52 @@ private ProcessResults runCmd(String[] cmd, long 
secondsToWait)
         reader = new BufferedReader(new 
InputStreamReader(proc.getErrorStream()));
         final StringBuilder errLines = new StringBuilder();
         reader.lines().forEach(s -> errLines.append(s).append('\n'));
-        LOG.info("Result size: " + lines.length() + ";" + errLines.length());
+        LOG.info("Result lines#: {}(stdout);{}(stderr)",lines.length(), 
errLines.length());
         return new ProcessResults(lines.toString(), errLines.toString(), 
proc.exitValue());
     }
 
-    private int runCmdAndPrintStreams(String[] cmd, long secondsToWait)
+    private ProcessResults runCmdAndPrintStreams(String[] cmd, long 
secondsToWait)
             throws InterruptedException, IOException {
         ProcessResults results = runCmd(cmd, secondsToWait);
         LOG.info("Stdout from proc: " + results.stdout);
         LOG.info("Stderr from proc: " + results.stderr);
-        return results.rc;
+        return results;
     }
 
 
     public void launchDockerContainer() throws Exception {
         runCmdAndPrintStreams(buildRmCmd(), 600);
-        if (runCmdAndPrintStreams(buildRunCmd(), 600) != 0) {
+        if (runCmdAndPrintStreams(buildRunCmd(), 600).rc != 0) {
             throw new RuntimeException("Unable to start docker container");
         }
         long startTime = System.currentTimeMillis();
         ProcessResults pr;
         do {
             Thread.sleep(1000);
-            pr = runCmd(buildLogCmd(), 30);
+            pr = runCmdAndPrintStreams(buildLogCmd(), 30);
             if (pr.rc != 0) {
-                throw new RuntimeException("Failed to get docker logs");
+              printDockerEvents();
+              throw new RuntimeException("Failed to get docker logs");
             }
         } while (startTime + MAX_STARTUP_WAIT >= System.currentTimeMillis() && 
!isContainerReady(pr));
         if (startTime + MAX_STARTUP_WAIT < System.currentTimeMillis()) {
-            throw new RuntimeException("Container failed to be ready in " + 
MAX_STARTUP_WAIT/1000 +
-                    " seconds");
+          printDockerEvents();
+          throw new RuntimeException("Container failed to be ready in " + 
MAX_STARTUP_WAIT/1000 +
+                  " seconds, check docker logs output in hive logs");
         }
     }
 
+    public void printDockerEvents() {
+      try {
+        runCmdAndPrintStreams(new String[] { "docker", "events", "--since", 
"24h", "--until", "0s" }, 3);
+      } catch (Exception e) {
+        LOG.info("Error while getting docker events, this was an analytical 
best effort step, no further actions...",

Review Comment:
   ack, I'll edit this one too
   your message makes sense, except that "to resolve the issue" is not 100% 
true, docker events cmd just lists the docker events to make us able to guess 
what happened, so this would be the ideal one:
   ```
   A problem was encountered while attempting to retrieve Docker events (the 
system made an analytical best effort to list the events to reveal the root 
cause). No further actions are necessary.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to