Bug #9167

tagmail report sends email when nothing happens

Added by Spencer Rinehart 9 months ago. Updated about 1 month ago.

Status:Closed Start date:11/28/2011
Priority:Low Due date:
Assignee:Kelsey Hightower % Done:

60%

Category:reports
Target version:2.7.14 Estimated time:4.00 hours
Affected Puppet version:2.6.9 Branch:https://github.com/puppetlabs/puppet/pull/618
Keywords:tagmail
Votes: 11

Description

Since upgrading to the 2.7 series (2.6.8 –> 2.7.3), the tagmail report will send an email with 1 line, shown below, after every run. Before the upgrade, it would only send emails when something occurred during the puppet run.

Steps to reproduce: Enable tagmail report Execute a puppet run that produces no updates

Expected result: No email sent

Actual result: Email sent with line below

Email body: Tue Aug 23 13:11:59 -0400 2011 Puppet (notice): Finished catalog run in 16.60 seconds

tagmail.conf: all: XXXX@XXXX.com


Related issues

related to Puppet - Bug #10199: tagmail sends report when all action items are squelched In Topic Branch Pending Review 10/20/2011
related to Puppet - Feature #11096: Add --quiet to 'puppet inspect' for use with cronjob Accepted 11/30/2011

History

Updated by K Hightower 9 months ago

I am going to try and reproduce this issue on my setup.

Updated by K Hightower 9 months ago

After running my agent:

root@master:~# puppet agent --test
info: Caching catalog for master.hightower.org
info: Applying configuration version '1314140379'
notice: Finished catalog run in 0.02 seconds

I received the following email:

From: report@master.hightower.org
Subject: Puppet Report for master.hightower.org
To: kelsey.hightower@gmail.com
Message-Id: <20110823225940.363555E87B@master.hightower.org>
Date: Tue, 23 Aug 2011 18:59:40 -0400 (EDT)
Tue Aug 23 18:59:39 -0400 2011 Puppet (info): Caching catalog for master.hightower.org
Tue Aug 23 18:59:39 -0400 2011 Puppet (info): Applying configuration version '1314140379'
Tue Aug 23 18:59:39 -0400 2011 Puppet (notice): Finished catalog run in 0.02 seconds

My /etc/puppet/tagmail.conf

all: kelsey.hightower@gmail.com

Updated by Digant Kasundra 9 months ago

This happens because of that message about the configuration version. We get this too and it would be cool if that message was bumped down to debug or didn’t trigger a report. (This throws off our custom reports as well).

Updated by K Hightower 9 months ago

From the comments in the source:

... there is an `all` tag that will always match all log messages.

This could be a change from the from the 2.6.x series. Checking now.

Updated by K Hightower 9 months ago

Code looks the same in the 2.6.x branch as well. If anything shows up in the logs, then it will go out in an email if “all” is used in tagmail.conf

Updated by Spencer Rinehart 9 months ago

Kelsey,

I’ve found that puppet agent —test will always send an email even on 2.6.8, but on 2.6.8, a normal puppet run (not —test) would not send an email for the “Finished catalog run” email. I don’t know if it’s an unintended feature of Faces that the “Finished catalog run” notice gets captured by the report or if there’s something else causing this. I’ve begun hunting through the code to figure out what changed it, and that’s my current best guess but I am not familiar with the codebase.

Updated by James Turnbull 9 months ago

  • Status changed from Unreviewed to Accepted
  • Assignee set to K Hightower

Updated by Lance Albertson 9 months ago

Kelsey Hightower wrote:

Code looks the same in the 2.6.x branch as well. If anything shows up in the logs, then it will go out in an email if “all” is used in tagmail.conf

I’m seeing the same thing on my hosts as well and only seeing the “finished catalog” text.

Wed Aug 24 17:01:46 +0000 2011 //foo.example.org/Puppet (notice): Finished catalog run in 9.62 seconds

Wed Aug 24 17:02:41 +0000 2011 //bar.example.org/Puppet (notice): Finished catalog run in 0.66 seconds

Updated by K Hightower 9 months ago

  • Branch set to https://github.com/khightower/puppet/tree/bug/master/9167

Updated by K Hightower 9 months ago

So my patch results in the follow output in the logs:

