Puppet: System Administration Automated

Support

Ticket #903 (closed defect: fixed)

Opened 10 months ago

Last modified 9 months ago

exec type logoutput doesn't work if command failed

Reported by: hrvojehr Assigned to: community
Priority: high Milestone: misspiggy
Component: library Version: 0.23.2
Severity: normal Keywords: logoutput exec
Cc: Triage Stage: Ready for checkin
Attached Patches: Code Complexity: Trivial

Description

logoutput doesn't work in exec type if command failed. Logging only works if command is successful.

Could be done: extending logoutput with a value "only_on_failure".

Patch is quick fix. Basicly I just moved logging code before self.fail.

This is quick patch because problem is now error output from command is displayed before message that command failed.

Attachments

exec.patch (0.9 kB) - added by hrvojehr on 11/14/07 22:24:47.

Change History

11/14/07 22:24:47 changed by hrvojehr

  • attachment exec.patch added.

11/14/07 22:25:40 changed by hrvojehr

  • complexity changed from Unknown to Trivial.
  • milestone set to misspiggy.

11/14/07 22:28:13 changed by hrvojehr

  • priority changed from normal to high.
  • version set to 0.23.2.

11/19/07 09:41:40 changed by DavidS

  • stage changed from Unreviewed to Ready for checkin.

I applied this patch in my repository and added a few tests for the exec type.

This is in the rest/fix-903 branch of my repo at git://git.black.co.at/puppet-bugfixes:

commit 4afbaa6f7042eb1cccc8938ee1ccb53c662ba41c
Author: David Schmitt <david@schmitt.edv-bus.at>
Date:   Sat Nov 17 11:40:15 2007 +0100

    fix #903: add patch from hrvojehr
    
    this moves logging of the command in front of failing from unexpected
    return. This helps very much to debug exec failures.
    
    Additionally I removed the unused local variable "loglevel"

commit 32d9afce4dd732d49a3157ce05f47d6f468569b3
Author: David Schmitt <david@schmitt.edv-bus.at>
Date:   Sat Nov 17 11:37:06 2007 +0100

    tests for #903: fail when no logoutput is generated on failure

11/19/07 10:24:24 changed by DavidS

On top of this, I implemented logoutput => on_failure. I had some troubles implementing the should raise_error stuff in the tests, but the (puppet) functionality is there and tested.

commit 1b78f57284a37e86db2351c34a2bbf22c43f0275
Author: David Schmitt <david@schmitt.edv-bus.at>
Date:   Mon Nov 19 10:21:56 2007 +0100

    Add Exec{ logoutput=> on_failure }
    
    This option only writes the output of the command to the log if the command
    failed.

11/19/07 23:04:22 changed by luke

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

Applied David's patches.