From a7cca3e29882e5dfacfb8f848cd710e9f027b8e2 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Fri, 16 Oct 2020 15:32:56 +0200
Subject: [PATCH] TMSS-190: more elaborate warning logging about the
 conflicting_claims, their resources, and why they are in conflict and with
 who

---
 .../ResourceAssigner/lib/schedulers.py        | 22 +++++++++++++------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/SAS/ResourceAssignment/ResourceAssigner/lib/schedulers.py b/SAS/ResourceAssignment/ResourceAssigner/lib/schedulers.py
index ea374250236..a2d282ce204 100644
--- a/SAS/ResourceAssignment/ResourceAssigner/lib/schedulers.py
+++ b/SAS/ResourceAssignment/ResourceAssigner/lib/schedulers.py
@@ -283,13 +283,21 @@ class BasicScheduler(object):
             # up more resources as a by-product, in which case other conflicts can simply be shifted to those newly freed
             # resources.
             conflict_claims = self.radb.getResourceClaims(task_ids=[self.task_id], status="conflict", extended=True)
-            logger.info("Resulting claims in conflict before resolution: %s", conflict_claims)
-
-            if conflict_claims and not any([self._resolve_conflict(c) for c in conflict_claims]):
-                if need_all or len(conflict_claims) == len(tentative_claims):
-                    # Could not resolve any conflict
-                    raise ScheduleException("Could not resolve one or more conflicting claims: #tentative_claims=%s #conflict_claims=%s conflict_claims=%s" % (
-                                            len(tentative_claims), len(conflict_claims), conflict_claims))
+            if conflict_claims:
+                for conflict_claim in conflict_claims:
+                    logger.warning("conflicting_claim: %s\nresource:%s\noverlapping_claims:%s\noverlapping_tasks:%s", conflict_claim,
+                                   self.radb.getResources(resource_ids=[conflict_claim['resource_id']],
+                                                          include_availability=True,
+                                                          claimable_capacity_lower_bound=conflict_claim['starttime'],
+                                                          claimable_capacity_upper_bound=conflict_claim['endtime'])[0],
+                                   self.radb.get_overlapping_claims(conflict_claim['id']),
+                                   self.radb.get_overlapping_tasks(conflict_claim['id']))
+
+                if not any([self._resolve_conflict(c) for c in conflict_claims]):
+                    if need_all or len(conflict_claims) == len(tentative_claims):
+                        # Could not resolve any conflict
+                        raise ScheduleException("Could not resolve one or more conflicting claims: #tentative_claims=%s #conflict_claims=%s conflict_claims=%s" % (
+                                                len(tentative_claims), len(conflict_claims), conflict_claims))
 
             # remove conflicting claims (allowing the next iteration to propose alternatives). Note that _handle_conflicts
             # could have reduced the number of conflicting claims.
-- 
GitLab