[ 
https://issues.apache.org/jira/browse/BEAM-8015?focusedWorklogId=301898&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-301898
 ]

ASF GitHub Bot logged work on BEAM-8015:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 27/Aug/19 11:32
            Start Date: 27/Aug/19 11:32
    Worklog Time Spent: 10m 
      Work Description: mxm commented on pull request #9389: [BEAM-8015] Get 
logs from Docker containers
URL: https://github.com/apache/beam/pull/9389#discussion_r318029522
 
 

 ##########
 File path: 
runners/java-fn-execution/src/main/java/org/apache/beam/runners/fnexecution/environment/DockerCommand.java
 ##########
 @@ -134,10 +148,41 @@ public void killContainer(String containerId)
     runShortCommand(Arrays.asList(dockerExecutable, "kill", containerId));
   }
 
-  /** Run the given command invocation and return stdout as a String. */
+  /**
+   * Removes docker container with container id.
+   *
+   * @throws IOException if an IOException occurs, or if the given container 
id either does not
+   *     exist or is still running
+   */
+  public void removeContainer(String containerId)
+      throws IOException, TimeoutException, InterruptedException {
+    checkArgument(containerId != null);
+    checkArgument(
+        CONTAINER_ID_PATTERN.matcher(containerId).matches(),
+        "Container ID must be a 64-character hexadecimal string");
+    runShortCommand(Arrays.asList(dockerExecutable, "rm", containerId));
+  }
+
   private String runShortCommand(List<String> invocation)
       throws IOException, TimeoutException, InterruptedException {
+    return runShortCommand(invocation, false, "");
+  }
+
+  /**
+   * Runs a command, blocks until {@link DockerCommand#commandTimeout} has 
elapsed, then returns the
+   * command's output.
+   *
+   * @param invocation command and arguments to be run
+   * @param redirectErrorStream if true, redirect stderr of the process to its 
stdout
+   * @param delimiter used for separating output lines
+   * @return stdout of the command, including stderr if {@code 
redirectErrorStream} is true
+   * @throws TimeoutException if command has not finished by {@link 
DockerCommand#commandTimeout}
+   */
+  private String runShortCommand(
+      List<String> invocation, boolean redirectErrorStream, CharSequence 
delimiter)
+      throws IOException, TimeoutException, InterruptedException {
     ProcessBuilder pb = new ProcessBuilder(invocation);
+    pb.redirectErrorStream(redirectErrorStream);
 
 Review comment:
   Had to go and look at the entire function to understand your changes..
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 301898)
    Time Spent: 3h 10m  (was: 3h)

> Get logs for SDK worker Docker containers
> -----------------------------------------
>
>                 Key: BEAM-8015
>                 URL: https://issues.apache.org/jira/browse/BEAM-8015
>             Project: Beam
>          Issue Type: Improvement
>          Components: java-fn-execution
>            Reporter: Kyle Weaver
>            Assignee: Kyle Weaver
>            Priority: Major
>          Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> Currently, when SDK worker containers fail to start up properly, an exception 
> is thrown that provides no information about what happened. We can improve 
> debugging by keeping containers around long enough to log their logs before 
> removing them.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to