Commit 30a44929 authored by Georgios D. Tsoukalas's avatar Georgios D. Tsoukalas

fix obscure bug in callpoint class that triggered db integrity errors

Callpoint class had a placeholder attribute original_calls
which was initialized as an empty dictionary,
and thus was usable. Class __init__() code did not initialize
original_calls as it should but because the placeholder was
usable it did not break. Alas, the placeholder is global
to all subclasses and their instances and one instance
leaked attributes and functionality to the other.

This caused the kamaki quotaholder client to be hijacked
and directly call the backend, which was available
on the same system/gunicorn deployment in our tests.
The backend was directly called from an astakos view that
had no transaction active (i.e. was on auto-commit).
Normally, the backend would be called from the
quotaholder_app view, which explicitly sets up a transaction.
parent 5f927596
......@@ -54,6 +54,9 @@ class Callpoint(object):
self.json_dumps = dumps
self.init_connection(connection)
original_calls = self.original_calls
if not original_calls:
original_calls = {}
self.original_calls = original_calls
canonifier = self.api_spec
if canonifier is None:
......
......@@ -484,6 +484,9 @@ class QuotaholderDjangoDBCallpoint(Callpoint):
h.policy = newp
h.flags = flags
# the order is intentionally reversed so that it
# would break if we are not within a transaction.
# Has helped before.
h.save()
newp.save()
......
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