Merge lp:~ursinha/ubuntu-ci-services-itself/401-copying-di-check into lp:ubuntu-ci-services-itself

Proposed by Ursula Junque on 2014-03-18
Status: Merged
Approved by: Francis Ginther on 2014-03-19
Approved revision: 412
Merged at revision: 412
Proposed branch: lp:~ursinha/ubuntu-ci-services-itself/401-copying-di-check
Merge into: lp:ubuntu-ci-services-itself
Diff against target: 80 lines (+36/-11)
1 file modified
lander/bin/ppa_sync.py (+36/-11)
To merge this branch: bzr merge lp:~ursinha/ubuntu-ci-services-itself/401-copying-di-check
Reviewer Review Type Date Requested Status
Francis Ginther Approve on 2014-03-19
PS Jenkins bot (community) continuous-integration Approve on 2014-03-18
Vincent Ladeuil (community) 2014-03-18 Approve on 2014-03-18
Review via email: mp+211619@code.launchpad.net

Commit message

Adding a check when the Unauthorized exception is raised during ppa_sync.copy() to see if the source is present in target PPA

Description of the change

Launchpad doesn't support copying packages with debian-installer to PPAs, that works only if destination is primary archive, and this causes a 401 Unauthorized error when ppa_sync tries to copy the generated kernel from a build pool's PPA to our master PPA, as it has debian-installer packages.
The good news is that this error happens only after the source and binaries were successfully copied, so this branch adds a check when the Unauthorized exception is raised to see if the source is present in target PPA. If so, that means we hit that bug and the files we need are on the master PPA already, so we can report publish step successfully completed. If not, we raise the Unauthorized error as this is something else going wrong.

To post a comment you must log in.
Vincent Ladeuil (vila) wrote :

Crystal clear.

review: Approve
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:412
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/455/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/455/rebuild

review: Approve (continuous-integration)
Francis Ginther (fginther) wrote :

approve.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lander/bin/ppa_sync.py'
2--- lander/bin/ppa_sync.py 2014-03-16 04:09:09 +0000
3+++ lander/bin/ppa_sync.py 2014-03-18 20:16:41 +0000
4@@ -5,6 +5,8 @@
5 import logging
6 import subprocess
7
8+from lazr.restfulclient import errors
9+
10 from ci_utils.launchpad import lp_login
11
12
13@@ -90,11 +92,11 @@
14 return False
15
16
17-def copy(source_ppa, target_ppa, packages, series):
18+def copy(source_ppa_url, target_ppa_url, packages, series):
19 launchpad = lp_login()
20
21- ppa_team, ppa = _get_team_ppa(launchpad, source_ppa)
22- target_ppa_team, target_ppa = _get_team_ppa(launchpad, target_ppa)
23+ ppa_team, ppa = _get_team_ppa(launchpad, source_ppa_url)
24+ target_ppa_team, target_ppa = _get_team_ppa(launchpad, target_ppa_url)
25
26 ubuntu = launchpad.distributions['ubuntu']
27 series = ubuntu.getSeries(name_or_version=series)
28@@ -108,8 +110,8 @@
29 source_data['version'])
30 # Arches built None means binary independent
31 arches_built = records_published(source_data['binaries'])
32- except EnvironmentError as e:
33- logging.info('Skipping %s: %s', package, e.message)
34+ except EnvironmentError as exc:
35+ logging.info('Skipping %s: %s', package, exc.message)
36 continue
37
38 if arches_built is not None and arches != arches_built:
39@@ -119,12 +121,35 @@
40
41 logging.info('Copying %s - %s for arches %s',
42 package, source_data['version'], arches_built)
43- target_ppa.syncSource(from_archive=ppa,
44- include_binaries=True,
45- source_name=package,
46- to_pocket='Release',
47- version=source_data['version'],
48- to_series=series.name)
49+ try:
50+ target_ppa.syncSource(from_archive=ppa,
51+ include_binaries=True,
52+ source_name=package,
53+ to_pocket='Release',
54+ version=source_data['version'],
55+ to_series=series.name)
56+ except errors.Unauthorized as exc:
57+ # When a kernel package is being copied, launchpad can
58+ # fail with Unauthorized trying to copy d-is, that doesn't work
59+ # for PPAs. So here we check if the relevant source was copied
60+ # succesfully, and report success if so.
61+ #
62+ # I won't check if publishing record is PENDING, because we don't
63+ # know if publisher ran in the meantime and set it to PUBLISHED,
64+ # that would cause the query to return empty and give a false
65+ # negative. Also it's not possible that more than one record
66+ # per version exists on a PPA.
67+ copied_source = target_ppa.getPublishedSources(
68+ source_name=package, version=source_data['version'],
69+ distro_series=series)
70+ if not copied_source:
71+ logging.error("Failed to copy packages from {} to {}. User "
72+ "~{} is not allowed to copy to target "
73+ "PPA.".format(
74+ source_ppa_url, target_ppa_url,
75+ launchpad.me.name))
76+ raise
77+
78
79 if __name__ == '__main__':
80 parser = argparse.ArgumentParser(

Subscribers

People subscribed via source and target branches