Aug 24 23:52:44 master puppet-agent[7485]: Caching catalog for master.lab.org
Aug 24 23:52:44 master puppet-agent[7485]: Applying configuration version '1314244364'
Aug 24 23:52:44 master puppet-agent[7485]: Finished catalog run in 0.03 seconds
Aug 24 23:52:44 master puppet-master[7446]: Handling request: PUT /production/report/master.lab.org
Aug 24 23:52:44 master puppet-master[7446]: Recieved report to process from master.lab.org
Aug 24 23:52:44 master puppet-master[7446]: Processing report from master.lab.org with processor Puppet::Reports::Store
Aug 24 23:52:45 master puppet-master[7446]: Processing report from master.lab.org with processor Puppet::Reports::Http
Aug 24 23:52:45 master puppet-master[7446]: Processing report from master.lab.org with processor Puppet::Reports::Tagmail
Aug 24 23:52:45 master puppet-master[7446]: Not sending tagmail report; no changes

Notice the last line: “Not sending tagmail report; no changes”. This patch also prevents the tagmail report (email) from being sent if the status of the puppet run is “unchanged”.

Tests

I could not figure out a good way to test this patch so I have created a pending example in spec/unit/reports/tagmail_spec.rb.

Updated by K Hightower 9 months ago

  • Status changed from Accepted to In Topic Branch Pending Review

Updated by K Hightower 9 months ago

  • % Done changed from 0 to 90

Updated by Lance Albertson 9 months ago

I tested your patch and I confirmed it works. Thanks!

Updated by K Hightower 9 months ago

  • % Done changed from 90 to 100

Updated by Todd Zullinger 9 months ago

  • Affected Puppet version changed from 2.7.3 to 2.6.9

This bug was introduced between 2.6.8 and 2.6.9. The patch applies cleanly to 2.6.x, so adding it there and merging up would be much appreciated.

I’ve tested this on a few systems and it resolves the problem for me.

Minor nit, the patch introduces some spurious trailing whitespace. It would be great to fix that before merging.

Updated by K Hightower 9 months ago

  • Branch changed from https://github.com/khightower/puppet/tree/bug/master/9167 to https://github.com/khightower/puppet/commits/bug/2.6.x/9167

Todd,

I have made the changes you have suggested and created a patch against the 2.6.x branch.

Updated by K Hightower 8 months ago

  • Branch changed from https://github.com/khightower/puppet/commits/bug/2.6.x/9167 to https://github.com/khightower/puppet/commits/bug/master/9167

Patching this against the master branch, and it should apply cleanly to 2.6.x as well.

Updated by Stefan Schulte 8 months ago

This is a major change in behaviour because you also don’t get any mail if you do all your puppetruns with the noop flag.

Updated by K Hightower 8 months ago

I think I should be able to rework the patch to check if we are in noop as well.

Updated by Jo Rhett 7 months ago

I’m sure everyone knows this, but it’s still an issue with 2.6.11 as well. Quite a shock after upgrading from 2.6.6.

How can I get this patch to apply?

Updated by K Hightower 7 months ago

I should have an updated patch that works for noop sometime tomorrow. At the point I would be happy if you can test this out for me.

Updated by Jo Rhett 7 months ago

I found your patch by googling around a bit, and it works for me. I’d love to see one that supports noop, and will happily test for you.

Updated by K Hightower 7 months ago

Yeah, most of the time you can find the current patch in the “branch” section of the ticket, towards the top.

Updated by Christian Ruppert 7 months ago

Kelsey Hightower wrote:

Yeah, most of the time you can find the current patch in the “branch” section of the ticket, towards the top.

Hm, looks like it doesn’t work for me with 2.7.5.

Updated by John Sellens 7 months ago

We were seeing this as well, and I dodged the problem by making a local change to puppet/reports/tagmail.rb (on the puppet server) to throw those lines away. A terrible kludge, but my mailbox was happier. Hope someone finds this useful. Thanks – cheers! John

% diff -c ./puppet-2.7.5/lib/puppet/reports/tagmail.rb.orig ./puppet-2.7.5/lib/puppet/reports/tagmail.rb
*** ./puppet-2.7.5/lib/puppet/reports/tagmail.rb.orig        Fri Sep 30 13:51:10 2011
--- ./puppet-2.7.5/lib/puppet/reports/tagmail.rb     Thu Oct  6 14:45:01 2011
***************
*** 59,64 ****
--- 59,70 ----
          true if neg.detect do |tag| log.tagged?(tag) end
        end

