Merge "Fix aggregate metadata update/remove error"
This commit is contained in:
commit
e7c202cf7a
@ -841,6 +841,7 @@ class Connection(api.Connection):
|
||||
def aggregate_metadata_update_or_create(self, context, aggregate_id,
|
||||
metadata, max_retries=10):
|
||||
for attempt in range(max_retries):
|
||||
with _session_for_write() as session:
|
||||
try:
|
||||
query = model_query(
|
||||
context, models.AggregateMetadata).\
|
||||
@ -861,7 +862,6 @@ class Connection(api.Connection):
|
||||
metadata_ref.update({"key": key,
|
||||
"value": value,
|
||||
"aggregate_id": aggregate_id})
|
||||
with _session_for_write() as session:
|
||||
session.add(metadata_ref)
|
||||
session.flush()
|
||||
|
||||
@ -872,7 +872,8 @@ class Connection(api.Connection):
|
||||
if attempt < max_retries - 1:
|
||||
LOG.warning("Add metadata failed for aggregate %(id)s "
|
||||
"after %(retries)s retries",
|
||||
{"id": aggregate_id, "retries": max_retries})
|
||||
{"id": aggregate_id,
|
||||
"retries": max_retries})
|
||||
|
||||
def aggregate_metadata_get(self, context, aggregate_id):
|
||||
rows = model_query(context, models.AggregateMetadata). \
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Copyright 2017 Huawei Technologies Co.,LTD.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
@ -54,7 +53,7 @@ class Aggregate(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||
super(Aggregate, self).obj_reset_changes(fields=fields,
|
||||
recursive=recursive)
|
||||
if fields is None or 'metadata' in fields:
|
||||
self.orig_metadata = (dict(self.metadata)
|
||||
self._orig_metadata = (dict(self.metadata)
|
||||
if self.obj_attr_is_set('metadata')
|
||||
else {})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user