Skip to content

Commit

Permalink
Merge "Add debug logs for when provider inventory changes"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Oct 24, 2018
2 parents ec89e48 + ade240b commit 7a76d0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions nova/compute/provider_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ def update_inventory(self, inventory, generation):
"""
self._update_generation(generation, 'update_inventory')
if self.has_inventory_changed(inventory):
LOG.debug('Updating inventory in ProviderTree for provider %s '
'with inventory: %s', self.uuid, inventory)
self.inventory = copy.deepcopy(inventory)
return True
LOG.debug('Inventory has not changed in ProviderTree for provider: %s',
self.uuid)
return False

def have_traits_changed(self, new):
Expand Down
17 changes: 14 additions & 3 deletions nova/scheduler/client/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,9 @@ def _refresh_and_get_inventory(self, context, rp_uuid):
if curr is None:
return None

LOG.debug('Updating ProviderTree inventory for provider %s from '
'_refresh_and_get_inventory using data: %s', rp_uuid,
curr['inventories'])
self._provider_tree.update_inventory(
rp_uuid, curr['inventories'],
generation=curr['resource_provider_generation'])
Expand Down Expand Up @@ -863,12 +866,15 @@ def _update_inventory_attempt(self, context, rp_uuid, inv_data):
# update_resource_stats() is called? :(
curr = self._refresh_and_get_inventory(context, rp_uuid)
if curr is None:
LOG.debug('No inventory for provider: %s', rp_uuid, inv_data)
return False

cur_gen = curr['resource_provider_generation']

# Check to see if we need to update placement's view
if not self._provider_tree.has_inventory_changed(rp_uuid, inv_data):
LOG.debug('Inventory has not changed for provider %s based '
'on inventory data: %s', rp_uuid, inv_data)
return True

payload = {
Expand Down Expand Up @@ -961,11 +967,11 @@ def _update_inventory_attempt(self, context, rp_uuid, inv_data):
# Update our view of the generation for next time
updated_inventories_result = result.json()
new_gen = updated_inventories_result['resource_provider_generation']

LOG.debug('Updating ProviderTree inventory for provider %s with '
'generation %s from _update_inventory_attempt with data: '
'%s', rp_uuid, new_gen, inv_data)
self._provider_tree.update_inventory(rp_uuid, inv_data,
generation=new_gen)
LOG.debug('Updated inventory for %s at generation %i',
rp_uuid, new_gen)
return True

@safe_connect
Expand Down Expand Up @@ -1110,6 +1116,8 @@ def do_put(url, payload):

# If not different from what we've got, short out
if not self._provider_tree.has_inventory_changed(rp_uuid, inv_data):
LOG.debug('Inventory has not changed for provider %s based '
'on inventory data: %s', rp_uuid, inv_data)
return

# Ensure non-standard resource classes exist, creating them if needed.
Expand All @@ -1125,6 +1133,9 @@ def do_put(url, payload):
resp = do_put(url, payload)

if resp.status_code == 200:
LOG.debug('Updated inventory for provider %s with generation %s '
'in Placement from _set_inventory_for_provider using '
'data: %s', rp_uuid, generation, inv_data)
json = resp.json()
self._provider_tree.update_inventory(
rp_uuid, json['inventories'],
Expand Down

0 comments on commit 7a76d0c

Please sign in to comment.