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
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-04-02 12:35:07 +0000
3+++ debian/changelog 2013-04-03 09:40:31 +0000
4@@ -3,8 +3,12 @@
5 * Return error code on unhandled error (LP: #1160857)
6 * Remove temporary files downloaded based on URL (LP: #1101186)
7 * Stop server on installation failure (LP: #1161855)
8+<<<<<<< TREE
9 * Check group after command line argument parsing (LP: #1126219)
10 * Added INVALID_USER return code (LP: #1160032)
11+=======
12+ * Write syslog pattern matched and timeouts timestamps (LP: #1162862)
13+>>>>>>> MERGE-SOURCE
14
15 -- Javier Collado <javier.collado@canonical.com> Wed, 27 Mar 2013 13:00:47 +0100
16
17
18=== modified file 'utah/provisioning/rsyslog.py'
19--- utah/provisioning/rsyslog.py 2013-03-29 17:00:50 +0000
20+++ utah/provisioning/rsyslog.py 2013-04-03 09:40:31 +0000
21@@ -154,6 +154,9 @@
22 msg = 'Expected pattern missed, matched future pattern: %s'
23 self.logger.warn(msg, match)
24 x = self._fast_forward(steps, match, callbacks)
25+ else:
26+ self.logger.info('Matched pattern %r for %r message',
27+ match, message)
28
29 self._do_callback(steps[x], callbacks)
30 x += 1
31@@ -213,7 +216,11 @@
32 for pat in pats:
33 if pat.match(data):
34 return pat.pattern
35- raise UTAHException('Timeout occurred for {}'.format(message))
36+ log_message = ('Timeout ({}) occurred for {!r} message'
37+ .format(timeout, message))
38+ # Log error message to write the timestamp when the timeout happened
39+ self.logger.error(log_message)
40+ raise UTAHException(log_message)
41
42 def _read_udp(self):
43 data = None

Subscribers

People subscribed via source and target branches