Commit 6f159c83 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Wrap diagnostic creation in transaction

Fix bug in snf-dispatcher causing wrong updates of VMs from ganeti.
Creation if instance diagnostics must run inside a transaction, because
otherwise, the lock of the vm (select_for_update) is released too early.
Specifally, 'if_update_required' takes a lock on the VM and checks if
the timestamp of the message is newer than the one in the VM. If
diagnostic creation ('create_instance_diagnostic' function) does not run
inside a transaction, the lock is released when the diagnostic row is
inserted in the DB. However, after storing the diagnostic, the VM is
saved in order to update the 'updated' timestamp (otherwise,
MODIFIED_SINCE does not work correctly). In the meantime, another
message may update the VM, and this update will be lost. This commit
wrap 'create_instance_diagnostic' inside transaction to fix this issue.
parent c177e8d9
......@@ -359,6 +359,7 @@ def process_create_progress(vm, etime, progress):
vm.save()
@transaction.commit_on_success
def create_instance_diagnostic(vm, message, source, level="DEBUG", etime=None,
details=None):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment