Unverified Commit 468d5e0c authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #13913 from bgruening/fix_job_stderr

[22.01] Redirect stderr of trap cleanup
parents e1031759 149af62e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -278,11 +278,11 @@ class CommandsBuilder:
        self.append_command("; ".join(c for c in commands if c))

    def capture_stdout_stderr(self, stdout_file, stderr_file):
        trap_command = """trap 'rm "$__out" "$__err"' EXIT"""
        trap_command = """trap 'rm -f "$__out" "$__err"' EXIT"""
        if TRAP_KILL_CONTAINER in self.commands:
            # We need to replace the container kill trap with one that removes the named pipes and kills the container
            self.commands = self.commands.replace(TRAP_KILL_CONTAINER, "")
            trap_command = """trap 'rm "$__out" "$__err" 2> /dev/null || true; _on_exit' EXIT"""
            trap_command = """trap 'rm -f "$__out" "$__err"; _on_exit' EXIT"""
        self.prepend_command(
            f"""__out="${{TMPDIR:-.}}/out.$$" __err="${{TMPDIR:-.}}/err.$$"
mkfifo "$__out" "$__err"
+3 −1
Original line number Diff line number Diff line
@@ -183,7 +183,9 @@ class GalaxyASGIRequest(GalaxyAbstractRequest):

    @property
    def host(self) -> str:
        return str(self.__request.client.host)
        client = self.__request.client
        assert client is not None
        return str(client.host)


class GalaxyASGIResponse(GalaxyAbstractResponse):
+3 −3
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ CAPTURE_AND_REDIRECT = f"{TEE_REDIRECT}{RETURN_CODE_CAPTURE}"
CP_WORK_DIR_OUTPUTS = '; \nif [ -f "foo" ] ; then cp "foo" "bar" ; fi'
TEE_LOG = """__out="${TMPDIR:-.}/out.$$" __err="${TMPDIR:-.}/err.$$"
mkfifo "$__out" "$__err"
trap 'rm "$__out" "$__err"' EXIT
trap 'rm -f "$__out" "$__err"' EXIT
tee -a '../outputs/tool_stdout' < "$__out" &
tee -a '../outputs/tool_stderr' < "$__err" >&2 & """

@@ -53,8 +53,8 @@ class TestCommandFactory(TestCase):
        self.include_work_dir_outputs = False
        self.job_wrapper.command_line = f"{TRAP_KILL_CONTAINER}{MOCK_COMMAND_LINE}"
        expected_command_line = self._surround_command(MOCK_COMMAND_LINE).replace(
            """trap 'rm "$__out" "$__err"' EXIT""",
            """trap 'rm "$__out" "$__err" 2> /dev/null || true; _on_exit' EXIT"""
            """trap 'rm -f "$__out" "$__err"' EXIT""",
            """trap 'rm -f "$__out" "$__err"; _on_exit' EXIT"""
        )
        self.__assert_command_is(expected_command_line)