Merge lp:~julian-edwards/launchpad/buildd-manager-better-logging-bug-530040 into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Merged at revision: not available
Proposed branch: lp:~julian-edwards/launchpad/buildd-manager-better-logging-bug-530040
Merge into: lp:launchpad
Diff against target: 191 lines (+24/-18)
5 files modified
lib/lp/buildmaster/interfaces/buildbase.py (+4/-1)
lib/lp/buildmaster/manager.py (+5/-5)
lib/lp/buildmaster/master.py (+1/-1)
lib/lp/buildmaster/model/buildbase.py (+11/-8)
lib/lp/buildmaster/model/builder.py (+3/-3)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/buildd-manager-better-logging-bug-530040
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+20667@code.launchpad.net

Description of the change

= Summary =
improve the logging for the buildd-manager

== Proposed fix ==
https://bugs.edge.launchpad.net/bugs/530040

The logging for the buildd-manager *sucks*. It logs crap that it shouldn't
and doesn't log important stuff that it should. This branch takes care of
that!

== Pre-implementation notes ==
Chatted briefly with noodles about what to do with the logger name - in the
end a constant in the buildbase interface file appeared to be a reasonable
choice.

== Implementation details ==
Most of this stuff is changing log.debug into log.info and vice versa. I also
added the build.title to the info message when it fetches a build from the
slave, and it also now logs the files it retrieves.

== Tests ==
None exist - I really don't see the point of testing logging anyway.

== Demo and Q/A ==
I've tested this on dogfood already to make sure it logs what I need.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/buildmaster/model/builder.py
  lib/lp/buildmaster/model/buildbase.py
  lib/lp/buildmaster/master.py
  lib/lp/buildmaster/interfaces/buildbase.py
  lib/lp/buildmaster/manager.py

== Pylint notices ==

lib/lp/buildmaster/interfaces/buildbase.py
    14: [F0401] Unable to import 'lazr.enum' (No module named enum)
    15: [F0401] Unable to import 'lazr.restful.declarations' (No module named
restful)
    16: [F0401] Unable to import 'lazr.restful.fields' (No module named
restful)