+       # Now remove any lines like this
+       # Puppet (notice): Finished catalog run in 14.14 seconds
+       messages = messages.reject do |log|
+         true if log.to_s =~ /Finished catalog run in .* seconds/
+       end
+
        if messages.empty?
          Puppet.info "No messages to report to #{emails.join(",")}"
          next

Updated by Kelsey Hightower 6 months ago

So, I am picking this back up today, the goal is to make a patch that address the following:

  • When there are no changes, do not send emails in normal or no-op mode
  • When there are changes, send emails in normal or no-op mode

Updated by Kelsey Hightower 6 months ago

  • Status changed from In Topic Branch Pending Review to Code Insufficient
  • Start date changed from 08/23/2011 to 11/28/2011
  • % Done changed from 100 to 60
  • Estimated time set to 4.00
  • Branch deleted (https://github.com/khightower/puppet/commits/bug/master/9167)

Updated by Kelsey Hightower 6 months ago

Looks like using metrics maybe the best way to detect changes during normal and no-op modes. Checking for resources that are either “Out of Sync”, “Restarted”, or “Changed” should work.

Updated by Kelsey Hightower 5 months ago

  • Assignee changed from K Hightower to Kelsey Hightower

Updated by Stefan Schulte 3 months ago

I hit this bug today as well. And it is not that just

Tue Feb 07 14:57:59 +0100 2012 Puppet (notice): Finished catalog run in 6.78 seconds

Bothers me. All the plugin/fact synchronisation will be put in the report, too. This will trigger a messagestorm whenever I change a plugin.

...
Tue Feb 07 14:57:25 +0100 2012 /File[/var/puppet/lib/puppet]/ensure (notice): created
Tue Feb 07 14:57:25 +0100 2012 /File[/var/puppet/lib/puppet/feature]/ensure (notice): created
Tue Feb 07 14:57:25 +0100 2012 /File[/var/puppet/lib/puppet/feature/nokogiri.rb]/ensure (notice): defined content as '{md5}70eeab3b73df6089eb87f4f760b31bbf'
Tue Feb 07 14:57:25 +0100 2012 /File[/var/puppet/lib/puppet/parser]/ensure (notice): created
Tue Feb 07 14:57:25 +0100 2012 /File[/var/puppet/lib/puppet/parser/functions]/ensure (notice): created
Tue Feb 07 14:57:26 +0100 2012 /File[/var/puppet/lib/puppet/parser/functions/downcase.rb]/ensure (notice): defined content as '{md5}9204a04c2a168375a38d502db8811bbe'
...

Updated by Stefan Schulte 3 months ago

Worth noticing:

  • I’ll not get any messages if a 2.6.1 agent is talking to a 2.6.11 server
  • I’ll get the pluginsync messages if a 2.611 agent is talking to a 2.6.11 server

So a fix must address the agent side and most probably not tagmail.rb itself (which runs on the server side).

Updated by Stefan Schulte 3 months ago

I tracked down the commit that caused the change in behaviour (pluginsync appears in reports and the »Finished catalog run« appears in reports): commit:98ba407

Updated by James Turnbull about 1 month ago

Hey Kelsey – I know you’re really busy but do you have a status on this? Thanks!

Updated by Kelsey Hightower about 1 month ago

  • Assignee deleted (Kelsey Hightower)

We need to group all the tagmail related issues and come up with a design to address all the reported problems. It seems like tagmail is being used for more than just reporting based on tags.

As it stands now the patch I worked up did not solve all the related issues so it was not merged.

Updated by Kelsey Hightower about 1 month ago

  • Assignee set to Kelsey Hightower

Updated by Kelsey Hightower about 1 month ago

  • Status changed from Code Insufficient to In Topic Branch Pending Review
  • Branch set to https://github.com/puppetlabs/puppet/pull/618

Updated by Jeff Weiss about 1 month ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release
  • Target version set to 2.7.14

Updated by Matthaus Litteken about 1 month ago

  • Status changed from Merged - Pending Release to Closed

Released in Puppet 2.7.14rc1

Also available in: Atom PDF