Skip to content

Commit

Permalink
Fix an xmlrpc beaker error when count > 1
Browse files Browse the repository at this point in the history
This should fix CentOS-PaaS-SIG#1693 where two resources belong to the same
job are filtered to avoid xmlrpc condition
  • Loading branch information
Dannyb48 committed Mar 16, 2020
1 parent a04466a commit e512320
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion linchpin/FilterUtils/FilterUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ def fetch_beaker_job_ids(topo_out):
for entry in topo_out:
entry_dict = {}
entry_dict["ids"] = []
if "id" in list(entry):
# filter out if the resource's job id has already
# been added.
if "id" in list(entry) and not \
[id for ed in output
for id in ed.get("ids", []) if entry.get("id") == id[2:]]:
entry_dict["ids"].append("J:" + entry["id"])
output.append(entry_dict)
return output
Expand Down
7 changes: 7 additions & 0 deletions linchpin/tests/InventoryFilters/test_FilterPlugins_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ def test_fetch_beaker_job_ids():
assert_equals(expected,
filter_utils.fetch_beaker_job_ids(test_input))


def test_fetch_beaker_job_ids_count():
test_input = [{"id": "3124"}, {"id": "3124"}, {"id": "3214"}]
expected = [{'ids': ['J:3124']}, {'ids': ['J:3214']}]
assert_equals(expected,
filter_utils.fetch_beaker_job_ids(test_input))

def test_fetch_os_server_names():
test_input = [ {"resource_group": "openstack",
"role": "os_server",
Expand Down

0 comments on commit e512320

Please sign in to comment.