Skip to content

Commit

Permalink
Fix traceback running instance-usage-audit
Browse files Browse the repository at this point in the history
There were two errors here:
    1 was a missed joinload that was causing an error pulling info_cache.
    2 the exception listed in the bug, which was caused by tring to load data for a deleted instance.

This fixes bug 934539

Change-Id: Ifffb6a35c1f7bf8caa6f57d33b29b58d0dbe10b3
  • Loading branch information
DragonDM committed Feb 17, 2012
1 parent 2471629 commit 13789e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nova/compute/utils.py
Expand Up @@ -37,7 +37,7 @@ def notify_usage_exists(instance_ref, current_period=False):
Generates usage for last completed period, unless 'current_period'
is True."""
admin_context = context.get_admin_context()
admin_context = context.get_admin_context(read_deleted='yes')
begin, end = utils.current_audit_period()
bw = {}
if current_period:
Expand Down
4 changes: 3 additions & 1 deletion nova/db/sqlalchemy/api.py
Expand Up @@ -1610,7 +1610,9 @@ def instance_get_active_by_window_joined(context, begin, end=None,
session = get_session()
query = session.query(models.Instance)

query = query.options(joinedload('security_groups')).\
query = query.options(joinedload('info_cache')).\
options(joinedload('security_groups')).\
options(joinedload('metadata')).\
options(joinedload('instance_type')).\
filter(or_(models.Instance.terminated_at == None,
models.Instance.terminated_at > begin))
Expand Down

0 comments on commit 13789e9

Please sign in to comment.