Merge "Logging Consistency"

This commit is contained in:
Zuul 2020-05-04 10:12:13 +00:00 committed by Gerrit Code Review
commit 0e7d99ac3f
14 changed files with 30 additions and 30 deletions

View File

@ -185,7 +185,7 @@ def add_command_parsers(subparsers):
parser.add_argument( parser.add_argument(
'-b', '--batch_size', default='20', '-b', '--batch_size', default='20',
help=_('Number of stacks to delete at a time (per transaction). ' help=_('Number of stacks to delete at a time (per transaction). '
'Note that a single stack may have many db rows ' 'Note that a single stack may have many DB rows '
'(events, etc.) associated with it.')) '(events, etc.) associated with it.'))
# update_params parser # update_params parser

View File

@ -46,7 +46,7 @@ class SymmetricCrypto(object):
Note: This is a reimplementation of the decryption algorithm from Note: This is a reimplementation of the decryption algorithm from
oslo-incubator, and is provided for backward compatibility. Once we have a oslo-incubator, and is provided for backward compatibility. Once we have a
db migration script available to re-encrypt using new encryption method as DB migration script available to re-encrypt using new encryption method as
part of upgrade, this can be removed. part of upgrade, this can be removed.
:param enctype: Encryption Cipher name (default: AES) :param enctype: Encryption Cipher name (default: AES)

View File

