Notifications from LWRPs: it's getting worse


#1

Now that I got your attention :slight_smile:

I’ve noticed in recent releases of cookbooks a lot of commits to fix
Foodcritic warnings, that’s great and I’m grateful that someone has
spent time working on that.
And then there’s this:

FC017: LWRP does not notify when updated.

That’s a very important one to fix; we all hate when an LWRP doesn’t
notify, it can easily lead to frustrating debugging sessions.
But this is not an acceptable fix:

new_resource.updated_by_last_action(true)

I repeat, it’s almost never the correct thing to do.

I notice because we receive notifications on updated resource on the
company Hipchat.
That’s benign, but it can easily get worse: application servers
restarting on every single run and so on.

As usual there is more than one “correct” way; all the resources in
the base gem get it right, and a lot of cookbooks do too. Those would
be good examples.
If you are working on an LWRP or you take it on yourself to fix an
existing LWRP (and again, I’m grateful if you do), then please take a
bit of time to understand the problem.

As an aside: there are several recipes that have resources that notify
on each run. In my opinion that’s a lesser evil since they are
"implementation details", whereas LWRP are for all intents and
purposes API.

That’s it for today’s rant :slight_smile:

Andrea