Skip to content

Commit

Permalink
Log the operation when updating generation in ProviderTree
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mriedem committed Oct 19, 2018
1 parent 5b815ee commit 9c842d1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions nova/compute/provider_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,25 @@ def has_inventory_changed(self, new):
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):
"""Update the stored inventory for the provider along with a resource
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
Expand All @@ -179,7 +181,7 @@ def update_traits(self, new, generation=None):
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
Expand All @@ -204,7 +206,7 @@ def update_aggregates(self, new, generation=None):
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
Expand Down

0 comments on commit 9c842d1

Please sign in to comment.