email: When there are multiple SPPHs, use the last one

We were just seeing an interesting crash in britney. It was trying to
look up the gpg_keys of ~python-modules-team, which is a suspended
account - in LP API terms that's a HTTP error 410.

  https://api.launchpad.net/devel/~python-modules-team/gpg_keys

The direct error was fixed in commit 272f41c, but we actually should
*not* have been trying to look up this team's email address in the first
place. This upload was an auto-sync and so should not cause email to be
sent. The problem is that it was synced into universe and then promoted
into main. We were looking at the SPPH for after the promotion, which
has different values in the various signer/creator/sponsor/... fields,
and that made us think that it was a regular upload to email about.

Fix this by always looking at the oldest SPPH which should correspond to
the initial upload and not whatever happened to it afterwards.
sru-regression-messages
Iain Lane 7 years ago
parent 272f41c4a5
commit 400a6c57c4

@ -165,10 +165,10 @@ class EmailPolicy(BasePolicy, Rest):
'version': version,
})
try:
source = data['entries'][0]
source = next(reversed(data['entries']))
# IndexError means no packages in -proposed matched this name/version,
# which is expected to happen when bileto runs britney.
except IndexError:
except StopIteration:
self.log('Email getPublishedSources IndexError (%s %s)' % (pkg, version))
return []
return self.scrape_gpg_emails(person_chooser(source))

@ -101,6 +101,19 @@ AUTO_SYNC = dict(
sponsor_link='https://api.launchpad.net/1.0/~ubuntu-archive-robot',
)
PROMOTED_AUTO_SYNC = [
dict(
creator_link=None,
package_creator_link='https://api.launchpad.net/1.0/~pkg-ruby-extras-maintainers',
package_signer_link=None,
sponsor_link=None,),
dict(
creator_link='https://api.launchpad.net/1.0/~katie',
package_creator_link='https://api.launchpad.net/1.0/~pkg-ruby-extras-maintainers',
package_signer_link=None,
sponsor_link='https://api.launchpad.net/1.0/~ubuntu-archive-robot',)
]
# address lists
UBUNTU = ['personal@gmail.com', 'ubuntu@ubuntu.com', 'work@canonical.com']
@ -164,6 +177,27 @@ class T(unittest.TestCase):
self.assertEqual(address_chooser(CANONICAL), 'work@canonical.com')
self.assertEqual(address_chooser(COMMUNITY), 'personal@gmail.com')
@patch('britney2.policies.email.EmailPolicy.query_rest_api')
@patch('britney2.policies.email.EmailPolicy.query_lp_rest_api')
def test_email_promoted_package(self, lp, rest):
"""When a package has been promoted in proposed, we find the older SPPH
and use its details - in the case of an autosync to not email."""
lp.return_value = dict(entries=PROMOTED_AUTO_SYNC)
e = EmailPolicy(FakeOptions, None)
self.assertEqual(e.lp_get_emails('openstack-doct-tools', '1.5.0-0ubuntu1'), [])
self.assertSequenceEqual(lp.mock_calls, [
call('testbuntu/+archive/primary', {
'distro_series': '/testbuntu/zazzy',
'exact_match': 'true',
'order_by_date': 'true',
'pocket': 'Proposed',
'source_name': 'openstack-doct-tools',
'version': '1.5.0-0ubuntu1',
'ws.op': 'getPublishedSources',
})
])
self.assertSequenceEqual(rest.mock_calls, [])
@patch('britney2.policies.email.EmailPolicy.query_rest_api')
@patch('britney2.policies.email.EmailPolicy.query_lp_rest_api')
def test_email_scraping(self, lp, rest):

Loading…
Cancel
Save