[PATCH] osmo-gsm-tester[master]: improve logging for resource allocation

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Sun May 7 00:58:56 UTC 2017


Review at  https://gerrit.osmocom.org/2517

improve logging for resource allocation

Log on level 'log', more clearly show whether it's for reservation or actual
use, show the origin that is asking for them.

Change-Id: I3b78c7bdcaec90943900343c878099160f8d2f64
---
M src/osmo_gsm_tester/resource.py
1 file changed, 6 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/17/2517/1

diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index 87ea551..2dbcb85 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -148,7 +148,7 @@
         with self.state_dir.lock(origin_id):
             rrfile_path = self.state_dir.mk_parentdir(RESERVED_RESOURCES_FILE)
             reserved = Resources(config.read(rrfile_path, if_missing_return={}))
-            to_be_reserved = self.all_resources.without(reserved).find(want)
+            to_be_reserved = self.all_resources.without(reserved).find(origin, want)
 
             to_be_reserved.mark_reserved_by(origin_id)
 
@@ -270,13 +270,12 @@
     def without(self, reserved):
         return Resources(self).drop(reserved)
 
-    def find(self, want, skip_if_marked=None, do_copy=True):
+    def find(self, for_origin, want, skip_if_marked=None, do_copy=True, log_label='Reserving'):
         matches = {}
         for key, want_list in sorted(want.items()): # sorted for deterministic test results
-          with log.Origin(want=key):
             my_list = self.get(key)
 
-            log.dbg(None, None, 'Looking for', len(want_list), 'x', key, ', candidates:', len(my_list))
+            for_origin.log(log_label, len(want_list), 'x', key, '(candidates: %d)'%len(my_list))
 
             # Try to avoid a less constrained item snatching away a resource
             # from a more detailed constrained requirement.
@@ -303,7 +302,7 @@
             # figure out who gets what
             solution = solve(all_matches)
             picked = [ my_list[i] for i in solution if i is not None ]
-            log.dbg(None, None, 'Picked', config.tostr(picked))
+            for_origin.dbg('Picked', config.tostr(picked))
             matches[key] = picked
 
         return Resources(matches, do_copy=do_copy)
@@ -421,7 +420,8 @@
             specifics = {}
         self.dbg('requesting use of', kind, specifics=specifics)
         want = { kind: [specifics] }
-        available_dict = self.reserved.find(want, skip_if_marked=USED_KEY, do_copy=False)
+        available_dict = self.reserved.find(self.origin, want, skip_if_marked=USED_KEY, do_copy=False,
+                                            log_label='Using')
         available = available_dict.get(kind)
         self.dbg(available=len(available))
         if not available:

-- 
To view, visit https://gerrit.osmocom.org/2517
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3b78c7bdcaec90943900343c878099160f8d2f64
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list