Ill-formed redirection of stderr to stdout in sub-processes #485

Open
opened 2021-12-30 22:17:58 +00:00 by Alexander-Shukaev · 1 comment

What I'm trying to do and why

Say, having a custom ssh_command, which can print errors to stderr (ssh can as well, but that's easier to reproduce).

Steps to reproduce (if a bug)

Run borgmatic ... info with a custom ssh_command that prints errors to stderr.

Actual behavior (if a bug)

Notice how borgmatic is spewing regular stdout output of info together with errors from ssh_command, i.e. them not being segregated to stderr, even though the invoked subprocess HAD written them to stderr in the first place.

Expected behavior (if a bug)

Redirections to output file descriptors stdout and stderr should be properly bound in order to naturally segregate outputs in a logical manner, not just for borgmatic itself but also for any sub-processes that it invokes.

Environment

borgmatic version: 1.5.21

Borg version: 1.1.17

Python version: 3.10.1

#### What I'm trying to do and why Say, having a custom `ssh_command`, which can print errors to `stderr` (`ssh` can as well, but that's easier to reproduce). #### Steps to reproduce (if a bug) Run `borgmatic ... info` with a custom `ssh_command` that prints errors to `stderr`. #### Actual behavior (if a bug) Notice how `borgmatic` is spewing regular `stdout` output of `info` together with errors from `ssh_command`, i.e. them not being segregated to `stderr`, even though the invoked subprocess HAD written them to `stderr` in the first place. #### Expected behavior (if a bug) Redirections to output file descriptors `stdout` and `stderr` should be properly bound in order to naturally segregate outputs in a logical manner, not just for `borgmatic` itself but also for any sub-processes that it invokes. #### Environment **borgmatic version:** 1.5.21 **Borg version:** 1.1.17 **Python version:** 3.10.1
Owner

Sorry for the delay here. I looked at the borgmatic code for this, and it appears it's very intentionally sending sub-process stderr to borgmatic stdout for simplicity. Everything gets plumbed through Python's logging system, and where the logs go (stdout or stderr) depends entirely on the level of each individual log. (Error and critical logs end up on stderr, while other log levels go to stderr.) So "fixing" this would probably entail elevating all sub-process stderr output to borgmatic error logs. That way, they'd get logged back to stderr.

Sorry for the delay here. I looked at the borgmatic code for this, and it appears it's very intentionally sending sub-process stderr to borgmatic stdout for simplicity. Everything gets plumbed through Python's logging system, and where the logs go (stdout or stderr) depends entirely on the level of each individual log. (Error and critical logs end up on stderr, while other log levels go to stderr.) So "fixing" this would probably entail elevating all sub-process stderr output to borgmatic error logs. That way, they'd get logged back to stderr.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#485
No description provided.