mojo script swallows stdout

Bug #1468974 reported by Michael Nelson
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Mojo: Continuous Delivery for Juju
Confirmed
Medium
Unassigned

Bug Description

I have some helper manifests/scripts (such as manifests/update-code-asset) which (used to) print to stdout in certain situations. For example, if the CI_RUN env var is not defined, it will automatically detect the current code asset revno, as well as the latest successfully tested asset revno from ci.admin, and print:

Updating code asset from r2036 to r2045. Continue? [y/N]

Now (I assume since the logging changes), any sys.stdout.write isn't visible on the console, which leaves the script looking like it's hung. I've tried using logging.info() instead in my script, which doesn't work either (I assume because mojo is itself running my script via subprocess and doesn't inherit the logging config).

The only work-around I have at the moment is to not depend on any output/input for manifests, and run my script directly (rather than through mojo script).

Revision history for this message
Tom Haddon (mthaddon) wrote :

This does indeed seem to be due to subprocess.check_output vs. subprocess.check_call in line 289 of mojo/phase.py. I'd imagine the best solution for this is to add an "interactive" option to the script phase, and if that's passed, to use subprocess.check_call rather than subprocess.check_output. This would mean you'd lose the ability to log the output, but since you're asking for it to happen interactively that may be okay. There may be some more complicated things we can do with subprocesses to display the prompt but still log everything, but depending on how much of a blocker this is that would be the quickest approach.

Revision history for this message
Nick Moffitt (nick-moffitt) wrote :

We could also just test for a terminal and try to DTRT about logging.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

I'm seeing a related issue, but it seems to me there's two distinct problems here:

1) Mojo swallows stdout / stderr for script phases.
2) stdin isn't connected to script phases.

My problem is with #1 above. My scripts write to stdout to indicate progress, and stderr to give additional debugging information on a failure. If the scripts fail right now, all I get is a generic "this script phase failed" message.

A simple fix here would be to include the script stdout and stderr in the error mesage when the script fails.

A more complex (and complete) fix would be to not capture stdout stderr, but instead allow the script process to inherit mojo's stdout & stderr handles (this would also resolve the issue of stdin not working).

Tom Haddon (mthaddon)
Changed in mojo:
status: New → Confirmed
importance: Undecided → Medium
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.