List missing streams in exception message.

Fixes: https://pagure.io/fm-orchestrator/issue/1574
This commit is contained in:
Joe Talbott
2021-06-17 13:41:05 -04:00
committed by Mike McLean
parent d1f2b85dea
commit b3203caf76
4 changed files with 11 additions and 5 deletions

View File

@@ -141,7 +141,7 @@ def get_base_module_mmds(db_session, mmd):
from module_build_service.common import models
seen = set()
ret = {"ready": [], "garbage": []}
ret = {"ready": [], "garbage": [], "missing": []}
resolver = GenericResolver.create(db_session, conf)
for deps in mmd.get_dependencies():
@@ -172,6 +172,7 @@ def get_base_module_mmds(db_session, mmd):
# zero or one module build.
mmds = resolver.get_module_modulemds(name, stream)
if not mmds:
ret["missing"] += [ns]
continue
base_mmd = mmds[0]

View File

@@ -187,9 +187,13 @@ def get_mmds_required_by_module_recursively(
base_module_mmds = get_base_module_mmds(db_session, mmd)
if not base_module_mmds["ready"]:
base_module_choices = " or ".join(conf.base_module_names)
missing = base_module_mmds["missing"]
missing_msg = ""
if missing:
missing_msg = " Missing streams are ({}).".format(", ".join(missing))
raise UnprocessableEntity(
"None of the base module ({}) streams in the buildrequires section could be found"
.format(base_module_choices)
"None of the base module ({}) streams in the buildrequires section could be found.{}"
.format(base_module_choices, missing_msg)
)
# Add base modules to `mmds`.

View File

@@ -100,6 +100,7 @@ class TestResolve:
expected = {}
expected["ready"] = {"platform:foo29", "platform:foo30"}
expected["garbage"] = {"platform:foo28"}
expected["missing"] = set()
# Verify no duplicates were returned before doing set operations
assert len(mmds) == len(expected)

View File

@@ -1035,7 +1035,7 @@ class TestSubmitBuild:
"status": 422,
"message": (
"None of the base module (platform) streams in the buildrequires section "
"could be found"
"could be found. Missing streams are (platform:Go)."
),
"error": "Unprocessable Entity",
}
@@ -2395,7 +2395,7 @@ class TestSubmitBuild:
"status": 422,
"message": (
"None of the base module (platform) streams in the buildrequires "
"section could be found"
"section could be found. Missing streams are (platform:28.0.0)."
),
}
assert rv.status_code == 422