@ -340,7 +340,7 @@ def resource_attr_id_set(context, resource_id, atomic_key, attr_id):
else: else:
# Someone else set the attr_id first and/or we have a stale # Someone else set the attr_id first and/or we have a stale
# view of the resource based on atomic_key, so delete the # view of the resource based on atomic_key, so delete the
# resource_properties_data (attr) db row. # resource_properties_data (attr) DB row.
LOG.debug('Not updating res_id %(rid)s with attr_id %(aid)s', LOG.debug('Not updating res_id %(rid)s with attr_id %(aid)s',
{'rid': resource_id, 'aid': attr_id}) {'rid': resource_id, 'aid': attr_id})
session.query( session.query(
@ -974,7 +974,7 @@ def user_creds_get(context, user_creds_id):
db_result = context.session.query(models.UserCreds).get(user_creds_id) db_result = context.session.query(models.UserCreds).get(user_creds_id)
if db_result is None: if db_result is None:
return None return None
# Return a dict copy of db results, do not decrypt details into db_result # Return a dict copy of DB results, do not decrypt details into db_result
# or it can be committed back to the DB in decrypted form # or it can be committed back to the DB in decrypted form
result = dict(db_result) result = dict(db_result)
del result['decrypt_method'] del result['decrypt_method']
@ -1808,7 +1808,7 @@ def db_encrypt_parameters_and_properties(ctxt, encryption_key, batch_size=50,
:param ctxt: RPC context :param ctxt: RPC context
:param encryption_key: key that will be used for parameter and property :param encryption_key: key that will be used for parameter and property
encryption encryption
:param batch_size: number of templates requested from db in each iteration. :param batch_size: number of templates requested from DB in each iteration.
50 means that heat requests 50 templates, encrypt them 50 means that heat requests 50 templates, encrypt them
and proceed with next 50 items. and proceed with next 50 items.
:param verbose: log an INFO message when processing of each raw_template or :param verbose: log an INFO message when processing of each raw_template or
@ -1832,7 +1832,7 @@ def db_decrypt_parameters_and_properties(ctxt, encryption_key, batch_size=50,
:param ctxt: RPC context :param ctxt: RPC context
:param encryption_key: key that will be used for parameter and property :param encryption_key: key that will be used for parameter and property
decryption decryption
:param batch_size: number of templates requested from db in each iteration. :param batch_size: number of templates requested from DB in each iteration.
50 means that heat requests 50 templates, encrypt them 50 means that heat requests 50 templates, encrypt them
and proceed with next 50 items. and proceed with next 50 items.
:param verbose: log an INFO message when processing of each raw_template or :param verbose: log an INFO message when processing of each raw_template or
@ -1853,7 +1853,7 @@ def db_properties_data_migrate(ctxt, batch_size=50):
"""Migrate properties data from legacy columns to new location in db. """Migrate properties data from legacy columns to new location in db.
:param ctxt: RPC context :param ctxt: RPC context
:param batch_size: number of templates requested from db in each iteration. :param batch_size: number of templates requested from DB in each iteration.
50 means that heat requests 50 templates, encrypt them 50 means that heat requests 50 templates, encrypt them
and proceed with next 50 items. and proceed with next 50 items.
""" """

View File

@ -243,7 +243,7 @@ def format_stack(stack, preview=False, resolve_outputs=True):
def format_stack_db_object(stack): def format_stack_db_object(stack):
"""Return a summary representation of the given stack. """Return a summary representation of the given stack.
Given a stack versioned db object, return a representation of the given Given a stack versioned DB object, return a representation of the given
stack for a stack listing. stack for a stack listing.
""" """
updated_time = heat_timeutils.isotime(stack.updated_at) updated_time = heat_timeutils.isotime(stack.updated_at)

View File

@ -2062,7 +2062,7 @@ class Resource(status.ResourceStatus):
try: try:
resource_objects.Resource.delete(self.context, self.id) resource_objects.Resource.delete(self.context, self.id)
except exception.NotFound: except exception.NotFound:
# Don't fail on delete if the db entry has # Don't fail on delete if the DB entry has
# not been created yet. # not been created yet.
pass pass
@ -2077,7 +2077,7 @@ class Resource(status.ResourceStatus):
self.id, self.id,
{'physical_resource_id': self.resource_id}) {'physical_resource_id': self.resource_id})
except Exception as ex: except Exception as ex:
LOG.warning('db error %s', ex) LOG.warning('DB error %s', ex)
def store(self, set_metadata=False, lock=LOCK_NONE): def store(self, set_metadata=False, lock=LOCK_NONE):
"""Create the resource in the database. """Create the resource in the database.

View File

@ -365,7 +365,7 @@ class Instance(resource.Resource):
nic_dict['v4-fixed-ip'] = ip nic_dict['v4-fixed-ip'] = ip
nics.append(nic_dict) nics.append(nic_dict)
# create db instance # create DB instance
instance = self.client().instances.create( instance = self.client().instances.create(
self._dbinstance_name(), self._dbinstance_name(),
self.flavor, self.flavor,

View File

@ -2277,9 +2277,9 @@ class Stack(collections.Mapping):
requires = set(res_id_dep.requires(db_res.id)) requires = set(res_id_dep.requires(db_res.id))
r = self.resources.get(db_res.name) r = self.resources.get(db_res.name)
if r is None: if r is None:
# delete db resources not in current_template_id # delete DB resources not in current_template_id
LOG.warning("Resource %(res)s not found in template " LOG.warning("Resource %(res)s not found in template "
"for stack %(st)s, deleting from db.", "for stack %(st)s, deleting from DB.",
{'res': db_res.name, 'st': self.id}) {'res': db_res.name, 'st': self.id})
resource_objects.Resource.delete(self.context, db_res.id) resource_objects.Resource.delete(self.context, db_res.id)
else: else:

View File

@ -49,7 +49,7 @@ class TemplateFiles(collections.Mapping):
'(value is %(val)s)') % '(value is %(val)s)') %
{'cname': files.__class__, {'cname': files.__class__,
'val': str(files)}) 'val': str(files)})
# the dict has not been persisted as a raw_template_files db obj # the dict has not been persisted as a raw_template_files DB obj
# yet, so no self.files_id # yet, so no self.files_id
self.files = ReadOnlyDict(files) self.files = ReadOnlyDict(files)
@ -81,7 +81,7 @@ class TemplateFiles(collections.Mapping):
return iter(self.files) return iter(self.files)
def _refresh_if_needed(self): def _refresh_if_needed(self):
# retrieve files from db if needed # retrieve files from DB if needed
if self.files_id is None: if self.files_id is None:
return return
if self.files_id in _d: if self.files_id in _d:
@ -111,13 +111,13 @@ class TemplateFiles(collections.Mapping):
def update(self, files): def update(self, files):
# Sets up the next call to store() to create a new # Sets up the next call to store() to create a new
# raw_template_files db obj. It seems like we *could* just # raw_template_files DB obj. It seems like we *could* just
# update the existing raw_template_files obj, but the problem # update the existing raw_template_files obj, but the problem
# with that is other heat-engine processes' _d dictionaries # with that is other heat-engine processes' _d dictionaries
# would have stale data for a given raw_template_files.id with # would have stale data for a given raw_template_files.id with
# no way of knowing whether that data should be refreshed or # no way of knowing whether that data should be refreshed or
# not. So, just avoid the potential for weird race conditions # not. So, just avoid the potential for weird race conditions
# and create another db obj in the next store(). # and create another DB obj in the next store().
if len(files) == 0: if len(files) == 0:
return return
if not isinstance(files, dict): if not isinstance(files, dict):

