Browse Source

Log the operation when updating generation in ProviderTree

Today when a provider generation is updated we get a mostly
unhelpful message in the logs like:

  Updating resource provider bc0f4c8e-96e2-4e68-a06e-f7e0ac9aac6b
  generation from 0 to 1

What we really want to know with that is in what context did the
generation change, i.e. did inventory or traits change?

This adds the actual operation to the log message when generation
changes.

Change-Id: I9b61f1dfb8db06e02ff79e19c055c673094a4ed2
Related-Bug: #1789654
changes/53/597553/3
Matt Riedemann 3 years ago
parent
commit
9c842d1aa6
  1. 12
      nova/compute/provider_tree.py

12
nova/compute/provider_tree.py

@ -148,15 +148,17 @@ class _Provider(object):
return True
return False
def _update_generation(self, generation):
def _update_generation(self, generation, operation):
if generation is not None and generation != self.generation:
msg_args = {
'rp_uuid': self.uuid,
'old': self.generation,
'new': generation,
'op': operation
}
LOG.debug("Updating resource provider %(rp_uuid)s generation "
"from %(old)s to %(new)s", msg_args)
"from %(old)s to %(new)s during operation: %(op)s",
msg_args)
self.generation = generation
def update_inventory(self, inventory, generation):
@ -164,7 +166,7 @@ class _Provider(object):
provider generation to set the provider to. The method returns whether
the inventory has changed.
"""
self._update_generation(generation)
self._update_generation(generation, 'update_inventory')
if self.has_inventory_changed(inventory):
self.inventory = copy.deepcopy(inventory)
return True
@ -179,7 +181,7 @@ class _Provider(object):
provider generation to set the provider to. The method returns whether
the traits have changed.
"""
self._update_generation(generation)
self._update_generation(generation, 'update_traits')
if self.have_traits_changed(new):
self.traits = set(new) # create a copy of the new traits
return True
@ -204,7 +206,7 @@ class _Provider(object):
provider generation to set the provider to. The method returns whether
the aggregates have changed.
"""
self._update_generation(generation)
self._update_generation(generation, 'update_aggregates')
if self.have_aggregates_changed(new):
self.aggregates = set(new) # create a copy of the new aggregates
return True

Loading…
Cancel
Save