diff options
| author | Yun Mao <yunmao@gmail.com> | 2012-08-30 14:55:13 -0400 |
|---|---|---|
| committer | Yun Mao <yunmao@gmail.com> | 2012-08-31 13:39:29 -0400 |
| commit | 4082c8375a6ae7e7e67c7ad2e263be2d5fc3dd1f (patch) | |
| tree | c4754f7470f4ca9bff17c79129a1f50348a4f585 /nova/exception.py | |
| parent | 3dd31e5a55c9932a3073d9988840066c0a7b87d0 (diff) | |
Address race condition from concurrent task state update
task_state acts like a guard to avoid concurrent tasks to be
scheduled. There might be two race conditions:
1) two tasks are concurrently accepted by api, check task_state to be
None and allow the tasks to be executed concurrently.
2) one ordinary task is running, so that task_state is set. The delete
task is accepted at API, and will "take over" and change task_state to
DELETING. However the first task may continue to update task_state or
set it to None as it finishes.
This patch specifies current expected task_state when updating task_state.
If unexpected state is met, abort the task without updating. Various
compute tests are fixed accordingly to set the pre condition of the
task state.
Part of bug 1037372
Change-Id: I5fdf0946c728a47febb56ad468043a828b2736c8
Diffstat (limited to 'nova/exception.py')
| -rw-r--r-- | nova/exception.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/nova/exception.py b/nova/exception.py index 60cc5ae30..6a418af33 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -1075,6 +1075,11 @@ class InstanceUserDataMalformed(NovaException): message = _("User data needs to be valid base 64.") +class UnexpectedTaskStateError(NovaException): + message = _("unexpected task state: expecting %(expected)s but " + "the actual state is %(actual)s") + + def get_context_from_function_and_args(function, args, kwargs): """Find an arg of type RequestContext and return it. |
