lxc-attach does not output stderr any more if stdout is redirected

Bug #1553097 reported by Martin Pitt
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Fix Released
High
Unassigned

Bug Description

With lxc 2.0.0~rc5-0ubuntu1 the autopkgtest LXC runner is still broken (even with bug 1551960 fixed) when stderr is a terminal:

$ adt-run gzip --- lxc -s adt-wily
[...]
adt-run [10:15:45]: ERROR: erroneous package: got 10 lines of results from extract where 4 expected:
gpgv: Signature made Mon 27 Oct 2014 09:48:46 AM CET using RSA key ID BD4CA59E
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./gzip_1.6-4ubuntu1.dsc
Get:1 http://archive.ubuntu.com/ubuntu/ wily/main gzip 1.6-4ubuntu1 (dsc) [1,907 B]
Get:2 http://archive.ubuntu.com/ubuntu/ wily/main gzip 1.6-4ubuntu1 (tar) [1,075 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ wily/main gzip 1.6-4ubuntu1 (diff) [14.9 kB]
/tmp/adt-virt-lxc.shared.xklzp9z7/downtmp/build.ehH/gzip-1.6
gzip
1.6-4ubuntu1
1

Thie first couple of lines are supposed to go to stderr, not stdout. This works if stderr is not a terminal, but a pipe, with e. g. "adt-run -l /dev/null gzip --- lxc -s adt-wily" (where stderr is sent to a pipe which gets tee'ed to both the log file and the real stderr).

This is probably a regression in LXC, and it doesn't happen with older LXC nor LXD nor any other backend. But it might also be some intentional change which autopkgtest needs to be adjusted to, so for now I keep tasks for both projects.

Martin Pitt (pitti)
Changed in autopkgtest (Ubuntu):
status: New → Triaged
importance: Undecided → High
Revision history for this message
Martin Pitt (pitti) wrote :

This is indeed a regression in lxc-attach. Until 2.0.0~rc1 this DTRT:

$ sudo lxc-attach -n adt-virt-lxc-lbmmpf -- sh -c 'echo ERR>&2' >/dev/null
ERR

but not any more with rc5:
$ sudo lxc-attach -n a -- sh -c 'echo ERR>&2' >/dev/null
# (no output)

summary: - latest LXC breaks autopkgtest's LXC runner
+ lxc-attach does not output stderr any more if stdout is redirected
Revision history for this message
Martin Pitt (pitti) wrote :

Given that this seems to be somewhat brittle, would you mind adding some integration tests for lxc-attach for various combinations of stdin/stdout/stderr redirection?

Changed in lxc (Ubuntu):
importance: Undecided → High
status: New → Triaged
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

As I understand the code to work, it should do exactly what pitti wants. Those fds which were not redirected should get a pty allocated, so in your example you should in fact see stderr output.

So I think this is a bug and no new flag should be needed.

Revision history for this message
Christian Brauner (cbrauner) wrote :

Fix proposed (https://github.com/lxc/lxc/pull/873). Tests are included as well.

Changed in lxc (Ubuntu):
status: Triaged → Fix Committed
Changed in lxc (Ubuntu):
status: Fix Committed → Fix Released
no longer affects: autopkgtest (Ubuntu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.