Puppet: System Administration Automated

Support

Ticket #662 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

hacky patch for avoiding child hangs

Reported by: wyvern Assigned to: luke
Priority: normal Milestone: fozzie
Component: library Version: 0.22.4
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Attached Patches: Code Complexity: Unknown

Description

(Submitted as requested by Jeff Mc Cune?)

I've been fighting these annoying hangs for a day and a bit and finally have something I believe works. It's not elegant (the approaches I took became steadily more hacky...) but it seems to work for me.

I started using a trimmed version of util.rb:execute, asking it run run "apt-get install osirisd". strace()ing this showed the read() being restarted. The child process had died but puppet was still reading from the pipe.

I tried using readpartial and read_nonblock but these didn't seem to capture the stdout and stderr (no idea why - they worked in the trimmed version but not when run in puppet).

I then tried using pipes and also spawning threads to either do the reads (using readpartial) or to do the Process.waitpid and then close the file descriptor. Again, this worked in the trimmed version but not in puppet (neither stdout or stderr were captured).

Finally in desperation I thought "sod it" and redirected the child process to a temporary file. This appears to work but I've only tried a few simple tests on it.

I've attached two diffs against 0.22.4 - a full diff and a diff excluding whitespace differences.

Attachments

util.rb.diff (4.3 kB) - added by wyvern on 06/12/07 10:10:40.
patch (including whitespace changes)
util.rb.diff.nospace (2.9 kB) - added by wyvern on 06/12/07 10:11:04.
patch (excluding whitespace changes)

Change History

06/12/07 10:10:40 changed by wyvern

  • attachment util.rb.diff added.

patch (including whitespace changes)

06/12/07 10:11:04 changed by wyvern

  • attachment util.rb.diff.nospace added.

patch (excluding whitespace changes)

06/12/07 10:14:13 changed by wyvern

The read hanigng is a ruby problem I _think_ - any of the standalone workaround seemed just wrong (starting extra threads etc) - the fact that they didn't work in puppet was very annoying even so (mainly due to the "\o/ fixed, oh no it's not" consequences) :-)

06/13/07 00:15:50 changed by wyvern

needs output_file.close inserting before the delete (otherwise we leak file descriptors)

06/14/07 01:04:03 changed by luke

  • milestone set to fozzie.

06/18/07 20:13:35 changed by luke

  • status changed from new to closed.
  • resolution set to fixed.

Applied in [2604] and [2605].