← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging ~cjwatson/launchpad:remove-old-code-import-worker-compat into launchpad:master.

Commit message:
Drop support for old code import log file protocol

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/442869

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.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:remove-old-code-import-worker-compat into launchpad:master.
diff --git a/lib/lp/code/interfaces/codeimportscheduler.py b/lib/lp/code/interfaces/codeimportscheduler.py
index 36b0308..f3262c7 100644
--- a/lib/lp/code/interfaces/codeimportscheduler.py
+++ b/lib/lp/code/interfaces/codeimportscheduler.py
@@ -59,8 +59,7 @@ class ICodeImportScheduler(Interface):
         :param job_id: The ID of the code import job to finish.
         :param status_name: The outcome of the job as the name of a
             `CodeImportResultStatus` item.
-        :param log_file: A log file to display for diagnostics, either as an
-            `xmlrpc.client.Binary` containing the log file data or
-            as the URL of a file in the librarian.
+        :param log_file: A log file to display for diagnostics, as an
+            `xmlrpc.client.Binary` containing the log file data.
         :raise NoSuchCodeImportJob: if no job with id `job_id` exists.
         """
diff --git a/lib/lp/code/xmlrpc/codeimportscheduler.py b/lib/lp/code/xmlrpc/codeimportscheduler.py
index ff65213..8a737fc 100644
--- a/lib/lp/code/xmlrpc/codeimportscheduler.py
+++ b/lib/lp/code/xmlrpc/codeimportscheduler.py
@@ -8,7 +8,6 @@ __all__ = [
 ]
 
 import io
-import xmlrpc.client
 
 import six
 from zope.component import getUtility
@@ -91,28 +90,16 @@ class CodeImportSchedulerAPI(LaunchpadXMLRPCView):
         job = self._getJob(job_id)
         status = CodeImportResultStatus.items[status_name]
         workflow = removeSecurityProxy(getUtility(ICodeImportJobWorkflow))
-        if isinstance(log_file, xmlrpc.client.Binary):
-            if log_file.data:
-                log_file_name = "%s.log" % (
-                    job.code_import.target.unique_name[1:].replace("/", "-")
-                )
-                log_file_alias = getUtility(ILibraryFileAliasSet).create(
-                    log_file_name,
-                    len(log_file.data),
-                    io.BytesIO(log_file.data),
-                    "text/plain",
-                )
-            else:
-                log_file_alias = None
-        elif log_file:
-            # XXX cjwatson 2020-10-05: Backward compatibility for previous
-            # versions that uploaded the log file to the librarian from the
-            # scheduler; remove this once deployed code import machines no
-            # longer need this.
-            library_file_alias_set = getUtility(ILibraryFileAliasSet)
-            # XXX This is so so so terrible:
-            log_file_alias_id = int(six.ensure_text(log_file).split("/")[-2])
-            log_file_alias = library_file_alias_set[log_file_alias_id]
+        if log_file and log_file.data:
+            log_file_name = "%s.log" % (
+                job.code_import.target.unique_name[1:].replace("/", "-")
+            )
+            log_file_alias = getUtility(ILibraryFileAliasSet).create(
+                log_file_name,
+                len(log_file.data),
+                io.BytesIO(log_file.data),
+                "text/plain",
+            )
         else:
             log_file_alias = None
         workflow.finishJob(job, status, log_file_alias)
diff --git a/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py b/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py
index 0ec55a4..d332f35 100644
--- a/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py
+++ b/lib/lp/code/xmlrpc/tests/test_codeimportscheduler.py
@@ -115,19 +115,6 @@ class TestCodeImportSchedulerAPI(TestCaseWithFactory):
             code_import, "date_last_successful", UTC_NOW
         )
 
-    def test_finishJobID_with_log_file_alias_url(self):
-        # finishJobID calls the finishJobID job workflow method and can parse
-        # a librarian file's http url to figure out its ID.
-        code_import_job = self.makeCodeImportJob(running=True)
-        code_import = code_import_job.code_import
-        log_file_alias = self.factory.makeLibraryFileAlias()
-        self.api.finishJobID(
-            code_import_job.id,
-            CodeImportResultStatus.SUCCESS.name,
-            log_file_alias.http_url,
-        )
-        self.assertEqual(log_file_alias, code_import.results.last().log_file)
-
     def test_finishJobID_with_log_file_data(self):
         # finishJobID calls the finishJobID job workflow method and uploads
         # log file data to the librarian.