Merge lp:~javier.collado/utah/bug1162862 into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 853
Merged at revision: 854
Proposed branch: lp:~javier.collado/utah/bug1162862
Merge into: lp:utah
Diff against target: 43 lines (+12/-1) (has conflicts)
2 files modified
debian/changelog (+4/-0)
utah/provisioning/rsyslog.py (+8/-1)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~javier.collado/utah/bug1162862
Reviewer Review Type Date Requested Status
Andy Doan (community) Approve
Javier Collado (community) Needs Resubmitting
Review via email: mp+156368@code.launchpad.net

Description of the change

This change is intended to write to log:
- The pattern that matched (to make sure about what pattern of all the possible
  ones matched)
- The error message when a timeout happens (to get the timestamp of when that
  happened)

This is expected to make easier to troubleshoot timeout problems.

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

> === modified file 'utah/provisioning/rsyslog.py'
> --- utah/provisioning/rsyslog.py 2013-03-29 17:00:50 +0000
> +++ utah/provisioning/rsyslog.py 2013-04-01 16:25:27 +0000
> @@ -154,6 +154,9 @@
> msg = 'Expected pattern missed, matched future pattern: %s'
> self.logger.warn(msg, match)
> x = self._fast_forward(steps, match, callbacks)
> + else:
> + self.logger.info('Matched pattern {!r} for {!r} message'
> + .format(match, message))

make this:
  + self.logger.info('Matched pattern %s for %s message',
                                        match, message)

Revision history for this message
Javier Collado (javier.collado) wrote :

Is there any reason why you prefer string interpolation over `format`? I find
easier to use curly braces and forget about the type of what I want to print.

Revision history for this message
Andy Doan (doanac) wrote :

On 04/02/2013 06:09 AM, Javier Collado wrote:
> Is there any reason why you prefer string interpolation over `format`? I find
> easier to use curly braces and forget about the type of what I want to print.

more for the logging.debug case. when you do .format it always builds
the string to write, even if that level of debug isn't enabled.

lp:~javier.collado/utah/bug1162862 updated
853. By Javier Collado

Avoid creating log message string depending on loglevel

Revision history for this message
Javier Collado (javier.collado) wrote :

I've never used that feature of the logging module, but indeed it makes sense.
Thanks for the explanation.

review: Needs Resubmitting
Revision history for this message
Andy Doan (doanac) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-04-02 12:35:07 +0000
+++ debian/changelog 2013-04-03 09:40:31 +0000
@@ -3,8 +3,12 @@
3 * Return error code on unhandled error (LP: #1160857)3 * Return error code on unhandled error (LP: #1160857)
4 * Remove temporary files downloaded based on URL (LP: #1101186)4 * Remove temporary files downloaded based on URL (LP: #1101186)
5 * Stop server on installation failure (LP: #1161855)5 * Stop server on installation failure (LP: #1161855)
6<<<<<<< TREE
6 * Check group after command line argument parsing (LP: #1126219)7 * Check group after command line argument parsing (LP: #1126219)
7 * Added INVALID_USER return code (LP: #1160032)8 * Added INVALID_USER return code (LP: #1160032)
9=======
10 * Write syslog pattern matched and timeouts timestamps (LP: #1162862)
11>>>>>>> MERGE-SOURCE
812
9 -- Javier Collado <javier.collado@canonical.com> Wed, 27 Mar 2013 13:00:47 +010013 -- Javier Collado <javier.collado@canonical.com> Wed, 27 Mar 2013 13:00:47 +0100
1014
1115
=== modified file 'utah/provisioning/rsyslog.py'
--- utah/provisioning/rsyslog.py 2013-03-29 17:00:50 +0000
+++ utah/provisioning/rsyslog.py 2013-04-03 09:40:31 +0000
@@ -154,6 +154,9 @@
154 msg = 'Expected pattern missed, matched future pattern: %s'154 msg = 'Expected pattern missed, matched future pattern: %s'
155 self.logger.warn(msg, match)155 self.logger.warn(msg, match)
156 x = self._fast_forward(steps, match, callbacks)156 x = self._fast_forward(steps, match, callbacks)
157 else:
158 self.logger.info('Matched pattern %r for %r message',
159 match, message)
157160
158 self._do_callback(steps[x], callbacks)161 self._do_callback(steps[x], callbacks)
159 x += 1162 x += 1
@@ -213,7 +216,11 @@
213 for pat in pats:216 for pat in pats:
214 if pat.match(data):217 if pat.match(data):
215 return pat.pattern218 return pat.pattern
216 raise UTAHException('Timeout occurred for {}'.format(message))219 log_message = ('Timeout ({}) occurred for {!r} message'
220 .format(timeout, message))
221 # Log error message to write the timestamp when the timeout happened
222 self.logger.error(log_message)
223 raise UTAHException(log_message)
217224
218 def _read_udp(self):225 def _read_udp(self):
219 data = None226 data = None

Subscribers

People subscribed via source and target branches