View File

@ -51,7 +51,7 @@ class Event(
event._resource_properties = None event._resource_properties = None
for field in event.fields: for field in event.fields:
if field == 'resource_status_reason': if field == 'resource_status_reason':
# this works whether db_event is a dict or db ref # this works whether db_event is a dict or DB ref
event[field] = db_event['_resource_status_reason'] event[field] = db_event['_resource_status_reason']
else: else:
event[field] = db_event[field] event[field] = db_event[field]

View File

@ -49,7 +49,7 @@ class UserCreds(
return db_ucreds return db_ucreds
ucreds._context = context ucreds._context = context
for field in ucreds.fields: for field in ucreds.fields:
# TODO(Shao HE Feng), now the db layer delete the decrypt_method # TODO(Shao HE Feng), now the DB layer delete the decrypt_method
# field, just skip it here. and will add an encrypted_field later. # field, just skip it here. and will add an encrypted_field later.
if field == "decrypt_method": if field == "decrypt_method":
continue continue

View File

@ -1446,7 +1446,7 @@ def create_raw_template(context, **kwargs):
'template': t, 'template': t,
} }
if 'files' not in kwargs and 'files_id' not in kwargs: if 'files' not in kwargs and 'files_id' not in kwargs:
# modern raw_templates have associated raw_template_files db obj # modern raw_templates have associated raw_template_files DB obj
tf = template_files.TemplateFiles({'foo': 'bar'}) tf = template_files.TemplateFiles({'foo': 'bar'})
tf.store(context) tf.store(context)
kwargs['files_id'] = tf.files_id kwargs['files_id'] = tf.files_id
@ -3194,7 +3194,7 @@ class DBAPIResourceUpdateTest(common.HeatTestCase):
self.assertEqual('engine-1', db_res.engine_id) self.assertEqual('engine-1', db_res.engine_id)
self.assertEqual(1, db_res.atomic_key) self.assertEqual(1, db_res.atomic_key)
# Set engine id as engine-2 and pass expected engine id as old engine # Set engine id as engine-2 and pass expected engine id as old engine
# i.e engine-1 in db api steal the lock # i.e engine-1 in DB api steal the lock
values = {'engine_id': 'engine-2', values = {'engine_id': 'engine-2',
'action': 'DELETE', 'action': 'DELETE',
'status': 'IN_PROGRESS'} 'status': 'IN_PROGRESS'}

View File

@ -282,7 +282,7 @@ class EventEncryptedTest(EventCommon):
self.resource.name, self.resource.type()) self.resource.name, self.resource.type())
e.store() e.store()
# verify the resource_properties_data db data is encrypted # verify the resource_properties_data DB data is encrypted
e_obj = event_object.Event.get_all_by_stack(self.resource.context, e_obj = event_object.Event.get_all_by_stack(self.resource.context,
self.stack.id)[0] self.stack.id)[0]
rpd_id = e_obj['rsrc_prop_data_id'] rpd_id = e_obj['rsrc_prop_data_id']

View File

