The Case of the Mysterious Dist Tag

We ran into a crazy bug in stg today where the `disttag` of every
component build .. for every module .. was the same!  (duh duh duh).

Turns out this had to do with the way we were writing the name, stream,
and version values back into the yaml file we recorded.  More correctly,
how we *weren't* writing those values back.
This commit is contained in:
Ralph Bean
2017-11-02 13:36:18 -04:00
parent 089a0c3db4
commit 9b006e1ba5
2 changed files with 11 additions and 7 deletions

View File

@@ -593,7 +593,8 @@ def _fetch_mmd(url, branch=None, allow_local_url=False, whitelist_url=False):
else:
mmd.version = int(scm.version)
return mmd, scm, yaml
return mmd, scm
def load_mmd(yaml):
@@ -936,7 +937,7 @@ def submit_module_build_from_yaml(username, handle, optional_params=None):
mmd.name = mmd.name or def_name
mmd.stream = mmd.stream or "master"
mmd.version = mmd.version or def_version
return submit_module_build(username, None, mmd, None, yaml, optional_params)
return submit_module_build(username, None, mmd, None, optional_params)
_url_check_re = re.compile(r"^[^:/]+:.*$")
@@ -950,13 +951,13 @@ def submit_module_build_from_scm(username, url, branch, allow_local_url=False,
"'{}' is not a valid URL, assuming local path".format(url))
url = os.path.abspath(url)
url = "file://" + url
mmd, scm, yaml = _fetch_mmd(url, branch, allow_local_url)
mmd, scm = _fetch_mmd(url, branch, allow_local_url)
if skiptests:
mmd.buildopts.rpms.macros += "\n\n%__spec_check_pre exit 0\n"
return submit_module_build(username, url, mmd, scm, yaml, optional_params)
return submit_module_build(username, url, mmd, scm, optional_params)
def submit_module_build(username, url, mmd, scm, yaml, optional_params=None):
def submit_module_build(username, url, mmd, scm, optional_params=None):
# Import it here, because SCM uses utils methods
# and fails to import them because of dep-chain.
validate_mmd(mmd)
@@ -991,7 +992,7 @@ def submit_module_build(username, url, mmd, scm, yaml, optional_params=None):
name=mmd.name,
stream=mmd.stream,
version=str(mmd.version),
modulemd=yaml,
modulemd=mmd.dumps(),
scmurl=url,
username=username,
**(optional_params or {})
@@ -1398,6 +1399,9 @@ def get_rpm_release_from_mmd(mmd):
Returns the dist tag based on the modulemd metadata and MBS configuration.
"""
if not mmd.name or not mmd.stream or not mmd.version:
raise ValueError("Modulemd name, stream, and version are required.")
dist_str = '.'.join([mmd.name, mmd.stream, str(mmd.version)])
dist_hash = hashlib.sha1(dist_str).hexdigest()[:8]
return conf.default_dist_tag_prefix + dist_hash

View File

@@ -292,7 +292,7 @@ class TestBuild(unittest.TestCase):
# Check that the components are added to buildroot after the batch
# is built.
buildroot_groups = []
buildroot_groups.append(set([u'module-build-macros-0.1-1.module+24957a32.src.rpm-1-1']))
buildroot_groups.append(set([u'module-build-macros-0.1-1.module+fc4ed5f7.src.rpm-1-1']))
buildroot_groups.append(set([u'perl-Tangerine?#f24-1-1', u'perl-List-Compare?#f25-1-1']))
buildroot_groups.append(set([u'tangerine?#f23-1-1']))