summaryrefslogtreecommitdiff
path: root/nova/weights.py
diff options
context:
space:
mode:
authorBalazs Gibizer <balazs.gibizer@est.tech>2021-11-11 19:06:56 +0100
committerBalazs Gibizer <balazs.gibizer@est.tech>2021-11-11 19:10:32 +0100
commit154ab7b2f9ad80fe432d2c036d5e8c4ee171897b (patch)
treeb5eb2aca5f6425586bcc0327ee667030cc6854c1 /nova/weights.py
parenta1e7ed3670f925e07a398872d303ac2f3d4e3723 (diff)
downloadnova-154ab7b2f9ad80fe432d2c036d5e8c4ee171897b.tar.gz
Add debug log for scheduler weight calculation
We have all the weighers enabled by default and each can have its own multiplier making the final compute node order calculation pretty complex. This patch adds some debug logging that helps understanding how the final ordering was reached. Change-Id: I7606d6eb3e08548c1df9dc245ab39cced7de1fb5
Diffstat (limited to 'nova/weights.py')
-rw-r--r--nova/weights.py40
1 files changed, 36 insertions, 4 deletions
diff --git a/nova/weights.py b/nova/weights.py
index 97dc7d3291..75d51dc5f7 100644
--- a/nova/weights.py
+++ b/nova/weights.py
@@ -19,9 +19,14 @@ Pluggable Weighing support
import abc
+from oslo_log import log as logging
+
from nova import loadables
+LOG = logging.getLogger(__name__)
+
+
def normalize(weight_list, minval=None, maxval=None):
"""Normalize the values in a list between 0 and 1.0.
@@ -128,13 +133,40 @@ class BaseWeightHandler(loadables.BaseLoader):
for weigher in weighers:
weights = weigher.weigh_objects(weighed_objs, weighing_properties)
+ LOG.debug(
+ "%s: raw weights %s",
+ weigher.__class__.__name__,
+ {(obj.obj.host, obj.obj.nodename): weight
+ for obj, weight in zip(weighed_objs, weights)}
+ )
+
# Normalize the weights
- weights = normalize(weights,
- minval=weigher.minval,
- maxval=weigher.maxval)
+ weights = list(
+ normalize(
+ weights, minval=weigher.minval, maxval=weigher.maxval))
+
+ LOG.debug(
+ "%s: normalized weights %s",
+ weigher.__class__.__name__,
+ {(obj.obj.host, obj.obj.nodename): weight
+ for obj, weight in zip(weighed_objs, weights)}
+ )
+
+ log_data = {}
for i, weight in enumerate(weights):
obj = weighed_objs[i]
- obj.weight += weigher.weight_multiplier(obj.obj) * weight
+ multiplier = weigher.weight_multiplier(obj.obj)
+ weigher_score = multiplier * weight
+ obj.weight += weigher_score
+
+ log_data[(obj.obj.host, obj.obj.nodename)] = (
+ f"{multiplier} * {weight}")
+
+ LOG.debug(
+ "%s: score (multiplier * weight) %s",
+ weigher.__class__.__name__,
+ {name: log for name, log in log_data.items()}
+ )
return sorted(weighed_objs, key=lambda x: x.weight, reverse=True)