@ -991,7 +991,7 @@ class ResourceTest(common.HeatTestCase):
res.state_set(res.CREATE, res.IN_PROGRESS, 'test_store') res.state_set(res.CREATE, res.IN_PROGRESS, 'test_store')
# Modernity, the data is where it belongs # Modernity, the data is where it belongs
# The db object data is encrypted # The DB object data is encrypted
rsrc_prop_data_db_obj = db_api.resource_prop_data_get( rsrc_prop_data_db_obj = db_api.resource_prop_data_get(
self.stack.context, res._rsrc_prop_data_id) self.stack.context, res._rsrc_prop_data_id)
self.assertNotEqual(rsrc_prop_data_db_obj['data'], {'Foo': 'lucky'}) self.assertNotEqual(rsrc_prop_data_db_obj['data'], {'Foo': 'lucky'})
@ -1970,7 +1970,7 @@ class ResourceTest(common.HeatTestCase):
'prop4': ['a', 'list'], 'prop4': ['a', 'list'],
'prop5': True} 'prop5': True}
# The db data should be encrypted when _store() is called # The DB data should be encrypted when _store() is called
res = generic_rsrc.GenericResource('test_res_enc', tmpl, self.stack) res = generic_rsrc.GenericResource('test_res_enc', tmpl, self.stack)
res._stored_properties_data = stored_properties_data res._stored_properties_data = stored_properties_data
res._rsrc_prop_data = None res._rsrc_prop_data = None
@ -1979,7 +1979,7 @@ class ResourceTest(common.HeatTestCase):
self.assertNotEqual('string', self.assertNotEqual('string',
db_res.rsrc_prop_data.data['prop1']) db_res.rsrc_prop_data.data['prop1'])
# The db data should be encrypted when state_set is called # The DB data should be encrypted when state_set is called
res = generic_rsrc.GenericResource('test_res_enc', tmpl, self.stack) res = generic_rsrc.GenericResource('test_res_enc', tmpl, self.stack)
res._stored_properties_data = stored_properties_data res._stored_properties_data = stored_properties_data
res.state_set(res.CREATE, res.IN_PROGRESS, 'test_store') res.state_set(res.CREATE, res.IN_PROGRESS, 'test_store')
@ -2015,7 +2015,7 @@ class ResourceTest(common.HeatTestCase):
'prop4': ['a', 'list'], 'prop4': ['a', 'list'],
'prop5': True} 'prop5': True}
# The db data should not be encrypted when state_set() # The DB data should not be encrypted when state_set()
# is called # is called
res = generic_rsrc.GenericResource('test_res_enc', tmpl, self.stack) res = generic_rsrc.GenericResource('test_res_enc', tmpl, self.stack)
res._stored_properties_data = stored_properties_data res._stored_properties_data = stored_properties_data
@ -2024,7 +2024,7 @@ class ResourceTest(common.HeatTestCase):
db_res = db_api.resource_get(res.context, res.id) db_res = db_api.resource_get(res.context, res.id)
self.assertEqual('string', db_res.rsrc_prop_data.data['prop1']) self.assertEqual('string', db_res.rsrc_prop_data.data['prop1'])
# The db data should not be encrypted when _store() is called # The DB data should not be encrypted when _store() is called
res = generic_rsrc.GenericResource('test_res_enc', tmpl, self.stack) res = generic_rsrc.GenericResource('test_res_enc', tmpl, self.stack)
res._stored_properties_data = stored_properties_data res._stored_properties_data = stored_properties_data
db_res = db_api.resource_get(res.context, res.id) db_res = db_api.resource_get(res.context, res.id)

View File

@ -301,7 +301,7 @@ class StackTest(common.HeatTestCase):
all_resources = list(self.stack.iter_resources()) all_resources = list(self.stack.iter_resources())
# Verify, the db query is called with expected filter # Verify, the DB query is called with expected filter
mock_db_call.assert_called_once_with(self.ctx, self.stack.id) mock_db_call.assert_called_once_with(self.ctx, self.stack.id)
# And returns the resources # And returns the resources
@ -367,7 +367,7 @@ class StackTest(common.HeatTestCase):
filters=dict(name=['A']) filters=dict(name=['A'])
)) ))
# Verify, the db query is called with expected filter # Verify, the DB query is called with expected filter
mock_db_call.assert_has_calls([ mock_db_call.assert_has_calls([
mock.call(self.ctx, self.stack.id, dict(name=['A'])), mock.call(self.ctx, self.stack.id, dict(name=['A'])),
mock.call(self.ctx, self.stack.id), mock.call(self.ctx, self.stack.id),
@ -438,7 +438,7 @@ class StackTest(common.HeatTestCase):
filters=dict(name=['A']) filters=dict(name=['A'])
)) ))
# Verify, the db query is called with expected filter # Verify, the DB query is called with expected filter
mock_db_call.assert_has_calls([ mock_db_call.assert_has_calls([
mock.call(self.ctx, self.stack.id, dict(name=['A'])), mock.call(self.ctx, self.stack.id, dict(name=['A'])),
mock.call(self.ctx, self.stack.id), mock.call(self.ctx, self.stack.id),