summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-04-06 18:04:04 +0000
committerGerrit Code Review <review@openstack.org>2023-04-06 18:04:04 +0000
commit706ee6010a3720b9d9faf72d6782665b6eb083a7 (patch)
treef9d285887f1f42650264f4407b66d5b14ca34acf
parentfee3c77fd5a4bf8453cbe80e93aa9a898dacccc1 (diff)
parent30c7180e1e655176952609e80f1f21cf8b6d13a0 (diff)
downloadnova-706ee6010a3720b9d9faf72d6782665b6eb083a7.tar.gz
Merge "Add debug log for scheduler weight calculation" into stable/xenaxena-em24.2.1
-rw-r--r--nova/weights.py40
1 files changed, 36 insertions, 4 deletions
diff --git a/nova/weights.py b/nova/weights.py
index a093df0345..b88caaa186 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.
@@ -127,13 +132,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)