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.orgNeels Hofmeyr has submitted this change and it was merged.
Change subject: error log: clarify for reserving more resources than available
......................................................................
error log: clarify for reserving more resources than available
When trying to reserve more resources than available in the resources.conf,
actually print an intelligible error message: catch the nameless error from
solve() and fill in what was requested for solution.
Change-Id: Iba3707f1aaeb40a58c616c33af52a60c9a2e7e1f
---
M selftest/resource_test.py
M src/osmo_gsm_tester/resource.py
2 files changed, 13 insertions(+), 4 deletions(-)
Approvals:
Pau Espin Pedrol: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/selftest/resource_test.py b/selftest/resource_test.py
index 08f1fbf..c78485e 100755
--- a/selftest/resource_test.py
+++ b/selftest/resource_test.py
@@ -39,7 +39,7 @@
[2],
[0, 2] ])
assert False
-except resource.NoResourceExn as e:
+except resource.NotSolvable as e:
print(e)
print('- test removing a Resources list from itself')
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index 3e8924a..52b23c7 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -337,7 +337,13 @@
continue
# figure out who gets what
- solution = solve(all_matches)
+ try:
+ solution = solve(all_matches)
+ except NotSolvable:
+ # instead of a cryptic error message, raise an exception that
+ # conveys meaning to the user.
+ raise NoResourceExn('Could not resolve request to reserve resources: '
+ '%d x %s with requirements: %r' % (len(want_list), key, want_list))
picked = [ my_list[i] for i in solution if i is not None ]
for_origin.dbg('Picked', config.tostr(picked))
matches[key] = picked
@@ -364,6 +370,9 @@
for item in item_list:
item[RESERVED_KEY] = origin_id
+
+class NotSolvable(Exception):
+ pass
def solve(all_matches):
'''
@@ -403,8 +412,8 @@
solution = search_in_permutations()
if not solution:
- raise NoResourceExn('The requested resource requirements are not solvable %r'
- % all_matches)
+ raise NotSolvable('The requested resource requirements are not solvable %r'
+ % all_matches)
return solution
--
To view, visit https://gerrit.osmocom.org/2851
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iba3707f1aaeb40a58c616c33af52a60c9a2e7e1f
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>