Merge lp:~mabac/launchpad-work-items-tracker/better-error-contacts into lp:~linaro-automation/launchpad-work-items-tracker/linaro

Proposed by Mattias Backman
Status: Merged
Merged at revision: 331
Proposed branch: lp:~mabac/launchpad-work-items-tracker/better-error-contacts
Merge into: lp:~linaro-automation/launchpad-work-items-tracker/linaro
Diff against target: 75 lines (+22/-12)
2 files modified
collect (+12/-12)
lpworkitems/error_collector.py (+10/-0)
To merge this branch: bzr merge lp:~mabac/launchpad-work-items-tracker/better-error-contacts
Reviewer Review Type Date Requested Status
Linaro Infrastructure Pending
Review via email: mp+91410@code.launchpad.net

Description of the change

Hi,

This branch changes the format of the config file so that we specify contacts for receiving error emails per project.

The current way is to match a blueprint name with a regexp from the config file to find out where to send those emails. This does miss quite a few errors which we instead see in the log files and email to the Infrastructure errors list.

There is a corresponding config file in lp:~mabac/launchpad-work-items-tracker/better-config

Thanks,

Mattias

To post a comment you must log in.
Revision history for this message
Guilherme Salgado (salgado) wrote :

Yay! Thanks for working on this, Mattias.

On 03/02/12 08:05, Mattias Backman wrote:
>
> === modified file 'collect'
> --- collect 2011-12-15 18:37:53 +0000
> +++ collect 2012-02-03 11:04:28 +0000
> @@ -667,9 +667,10 @@
> def send_error_mails(cfg):
> '''Send data_errors to contacts.
>
> - Data error contacts are defined in the configuration in the "error_contact"
> - map (which assigns a regexp over spec names to a list of email addresses).
> - If no match is found, the error goes to stderr.
> + Data error contacts are defined in the configuration in the
> + "project_notification_addresses" map (which assigns project names to a list
> + of email addresses). If no address list for a project is found, the error
> + goes to stderr.

I wonder if we should make the contact address required...

The rest looks pretty good; can't wait to stop receiving all those
warnings on infra-errors!

Revision history for this message
Mattias Backman (mabac) wrote :

On Fri, Feb 3, 2012 at 1:52 PM, Guilherme Salgado
<email address hidden> wrote:
> Yay!  Thanks for working on this, Mattias.

No problem. I'm also tired of getting spam about typos. ;)

>
> On 03/02/12 08:05, Mattias Backman wrote:
>>
>> === modified file 'collect'
>> --- collect   2011-12-15 18:37:53 +0000
>> +++ collect   2012-02-03 11:04:28 +0000
>> @@ -667,9 +667,10 @@
>>  def send_error_mails(cfg):
>>      '''Send data_errors to contacts.
>>
>> -    Data error contacts are defined in the configuration in the "error_contact"
>> -    map (which assigns a regexp over spec names to a list of email addresses).
>> -    If no match is found, the error goes to stderr.
>> +    Data error contacts are defined in the configuration in the
>> +    "project_notification_addresses" map (which assigns project names to a list
>> +    of email addresses). If no address list for a project is found, the error
>> +    goes to stderr.
>
> I wonder if we should make the contact address required...

Umm, yes we shouldn't have project groups without contact addresses.
But I'd hate to break the update because of a bad config, so I'd
prefer not to bail on it. Do you think we can handle this when
reviewing config changes?

>
> The rest looks pretty good; can't wait to stop receiving all those
> warnings on infra-errors!
>
>
> --
> https://code.launchpad.net/~mabac/launchpad-work-items-tracker/better-error-contacts/+merge/91410
> You are the owner of lp:~mabac/launchpad-work-items-tracker/better-error-contacts.

Revision history for this message
Guilherme Salgado (salgado) wrote :

On 03/02/12 11:28, Mattias Backman wrote:
> On Fri, Feb 3, 2012 at 1:52 PM, Guilherme Salgado
> <email address hidden> wrote:
>> Yay! Thanks for working on this, Mattias.
>
> No problem. I'm also tired of getting spam about typos. ;)
>
>>
>> On 03/02/12 08:05, Mattias Backman wrote:
>>>
>>> === modified file 'collect'
>>> --- collect 2011-12-15 18:37:53 +0000
>>> +++ collect 2012-02-03 11:04:28 +0000
>>> @@ -667,9 +667,10 @@
>>> def send_error_mails(cfg):
>>> '''Send data_errors to contacts.
>>>
>>> - Data error contacts are defined in the configuration in the "error_contact"
>>> - map (which assigns a regexp over spec names to a list of email addresses).
>>> - If no match is found, the error goes to stderr.
>>> + Data error contacts are defined in the configuration in the
>>> + "project_notification_addresses" map (which assigns project names to a list
>>> + of email addresses). If no address list for a project is found, the error
>>> + goes to stderr.
>>
>> I wonder if we should make the contact address required...
>
> Umm, yes we shouldn't have project groups without contact addresses.
> But I'd hate to break the update because of a bad config, so I'd
> prefer not to bail on it. Do you think we can handle this when
> reviewing config changes?

We don't have config changes too often, do we? And in most cases I've
seen they'd be just a matter of extending the list of projects of an
existing class, so wouldn't break anything. We could also add a small
test script to the config branch, just to do some sanity checking, but
that we can probably save for later.

Revision history for this message
Mattias Backman (mabac) wrote :

On Fri, Feb 3, 2012 at 3:52 PM, Guilherme Salgado
<email address hidden> wrote:
> On 03/02/12 11:28, Mattias Backman wrote:
>> On Fri, Feb 3, 2012 at 1:52 PM, Guilherme Salgado
>> <email address hidden> wrote:
>>> Yay!  Thanks for working on this, Mattias.
>>
>> No problem. I'm also tired of getting spam about typos. ;)
>>
>>>
>>> On 03/02/12 08:05, Mattias Backman wrote:
>>>>
>>>> === modified file 'collect'
>>>> --- collect   2011-12-15 18:37:53 +0000
>>>> +++ collect   2012-02-03 11:04:28 +0000
>>>> @@ -667,9 +667,10 @@
>>>>  def send_error_mails(cfg):
>>>>      '''Send data_errors to contacts.
>>>>
>>>> -    Data error contacts are defined in the configuration in the "error_contact"
>>>> -    map (which assigns a regexp over spec names to a list of email addresses).
>>>> -    If no match is found, the error goes to stderr.
>>>> +    Data error contacts are defined in the configuration in the
>>>> +    "project_notification_addresses" map (which assigns project names to a list
>>>> +    of email addresses). If no address list for a project is found, the error
>>>> +    goes to stderr.
>>>
>>> I wonder if we should make the contact address required...
>>
>> Umm, yes we shouldn't have project groups without contact addresses.
>> But I'd hate to break the update because of a bad config, so I'd
>> prefer not to bail on it. Do you think we can handle this when
>> reviewing config changes?
>
> We don't have config changes too often, do we?  And in most cases I've
> seen they'd be just a matter of extending the list of projects of an
> existing class, so wouldn't break anything. We could also add a small
> test script to the config branch, just to do some sanity checking, but
> that we can probably save for later.

