Merge ~cjwatson/launchpad:remove-old-code-import-worker-compat into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: f783c0e3c60e071846f72e585478e3aef557c19b
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:remove-old-code-import-worker-compat
Merge into: launchpad:master
Diff against target: 90 lines (+12/-39)
3 files modified
lib/lp/code/interfaces/codeimportscheduler.py (+2/-3)
lib/lp/code/xmlrpc/codeimportscheduler.py (+10/-23)
lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py (+0/-13)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+442869@code.launchpad.net

Commit message

Drop support for old code import log file protocol

Description of the change

This completes a protocol change for code import workers begun in https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/391793 and https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/392369; the worker changes were deployed to production long ago.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/code/interfaces/codeimportscheduler.py b/lib/lp/code/interfaces/codeimportscheduler.py
2index 36b0308..f3262c7 100644
3--- a/lib/lp/code/interfaces/codeimportscheduler.py
4+++ b/lib/lp/code/interfaces/codeimportscheduler.py
5@@ -59,8 +59,7 @@ class ICodeImportScheduler(Interface):
6 :param job_id: The ID of the code import job to finish.
7 :param status_name: The outcome of the job as the name of a
8 `CodeImportResultStatus` item.
9- :param log_file: A log file to display for diagnostics, either as an
10- `xmlrpc.client.Binary` containing the log file data or
11- as the URL of a file in the librarian.
12+ :param log_file: A log file to display for diagnostics, as an
13+ `xmlrpc.client.Binary` containing the log file data.
14 :raise NoSuchCodeImportJob: if no job with id `job_id` exists.
15 """
16diff --git a/lib/lp/code/xmlrpc/codeimportscheduler.py b/lib/lp/code/xmlrpc/codeimportscheduler.py
17index ff65213..8a737fc 100644
18--- a/lib/lp/code/xmlrpc/codeimportscheduler.py
19+++ b/lib/lp/code/xmlrpc/codeimportscheduler.py
20@@ -8,7 +8,6 @@ __all__ = [
21 ]
22
23 import io
24-import xmlrpc.client
25
26 import six
27 from zope.component import getUtility
28@@ -91,28 +90,16 @@ class CodeImportSchedulerAPI(LaunchpadXMLRPCView):
29 job = self._getJob(job_id)
30 status = CodeImportResultStatus.items[status_name]
31 workflow = removeSecurityProxy(getUtility(ICodeImportJobWorkflow))
32- if isinstance(log_file, xmlrpc.client.Binary):
33- if log_file.data:
34- log_file_name = "%s.log" % (
35- job.code_import.target.unique_name[1:].replace("/", "-")
36- )
37- log_file_alias = getUtility(ILibraryFileAliasSet).create(
38- log_file_name,
39- len(log_file.data),
40- io.BytesIO(log_file.data),
41- "text/plain",
42- )
43- else:
44- log_file_alias = None
45- elif log_file:
46- # XXX cjwatson 2020-10-05: Backward compatibility for previous
47- # versions that uploaded the log file to the librarian from the
48- # scheduler; remove this once deployed code import machines no
49- # longer need this.
50- library_file_alias_set = getUtility(ILibraryFileAliasSet)
51- # XXX This is so so so terrible:
52- log_file_alias_id = int(six.ensure_text(log_file).split("/")[-2])
53- log_file_alias = library_file_alias_set[log_file_alias_id]
54+ if log_file and log_file.data:
55+ log_file_name = "%s.log" % (
56+ job.code_import.target.unique_name[1:].replace("/", "-")
57+ )
58+ log_file_alias = getUtility(ILibraryFileAliasSet).create(
59+ log_file_name,
60+ len(log_file.data),
61+ io.BytesIO(log_file.data),
62+ "text/plain",
63+ )
64 else:
65 log_file_alias = None
66 workflow.finishJob(job, status, log_file_alias)
67diff --git a/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py b/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py
68index 0ec55a4..d332f35 100644
69--- a/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py
70+++ b/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py
71@@ -115,19 +115,6 @@ class TestCodeImportSchedulerAPI(TestCaseWithFactory):
72 code_import, "date_last_successful", UTC_NOW
73 )
74
75- def test_finishJobID_with_log_file_alias_url(self):
76- # finishJobID calls the finishJobID job workflow method and can parse
77- # a librarian file's http url to figure out its ID.
78- code_import_job = self.makeCodeImportJob(running=True)
79- code_import = code_import_job.code_import
80- log_file_alias = self.factory.makeLibraryFileAlias()
81- self.api.finishJobID(
82- code_import_job.id,
83- CodeImportResultStatus.SUCCESS.name,
84- log_file_alias.http_url,
85- )
86- self.assertEqual(log_file_alias, code_import.results.last().log_file)
87-
88 def test_finishJobID_with_log_file_data(self):
89 # finishJobID calls the finishJobID job workflow method and uploads
90 # log file data to the librarian.

Subscribers

People subscribed via source and target branches

to status/vote changes: