puppetlabs/puppet — pull request #2119 by qralston (2013-12-02 00:33:19+00:00)
Title: (#23320) NetworkManager dispatcher script needs to reload Puppet agent, not restart

Restarting the Puppet agent can easily take longer than 3 seconds on a slow system (e.g., a laptop), because the restart doesn't return until the new Puppet agent forks into the background.

This is a significant problem, because NetworkManager has a hardcoded 3-second timeout that it applies to each dispatcher script it runs. If a dispatcher script takes longer than 3 seconds to execute, NetworkManager forcibly kills the script.

Therefore, to reduce the amount of time it takes the Puppet dispatcher script to run, reload the Puppet agent service instead of restarting it. Reloading sends a SIGHUP to the running Puppet agent and immediately returns, thereby allowing the dispatcher script to exit well before NetworkManager's timeout. (The running Puppet agent will restart upon receiving the SIGHUP, but this restart occurs asynchronously to the execution of the dispatcher script.)

Also, use a simple (and fast) case statement to determine the NetworkManager action, instead of the slower (and bash-specific) regular expression matching.