I was actually thinking that we should have some validator script.
Didn't have time to add that now though.

We're testing the changes on staging atm:
http://status.linaro.org/staging/update.log.txt

>
>
> --
> https://code.launchpad.net/~mabac/launchpad-work-items-tracker/better-error-contacts/+merge/91410
> You are the owner of lp:~mabac/launchpad-work-items-tracker/better-error-contacts.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'collect'
--- collect 2011-12-15 18:37:53 +0000
+++ collect 2012-02-03 11:04:28 +0000
@@ -667,9 +667,10 @@
667def send_error_mails(cfg):667def send_error_mails(cfg):
668 '''Send data_errors to contacts.668 '''Send data_errors to contacts.
669669
670 Data error contacts are defined in the configuration in the "error_contact"670 Data error contacts are defined in the configuration in the
671 map (which assigns a regexp over spec names to a list of email addresses).671 "project_notification_addresses" map (which assigns project names to a list
672 If no match is found, the error goes to stderr.672 of email addresses). If no address list for a project is found, the error
673 goes to stderr.
673 '''674 '''
674 global error_collector675 global error_collector
675676
@@ -678,15 +679,14 @@
678679
679 dbg('mailing %i data errors' % len(error_collector.errors))680 dbg('mailing %i data errors' % len(error_collector.errors))
680 for error in error_collector.errors:681 for error in error_collector.errors:
681 for pattern, addresses in cfg['error_contact'].iteritems():682 project_name = error.get_project_name()
682 if (error.get_blueprint_name() is not None683 if project_name is not None:
683 and re.search(pattern, error.get_blueprint_name())):684 addresses = cfg['project_notification_addresses'][project_name]
684 dbg('spec %s matches error_contact pattern "%s", mailing to %s' % (error.get_blueprint_name(),685 dbg('spec %s is targetted to "%s", mailing to %s' % (error.get_blueprint_name(),
685 pattern, ', '.join(addresses)))686 project_name, ', '.join(addresses)))
686 for a in addresses:687 for a in addresses:
687 emails.setdefault(a, '')688 emails.setdefault(a, '')
688 emails[a] += error.format_for_display() + '\n'689 emails[a] += error.format_for_display() + '\n'
689 break
690 else:690 else:
691 print >> sys.stderr, error.format_for_display(), '(no error_contact pattern)'691 print >> sys.stderr, error.format_for_display(), '(no error_contact pattern)'
692692
693693
=== modified file 'lpworkitems/error_collector.py'
--- lpworkitems/error_collector.py 2011-06-08 19:30:24 +0000
+++ lpworkitems/error_collector.py 2012-02-03 11:04:28 +0000
@@ -48,6 +48,10 @@
48 """Get the name of the blueprint, or None if not a blueprint."""48 """Get the name of the blueprint, or None if not a blueprint."""
49 return None49 return None
5050
51 def get_project_name(self):
52 """Get the name of the project, or None if not a project."""
53 return None
54
51 def format_for_display(self):55 def format_for_display(self):
52 """Produce a string representation of the Error.56 """Produce a string representation of the Error.
5357
@@ -84,6 +88,9 @@
84 def get_blueprint_name(self):88 def get_blueprint_name(self):
85 return self.blueprint.name89 return self.blueprint.name
8690
91 def get_project_name(self):
92 return self.blueprint.url.split('/')[-3]
93
8794
88class BlueprintURLError(Error):95class BlueprintURLError(Error):
89 """A deprecated class for backwards-compatibility.96 """A deprecated class for backwards-compatibility.
@@ -101,6 +108,9 @@
101 def get_blueprint_name(self):108 def get_blueprint_name(self):
102 return self.blueprint_url.split('/')[-1]109 return self.blueprint_url.split('/')[-1]
103110
111 def get_project_name(self):
112 return self.blueprint_url.split('/')[-3]
113
104114
105class MilestoneError(Error):115class MilestoneError(Error):
106116

Subscribers

People subscribed via source and target branches