To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/buildmaster/interfaces/buildbase.py'
2--- lib/lp/buildmaster/interfaces/buildbase.py 2010-02-16 03:52:28 +0000
3+++ lib/lp/buildmaster/interfaces/buildbase.py 2010-03-08 11:14:30 +0000
4@@ -7,7 +7,7 @@
5
6 __metaclass__ = type
7
8-__all__ = ['IBuildBase']
9+__all__ = ['BUILDD_MANAGER_LOG_NAME', 'IBuildBase']
10
11 from zope.interface import Attribute, Interface
12 from zope.schema import Choice, Datetime, Object, TextLine, Timedelta
13@@ -24,6 +24,9 @@
14 from canonical.launchpad import _
15
16
17+BUILDD_MANAGER_LOG_NAME = "slave-scanner"
18+
19+
20 class IBuildBase(Interface):
21 """Common interface shared by farm jobs that build a package."""
22
23
24=== modified file 'lib/lp/buildmaster/manager.py'
25--- lib/lp/buildmaster/manager.py 2010-02-02 16:39:10 +0000
26+++ lib/lp/buildmaster/manager.py 2010-03-08 11:14:30 +0000
27@@ -31,7 +31,7 @@
28 from canonical.launchpad.webapp import urlappend
29 from canonical.librarian.db import write_transaction
30 from canonical.twistedsupport.processmonitor import run_process_with_timeout
31-
32+from lp.buildmaster.interfaces.buildbase import BUILDD_MANAGER_LOG_NAME
33
34 buildd_success_result_map = {
35 'ensurepresent': True,
36@@ -222,7 +222,7 @@
37 Make it less verbose to avoid messing too much with the old code.
38 """
39 level = logging.INFO
40- logger = logging.getLogger('slave-scanner')
41+ logger = logging.getLogger(BUILDD_MANAGER_LOG_NAME)
42
43 # Redirect the output to the twisted log module.
44 channel = logging.StreamHandler(log.StdioOnnaStick())
45@@ -283,7 +283,7 @@
46
47 Perform the finishing-cycle tasks mentioned above.
48 """
49- self.logger.info('Scanning cycle finished.')
50+ self.logger.debug('Scanning cycle finished.')
51 # We are only interested in returned objects of type
52 # BaseDispatchResults, those are the ones that needs evaluation.
53 # None, resulting from successful chains, are discarded.
54@@ -304,7 +304,7 @@
55 # Return the evaluated events for testing purpose.
56 return deferred_results
57
58- self.logger.info('Finishing scanning cycle.')
59+ self.logger.debug('Finishing scanning cycle.')
60 dl = defer.DeferredList(self._deferreds, consumeErrors=True)
61 dl.addBoth(done)
62 return dl
63@@ -415,7 +415,7 @@
64
65 See `RecordingSlave.resumeSlaveHost` for more details.
66 """
67- self.logger.info('Resuming slaves: %s' % recording_slaves)
68+ self.logger.debug('Resuming slaves: %s' % recording_slaves)
69 self.remaining_slaves = recording_slaves
70 if len(self.remaining_slaves) == 0:
71 self.finishCycle()
72
73=== modified file 'lib/lp/buildmaster/master.py'
74--- lib/lp/buildmaster/master.py 2010-01-20 01:23:38 +0000
75+++ lib/lp/buildmaster/master.py 2010-03-08 11:14:30 +0000
76@@ -138,7 +138,7 @@
77 self._tm = tm
78 self.librarian = getUtility(ILibrarianClient)
79 self._archseries = {}
80- self._logger.info("Buildd Master has been initialised")
81+ self._logger.debug("Buildd Master has been initialised")
82
83 def commit(self):
84 self._tm.commit()
85
86=== modified file 'lib/lp/buildmaster/model/buildbase.py'
87--- lib/lp/buildmaster/model/buildbase.py 2010-03-05 23:29:50 +0000
88+++ lib/lp/buildmaster/model/buildbase.py 2010-03-08 11:14:30 +0000
89@@ -29,6 +29,7 @@
90 from canonical.launchpad.helpers import filenameToContentType
91 from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
92 from canonical.librarian.utils import copy_and_close
93+from lp.buildmaster.interfaces.buildbase import BUILDD_MANAGER_LOG_NAME
94 from lp.registry.interfaces.pocket import pocketsuffix
95 from lp.soyuz.interfaces.build import BuildStatus
96 from lp.soyuz.model.buildqueue import BuildQueue
97@@ -129,7 +130,7 @@
98
99 def handleStatus(self, status, librarian, slave_status):
100 """See `IBuildBase`."""
101- logger = logging.getLogger()
102+ logger = logging.getLogger(BUILDD_MANAGER_LOG_NAME)
103
104 method = getattr(self, '_handleStatus_' + status, None)
105
106@@ -151,7 +152,8 @@
107 buildid = slave_status['build_id']
108 filemap = slave_status['filemap']
109
110- logger.debug("Processing successful build %s" % buildid)
111+ logger.info("Processing successful build %s from builder %s" % (
112+ buildid, self.buildqueue_record.builder.name))
113 # Explode before collect a binary that is denied in this
114 # distroseries/pocket
115 if not self.archive.allowUpdatesToReleasePocket():
116@@ -180,6 +182,7 @@
117
118 slave = removeSecurityProxy(self.buildqueue_record.builder.slave)
119 for filename in filemap:
120+ logger.info("Grabbing file: %s" % filename)
121 slave_file = slave.getFile(filemap[filename])
122 out_file_name = os.path.join(upload_path, filename)
123 out_file = open(out_file_name, "wb")
124@@ -190,8 +193,8 @@
125 upload_leaf, uploader_logfilename)
126 logger.debug("Saving uploader log at '%s'" % uploader_logfilename)
127
128- logger.debug("Invoking uploader on %s" % root)
129- logger.debug("%s" % uploader_command)
130+ logger.info("Invoking uploader on %s" % root)
131+ logger.info("%s" % uploader_command)
132
133 uploader_process = subprocess.Popen(
134 uploader_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
135@@ -204,11 +207,11 @@
136 # when it failed HARD (there is a huge effort in process-upload
137 # to not return error, it only happen when the code is broken).
138 uploader_result_code = uploader_process.returncode
139- logger.debug("Uploader returned %d" % uploader_result_code)
140+ logger.info("Uploader returned %d" % uploader_result_code)
141
142 # Quick and dirty hack to carry on on process-upload failures
143 if os.path.exists(upload_dir):
144- logger.debug("The upload directory did not get moved.")
145+ logger.warning("The upload directory did not get moved.")
146 failed_dir = os.path.join(root, "failed-to-move")
147 if not os.path.exists(failed_dir):
148 os.mkdir(failed_dir)
149@@ -261,7 +264,7 @@
150 # binary upload when it was the case.
151 if (self.buildstate != BuildStatus.FULLYBUILT or
152 not self.verifySuccessfulUpload()):
153- logger.debug("Build %s upload failed." % self.id)
154+ logger.warning("Build %s upload failed." % self.id)
155 self.buildstate = BuildStatus.FAILEDTOUPLOAD
156 uploader_log_content = self.getUploadLogContent(root,
157 upload_leaf)
158@@ -271,7 +274,7 @@
159 # Notify the build failure.
160 self.notify(extra_info=uploader_log_content)
161 else:
162- logger.debug(
163+ logger.info(
164 "Gathered %s %d completely" % (
165 self.__class__.__name__, self.id))
166
167
168=== modified file 'lib/lp/buildmaster/model/builder.py'
169--- lib/lp/buildmaster/model/builder.py 2010-01-22 04:01:17 +0000
170+++ lib/lp/buildmaster/model/builder.py 2010-03-08 11:14:30 +0000
171@@ -636,17 +636,17 @@
172
173 def pollBuilders(self, logger, txn):
174 """See IBuilderSet."""
175- logger.info("Slave Scan Process Initiated.")
176+ logger.debug("Slave Scan Process Initiated.")
177
178 buildMaster = BuilddMaster(logger, txn)
179
180- logger.info("Setting Builders.")
181+ logger.debug("Setting Builders.")
182 # Put every distroarchseries we can find into the build master.
183 for archseries in getUtility(IDistroArchSeriesSet):
184 buildMaster.addDistroArchSeries(archseries)
185 buildMaster.setupBuilders(archseries)
186
187- logger.info("Scanning Builders.")
188+ logger.debug("Scanning Builders.")
189 # Scan all the pending builds, update logtails and retrieve
190 # builds where they are completed
191 buildMaster.scanActiveBuilders()