Merge lp:~tr3buchet/nova/lock into lp:~hudson-openstack/nova/trunk
| Status: | Merged |
|---|---|
| Approved by: | Eric Day on 2011-01-07 |
| Approved revision: | 529 |
| Merged at revision: | 524 |
| Proposed branch: | lp:~tr3buchet/nova/lock |
| Merge into: | lp:~hudson-openstack/nova/trunk |
| Diff against target: |
330 lines (+184/-2) 5 files modified
nova/api/openstack/servers.py (+44/-0) nova/compute/api.py (+33/-0) nova/compute/manager.py (+86/-2) nova/db/sqlalchemy/models.py (+2/-0) nova/tests/test_compute.py (+19/-0) |
| To merge this branch: | bzr merge lp:~tr3buchet/nova/lock |
| Related bugs: | |
| Related blueprints: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Eric Day (community) | 2010-12-29 | Approve on 2011-01-07 | |
| Devin Carlen (community) | Approve on 2010-12-30 | ||
| Matt Dietz (community) | Needs Fixing on 2010-12-29 | ||
|
Review via email:
|
|||
Description of the Change
This branch implements lock functionality. The lock is stored in the compute worker database. Decorators have been added to the openstack API actions which alter instances in any way.
| Trey Morris (tr3buchet) wrote : | # |
- 507. By Trey Morris on 2010-12-29
-
removed some code i didn't end up using
| Trey Morris (tr3buchet) wrote : | # |
also, I apologize for launchpad mangling my commit message
| Rick Harris (rconradharris) wrote : | # |
Overall lgtm. A few small comments:
> + if(admin or not locked):
No parens needed :-)
> + @checks_lock
I'm wondering if we should give this particular lock a memorable/
Maybe, @check_
| Trey Morris (tr3buchet) wrote : | # |
i like that
i'll fix up both
- 508. By Trey Morris on 2010-12-29
-
removed () from if (can't believe i did that) and renamed checks_lock decorator
| Trey Morris (tr3buchet) wrote : | # |
fixed.
also moved my testing notes from above to this comment so it isn't in the commit message
Notes: unittests passed locally. pep8 returned not errors locally. My integration test with output is as follows (remember that the openstack API maps state "pause" to "error"):
(trey|3nova)
(trey|3nova)
(screen window)
(trey|3nova)
(trey|3nova)
(trey|3nova)
(trey|3nova)
(trey|3nova)
(trey|3nova)
RESERVATION r-27hxqjra admin
INSTANCE i-qssosb ami-tiny scheduling test (admin, None) 0 m1.tiny 2010-12-29 20:54:38.391163
(trey|3nova)
(trey|3nova)
(trey|3nova)
+------
| ID | Name | Status | Public IP | Private IP |
+------
| 1620488315 | Server 1620488315 | active | | |
+------
(trey|3nova)
(trey|3nova)
+------
| ID | Name | Status | Public IP | Private IP |
+------
| 1620488315 | Server 1620488315 | error | | |
+------
(trey|3nova)
(trey|3nova)
+------
| ID | Name | Status | Public IP | Private IP |
+------
| 1620488315 | Server 1620488315 | active | | |
+------
(trey|3nova)
(trey|3nova)
(trey|3nova)
+------
| ID | Name | Status | Public IP | Private IP |
+------
| 1620488315 | Server 1620488315 | active | | |
+------
(trey|3nova)
(trey|3nova)
+------
| ID | Name | Status | Public ...
| Trey Morris (tr3buchet) wrote : | # |
oooh less mangling this way too :D
| Eric Day (eday) wrote : | # |
I think the lock check should be happening on the compute worker node, not within the API server (and if it were happening in the API server, it should be in compute.api, not in the openstack API specific code). We need to start planning for race conditions in a distributed system, and this means handling operations at the canonical source.
| Matt Dietz (cerberus) wrote : | # |
I'm not sure I agree with the idea of a locked instance returning not found. I think it delivers an idea inconsistent with the intent of the locking mechanism. I would say HTTP 405 (MethodNotAllowed) or something like that instead, as a 404 wouldn't let the end user know that it needs to be unlocked. Also, I don't think we want to lock the show action, as the lock is supposed to represent immutability, not visibility.
- 509. By Trey Morris on 2010-12-29
-
removed lock check from show and changed returning 404 to 405
| Trey Morris (tr3buchet) wrote : | # |
re matthew: fixed.
re eric: yikes, good point.
| Trey Morris (tr3buchet) wrote : | # |
also re eric: you devil...
- 510. By Trey Morris on 2010-12-30
-
moved check lock decorator to compute api level. altered openstack.
test_servers according and wrote test for lock in tests.test_compute - 511. By Trey Morris on 2010-12-30
-
fixd variables being out of scope in lock decorator
- 512. By Trey Morris on 2010-12-30
-
altered error exception/logging
- 513. By Trey Morris on 2010-12-30
-
altered error exception/logging
- 514. By Trey Morris on 2010-12-30
-
typo, trying to hurry.. look where that got me
- 515. By Trey Morris on 2010-12-30
-
added some logging
- 516. By Trey Morris on 2010-12-30
-
removed db.set_lock, using update_instance instead
- 517. By Trey Morris on 2010-12-30
-
moved check lock decorator from the compute api to the come manager... when it rains it pours
- 518. By Trey Morris on 2010-12-30
-
syntax error
- 519. By Trey Morris on 2010-12-30
-
fixed up the compute lock test, was failing because the context was always admin
- 520. By Trey Morris on 2010-12-30
-
removed tests.api.
openstack. test_servers test_lock, to hell with it. i'm not even sure if testing lock needs to be at this level
| Trey Morris (tr3buchet) wrote : | # |
re eric:
ok moved the lock check business to the compute api. Tests spent forever fixing the unittests, gave up. Moved the lock check business to the compute manager. Tests are passing. Testing shows it works. Attempting to perform a lock checking action on a locked instance when not an admin will throw an exception which is currently uncaught. Also I removed the test for lock in the openstack api tests because I'm not sure a lock test should go there.
- 521. By Trey Morris on 2010-12-30
-
altered the compute lock test
- 522. By Trey Morris on 2010-12-30
-
fixed the compute lock test
| Trey Morris (tr3buchet) wrote : | # |
alright here we go. Now it works, passes unittests and when you attempt to do something to a locked instance and are not an admin, nothing happens and this shows up in the logs (for example):
ERROR:root:Instance |1| is locked, cannot execute |<function pause_instance at 0x2d910c8>|
| Devin Carlen (devcamcar) wrote : | # |
good work, lock name is clear and code is in compute api now.
| Eric Day (eday) wrote : | # |
140: I would simplify this and assume (self, context, instance_id) for args[0/1/2] and not looks in kwargs. In fact, on 129, I would instead do:
+ def decorated_
and remove the try block altogether.
- 523. By Trey Morris on 2011-01-06
-
altered argument handling
- 524. By Trey Morris on 2011-01-06
-
pep8
- 525. By Trey Morris on 2011-01-06
-
merged trunk
- 526. By Trey Morris on 2011-01-06
-
accidentally left unlocked in there, it should have been locked
- 527. By Trey Morris on 2011-01-06
-
passing the correct parameters to decorated function
- 528. By Trey Morris on 2011-01-06
-
refers to instance_id instead of instance_
ref[instance_ id] - 529. By Trey Morris on 2011-01-06
-
typo
| Trey Morris (tr3buchet) wrote : | # |
alright eric day, i've got your changes implemented. locally unittests pass, pep8 returns nothing and the lock works.


also, not shown is me modifying the users and instances tables in another window to set the state of is_admin and locked attributes which are commented about above.