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

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 828
Merged at revision: 826
Proposed branch: lp:~javier.collado/utah/bug1126361
Merge into: lp:utah
Diff against target: 61 lines (+33/-0)
2 files modified
debian/changelog (+1/-0)
utah/provisioning/provisioning.py (+32/-0)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1126361
Reviewer Review Type Date Requested Status
Javier Collado (community) Approve
Review via email: mp+151010@code.launchpad.net

Description of the change

This branch uses ubiquity/failure_command to add an error message to the syslog
that should help to troubleshoot problems faster.

I haven't been able to reproduce any installation failure, but I've tested that
with today's image no problem has been introduced. Also, I've made sure that
the change only affects desktop installations.

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

+1

kernel guys curse breaking a debug string like:

+ self.logger.debug('Adding ubiquity/failure_command question '
+ 'with log messsage')

I guess that's pretty standard pep8-ish code, but couldn't we also do it like:

            self.logger.debug(
         'Adding ubiquity/failure_command question with log messsage')

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Looks reasonable. I guess to test it we should use a preseed with a late command of /bin/false or something? I'll try that today.

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

@Max

The failure command is called when the installation fails, but not when the
success command fails (the wrapping I wrote was to address that case).

To be able to verify this I think an image that is broken at some point or a
preseed that enforces something this isn't possible in a constrained hardware
will be needed.

lp:~javier.collado/utah/bug1126361 updated
828. By Javier Collado

Fixed log strings aren't splitted as suggested by Andy

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

@Andy

Thanks for the suggestion. Yes, I think it's better to have everything in a
single line just in case we need to grep for them in future.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Do we have a broken image handy somewhere? I'm sure we'll see some in the dailies, so it'll be nice to get this in, but I'm not sure how to test it. Apart from that, I approve.

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

I'm merging this and will check if the error message is available in syslog
when a broken build is found.

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-02-26 10:00:28 +0000
3+++ debian/changelog 2013-02-28 16:48:56 +0000
4@@ -2,6 +2,7 @@
5
6 * Added battery_measurements boolean variable to runlist (defaults to False)
7 * Added success command failure detection (LP: #1126115)
8+ * Added installation failure log message (LP: #1126361)
9
10 -- Javier Collado <javier.collado@canonical.com> Wed, 27 Feb 2013 09:28:58 +0100
11
12
13=== modified file 'utah/provisioning/provisioning.py'
14--- utah/provisioning/provisioning.py 2013-02-27 11:10:59 +0000
15+++ utah/provisioning/provisioning.py 2013-02-28 16:48:56 +0000
16@@ -826,6 +826,9 @@
17 if 'passwd/username' in preseed:
18 self._rewrite_passwd_username(preseed)
19
20+ if self.installtype == 'desktop':
21+ self._rewrite_failure_command(preseed)
22+
23 output_preseed_filename = os.path.join(tmpdir,
24 'initrd.d', 'preseed.cfg')
25 with open(output_preseed_filename, 'w') as f:
26@@ -869,6 +872,35 @@
27 'logger -s -t utah "Late command failure detected" '
28 '2>>{}'.format(target_log_file))
29
30+ def _rewrite_failure_command(self, preseed):
31+ """Add log message to failure command.
32+
33+ When an ubiquity installation fails, ubiquity/failure_command is
34+ called. This is a nice place to write a log message, so that when
35+ troubleshotting a provisioing problem it's clearly stated that was the
36+ image instalation itself that failed.
37+
38+ :param preseed: The preseed contents before is written to initrd.d
39+ :type preseed: :class:`Preseed`
40+
41+ .. note::
42+ If ubiquity/failure_command question isn't present in the preseed,
43+ a new entry will be created for it.
44+
45+ """
46+ # Create an ubiquity/failure_command question if not present already
47+ command = 'logger -t utah "Installation failure detected"'
48+ if not 'ubiquity/failure_command' in preseed:
49+ self.logger.debug(
50+ 'Adding ubiquity/failure_command question with log messsage')
51+ preseed.append('ubiquity ubiquity/failure_command string {}'
52+ .format(command))
53+ else:
54+ self.logger.debug(
55+ 'Adding log message to ubiquity/failure_command question')
56+ question = preseed['ubiquity/failure_command']
57+ question.value.prepend('{}; '.format(command))
58+
59 def _rewrite_pkgsel_include(self, preseed):
60 """
61 Add packages required by utah client to pkgsel/include

Subscribers

People subscribed via source and target branches