flush after all resources are synced

43 views
Skip to first unread message

Stefan Schulte

unread,
Mar 5, 2014, 6:54:38 PM3/5/14
to puppe...@googlegroups.com
Hello,

is there a way for a custom provider to define a method that flushes
resources afer *all* resources are processed?

I have a custom type to manage configuration aspects of a specific
application and I need to restart that application for configuration
changes to take effect. If I define a flush method for my provider
instances, I'd end up with multiple restarts in one run if more than
resource is out of sync, but I'd rather just do one restart after the
last resource is processed.

Currently I do the restart with an exec resource and every resource
notifies the exec, which does exactly what I want (zero restarts on no
changes, and one restart if one one or more resources are out of sync).
However I'd rather do without the exec.

Something along these lines might also be useful for the puppetlabs
firewall provider because from a first glance, it calls iptables-save
for every changed resource, so you can also end up with multiple calls
during one puppet run.

-Stefan

Erik Dalén

unread,
Mar 6, 2014, 3:28:51 AM3/6/14
to Puppet Developers
Isn't this what was done in http://projects.puppetlabs.com/issues/3946 ?
So should be available in 3.4.0+




-Stefan

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/5317B93E.6010408%40taunusstein.net.
For more options, visit https://groups.google.com/groups/opt_out.



--
Erik Dalén

Stefan Schulte

unread,
Mar 6, 2014, 2:23:39 PM3/6/14
to puppe...@googlegroups.com
Hi Erik,

On 06.03.2014 09:28, Erik Dalén wrote:
> Isn't this what was done in http://projects.puppetlabs.com/issues/3946 ?
> So should be available in 3.4.0+
>
> Was discussed in this mail
> thread: https://groups.google.com/forum/#!topic/puppet-dev/Iqs5jEGfu_0

thanks for finding the ticket and pull request for me. I have looked
into the implementation but if am not mistaken `post_resource_eval` will
be called on every puppet run (after all resources are evaluated) no
matter whether resources where out of sync or not.

This is not quite what I want, because I only want to restart my
application when one ore more resources have been changed.

-Stefan

badgerious

unread,
Mar 6, 2014, 5:59:11 PM3/6/14
to puppe...@googlegroups.com
Not sure if this will work as expected for your custom type, but a thought might be to set some (provider) class variable in #flush and then, in ::post_resource_eval, check if this variable is set and do the restart (so each flush does no actual work other than setting the flag).

Eric

Trevor Vaughan

unread,
Mar 6, 2014, 8:51:00 PM3/6/14
to puppe...@googlegroups.com
+1 to this idea from Eric.

However, be VERY careful that you don't end up stepping on data across runs. You'll need to clear that variable at each start and, if you use a class variable, you'll need to make sure that they're all unique across ALL types.

Trevor


--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
tvau...@onyxpoint.com

-- This account not approved for unencrypted proprietary information --

Jeff McCune

unread,
Mar 6, 2014, 10:21:19 PM3/6/14
to puppe...@googlegroups.com
I know I'm a little late to the party on this one, but the matter of naming things has occurred to me.  Recently, I've run into a couple of use cases where I could see the need for a callback that's executed after each discrete resource is evaluated.  When I saw, post_resource_eval I thought this might have been what I was thinking about anyway, but then I learned (please correct me if I'm wrong) that post_resource_eval is actually a hook into the point after all resources have been eveluated.

Would it make more sense to name what's currently implemented post_catalog_eval in the event we do implement some hook for each discrete resource?

If so, is it worth renaming it sooner rather than later?

-Jeff

Jeff McCune

unread,
Mar 6, 2014, 10:26:30 PM3/6/14
to puppe...@googlegroups.com
On Thu, Mar 6, 2014 at 7:21 PM, Jeff McCune <je...@puppetlabs.com> wrote:
If so, is it worth renaming it sooner rather than later?

Or is it worth renaming at all? I didn't mean to assume that part. 

-Jeff

Nan Liu

unread,
Mar 6, 2014, 10:36:30 PM3/6/14
to puppe...@googlegroups.com
Yeah, agree with renaming it. I have some horrible monkey patch that close connections post catalog. The rename would clarify since they serve different needs.

Nan

Jeff McCune

unread,
Mar 6, 2014, 11:18:22 PM3/6/14
to puppe...@googlegroups.com
OK, if naming is going to get some discussion then we should probably start a different thread as to not hijack this one.

I'll start that, please reply to the naming discussion at: https://groups.google.com/forum/#!topic/puppet-dev/8j2IjZ1Ilog

Sorry for the temporary hijack.

-Jeff

badgerious

unread,
Mar 7, 2014, 10:37:12 AM3/7/14
to puppe...@googlegroups.com
I should clarify my suggestion to say 'single @ class variable' with an attr_accessor rather than 'double @@ class variable', the former of which avoids some of the complications Trevor mentioned. (You could of course put the variable in any number of globally accessible places).

Eric

Trevor Vaughan

unread,
Mar 7, 2014, 12:52:01 PM3/7/14
to puppe...@googlegroups.com
You'd have to run through the entire catalog of resources in that case. It would certainly work, but I'm not sure if it would actually do what you want.

Trevor


Reply all
Reply to author
Forward
0 new messages