Merge lp:~doanac/utah/bug1158743 into lp:utah

Proposed by Andy Doan
Status: Superseded
Proposed branch: lp:~doanac/utah/bug1158743
Merge into: lp:utah
Diff against target: 74 lines (+26/-9)
2 files modified
debian/changelog (+6/-0)
utah/provisioning/baremetal/inventory.py (+20/-9)
To merge this branch: bzr merge lp:~doanac/utah/bug1158743
Reviewer Review Type Date Requested Status
UTAH Dev Pending
Review via email: mp+155069@code.launchpad.net

This proposal has been superseded by a proposal from 2013-03-25.

Description of the change

This should add the logging Javier was suggesting to understand what processes are actually using a machine.

To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

I see that you fixed the bug in a branch based on trunk and created the merge
for dev (which actually reveals an entry in debian/changelog that isn't in
dev). Is this the expected way to work with bugs?

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

The use of a static private method suggests that `_in_use` is a utility method,
so I believe it should be moved to the `process` module which is expected to
have that kind of methods.

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

On 03/25/2013 04:16 AM, Javier Collado wrote:
> I see that you fixed the bug in a branch based on trunk and created the merge
> for dev (which actually reveals an entry in debian/changelog that isn't in
> dev). Is this the expected way to work with bugs?
>
Nope - that was a mechanical error. I'll correct

lp:~doanac/utah/bug1158743 updated
270. By Andy Doan

move pid _in_use to process.py

As per Javier's review comment this moves the function to become a
generic helper. I also added some unit-testing logic for it

271. By Andy Doan

fix pep257 issues

272. By Andy Doan

add changelog entry

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-03-21 08:27:02 +0000
+++ debian/changelog 2013-03-22 21:18:28 +0000
@@ -2259,6 +2259,12 @@
22592259
2260 -- Max Brustkern <max@canonical.com> Mon, 02 Jul 2012 10:13:46 -04002260 -- Max Brustkern <max@canonical.com> Mon, 02 Jul 2012 10:13:46 -0400
22612261
2262utah (0.2ubuntu365) quantal; urgency=low
2263
2264 * Updated to add CustomKVM provisioning
2265
2266 -- Max Brustkern <max@canonical.com> Mon, 02 Jul 2012 10:13:09 -0400
2267
2262utah (0.2ubuntu364) quantal; urgency=low2268utah (0.2ubuntu364) quantal; urgency=low
22632269
2264 * Updated script to warn user should logout and back in to pick up2270 * Updated script to warn user should logout and back in to pick up
22652271
=== added file 'utah-client_0.1_all.deb'
2266Binary files utah-client_0.1_all.deb 1970-01-01 00:00:00 +0000 and utah-client_0.1_all.deb 2013-03-22 21:18:28 +0000 differ2272Binary files utah-client_0.1_all.deb 1970-01-01 00:00:00 +0000 and utah-client_0.1_all.deb 2013-03-22 21:18:28 +0000 differ
=== modified file 'utah/provisioning/baremetal/inventory.py'
--- utah/provisioning/baremetal/inventory.py 2013-01-22 14:13:17 +0000
+++ utah/provisioning/baremetal/inventory.py 2013-03-22 21:18:28 +0000
@@ -17,8 +17,10 @@
17Provide inventory functions specific to bare metal deployments.17Provide inventory functions specific to bare metal deployments.
18"""18"""
1919
20import logging
20import os21import os
21import psutil22import psutil
23
22from utah.provisioning.inventory.exceptions import \24from utah.provisioning.inventory.exceptions import \
23 UTAHProvisioningInventoryException25 UTAHProvisioningInventoryException
24from utah.provisioning.inventory.sqlite import SQLiteInventory26from utah.provisioning.inventory.sqlite import SQLiteInventory
@@ -47,6 +49,19 @@
47 raise UTAHProvisioningInventoryException('No machines in database')49 raise UTAHProvisioningInventoryException('No machines in database')
48 self.machines = []50 self.machines = []
4951
52 @staticmethod
53 def _in_use(pid):
54 try:
55 proc = psutil.Process(pid)
56 except (psutil.error.NoSuchProcess, TypeError, ValueError):
57 return None
58
59 cmdline = ' '.join(proc.cmdline)
60 if 'utah' in cmdline or 'run_test' in cmdline:
61 return proc
62
63 return None
64
50 def request(self, machinetype, name=None, *args, **kw):65 def request(self, machinetype, name=None, *args, **kw):
51 query = 'SELECT * FROM machines'66 query = 'SELECT * FROM machines'
52 queryvars = []67 queryvars = []
@@ -65,15 +80,11 @@
65 for minfo in result:80 for minfo in result:
66 machineinfo = dict(minfo)81 machineinfo = dict(minfo)
67 pid = machineinfo['pid']82 pid = machineinfo['pid']
68 try:83 proc = self._in_use(pid)
69 if not (psutil.pid_exists(pid) and ('utah' in84 if not proc:
70 ' '.join(psutil.Process(pid).cmdline)85 return self._take(machineinfo, machinetype, *args, **kw)
71 or 'run_test' in86 else:
72 ' '.join(psutil.Process(pid).cmdline))):87 logging.info('machine in use by: %s', proc.cmdline)
73 return self._take(machineinfo, machinetype,
74 *args, **kw)
75 except ValueError:
76 continue
7788
78 raise UTAHProvisioningInventoryException(89 raise UTAHProvisioningInventoryException(
79 'All machines meeting criteria are currently unavailable')90 'All machines meeting criteria are currently unavailable')

Subscribers

People subscribed via source and target branches

to all changes: