Merge lp:~nuclearbob/utah/installclient-improvement into lp:utah

Proposed by Max Brustkern
Status: Merged
Merged at revision: 667
Proposed branch: lp:~nuclearbob/utah/installclient-improvement
Merge into: lp:utah
Diff against target: 16 lines (+5/-2)
1 file modified
utah/provisioning/provisioning.py (+5/-2)
To merge this branch: bzr merge lp:~nuclearbob/utah/installclient-improvement
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Review via email: mp+119017@code.launchpad.net

Description of the change

Sometimes when I provision a machine and install the client, some other apt or dpkg process is running, and I can't get a lock on the dpkg database. This causes the whole installation to fail.

I've added to the command that installs the client so that it will wait until it can get a lock before trying to install the package. It seemed to work fine on a VMToolsVM. I plan to test it on a CustomVM as well, and a CobblerMachine certainly wouldn't hurt. Since both of those use run from SSHMachine, I think if it works on one it should work on the other.

The problem I'm having with testing right now is that the client install is broken since it PreDepends on python-pip, and that's not getting installed by the preseed yet. I can commit a fix for that, but I think we're redoing that anyway, so I might just wait until that's ready.

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) wrote :

Looks okay to me. I think there might be a small race condition between when the while
tests the lock and the dpkg -i runs in which another process could obtain the lock. However
it's such a small window.

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

This is probably the update manager being launchpad automatically. What about trying to disable automatic updates like this:

gconftool --set --type bool /apps/update-notifier/auto_launch false

I'm not sure how to best translate this to the preseed (maybe just as a late command), but I think it's worth giving a try.

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

One more thing I'd like to comment is that to concatenate two strings you don't really need any operator (they are still needed to concatenate the output from a function like os.path.join though), just put them together:
>>> 'Hello' ' ' 'World'
'Hello World'
>>>

In my opinion, when there are less plus signs, the code is more readable.

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

Good point on the plus signs. I'll try to remember to do that in the future.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/provisioning/provisioning.py'
2--- utah/provisioning/provisioning.py 2012-08-08 23:49:34 +0000
3+++ utah/provisioning/provisioning.py 2012-08-09 19:18:23 +0000
4@@ -232,8 +232,11 @@
5 raise err
6 except AttributeError:
7 raise err
8- if self.run('DEBIAN_FRONTEND=noninteractive dpkg -i '
9- + os.path.join(tmppath, os.path.split(self.getclientdeb())[1])
10+ if self.run('export DEBIAN_FRONTEND=noninteractive ; while '
11+ + '(fuser /var/lib/dpkg/lock >/dev/null 2>&1) ; do echo '
12+ + '"Waiting for dpkg lock to become available" ; sleep 10 ; '
13+ + 'done ; dpkg -i ' + os.path.join(tmppath,
14+ os.path.split(self.getclientdeb())[1])
15 + ' || apt-get -y -f install', root=True) != 0:
16 raise UTAHProvisioningException('Failed to install client')
17

Subscribers

People subscribed via source and target branches