Skip to content

Commit ade240b

Browse files
committed
Add debug logs for when provider inventory changes
Because of the ProviderTree caching involved in both the ResourceTracker and SchedulerReportClient, it can be hard to know if inventory changes are being correctly reported to the placement service as expected, especially with things like configurable allocation ratios. This adds debug logs to the SchedulerReportClient and ProviderTree to determine if inventory has changed and when it's flushed back to placement. Change-Id: Ia6ab3ab4dea08b479bb6b794f408fd2e6f678c50 Related-Bug: #1789654
1 parent 9c842d1 commit ade240b

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

nova/compute/provider_tree.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ def update_inventory(self, inventory, generation):
168168
"""
169169
self._update_generation(generation, 'update_inventory')
170170
if self.has_inventory_changed(inventory):
171+
LOG.debug('Updating inventory in ProviderTree for provider %s '
172+
'with inventory: %s', self.uuid, inventory)
171173
self.inventory = copy.deepcopy(inventory)
172174
return True
175+
LOG.debug('Inventory has not changed in ProviderTree for provider: %s',
176+
self.uuid)
173177
return False
174178

175179
def have_traits_changed(self, new):

nova/scheduler/client/report.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,9 @@ def _refresh_and_get_inventory(self, context, rp_uuid):
756756
if curr is None:
757757
return None
758758

759+
LOG.debug('Updating ProviderTree inventory for provider %s from '
760+
'_refresh_and_get_inventory using data: %s', rp_uuid,
761+
curr['inventories'])
759762
self._provider_tree.update_inventory(
760763
rp_uuid, curr['inventories'],
761764
generation=curr['resource_provider_generation'])
@@ -863,12 +866,15 @@ def _update_inventory_attempt(self, context, rp_uuid, inv_data):
863866
# update_resource_stats() is called? :(
864867
curr = self._refresh_and_get_inventory(context, rp_uuid)
865868
if curr is None:
869+
LOG.debug('No inventory for provider: %s', rp_uuid, inv_data)
866870
return False
867871

868872
cur_gen = curr['resource_provider_generation']
869873

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

874880
payload = {
@@ -961,11 +967,11 @@ def _update_inventory_attempt(self, context, rp_uuid, inv_data):
961967
# Update our view of the generation for next time
962968
updated_inventories_result = result.json()
963969
new_gen = updated_inventories_result['resource_provider_generation']
964-
970+
LOG.debug('Updating ProviderTree inventory for provider %s with '
971+
'generation %s from _update_inventory_attempt with data: '
972+
'%s', rp_uuid, new_gen, inv_data)
965973
self._provider_tree.update_inventory(rp_uuid, inv_data,
966974
generation=new_gen)
967-
LOG.debug('Updated inventory for %s at generation %i',
968-
rp_uuid, new_gen)
969975
return True
970976

971977
@safe_connect
@@ -1110,6 +1116,8 @@ def do_put(url, payload):
11101116

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

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

11271135
if resp.status_code == 200:
1136+
LOG.debug('Updated inventory for provider %s with generation %s '
1137+
'in Placement from _set_inventory_for_provider using '
1138+
'data: %s', rp_uuid, generation, inv_data)
11281139
json = resp.json()
11291140
self._provider_tree.update_inventory(
11301141
rp_uuid, json['inventories'],

0 commit comments

Comments
 (0)