pkgset: Check tag inheritance change before reuse

JIRA: RHELCMP-2453
Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2021-01-29 12:00:54 +08:00
parent 49a5661521
commit d4ee42ec23
2 changed files with 28 additions and 8 deletions

View File

@ -731,17 +731,22 @@ class KojiPackageSet(PackageSetBase):
% (old_koji_event, koji_event) % (old_koji_event, koji_event)
) )
changed = self.koji_proxy.queryHistory( changed = self.koji_proxy.queryHistory(
tables=["tag_listing"], tag=tag, afterEvent=old_koji_event tables=["tag_listing", "tag_inheritance"],
tag=tag,
afterEvent=old_koji_event,
) )
if changed["tag_listing"]: if changed["tag_listing"]:
self.log_debug("Builds under tag %s changed. Can't reuse." % tag) self.log_debug("Builds under tag %s changed. Can't reuse." % tag)
return False return False
if changed["tag_inheritance"]:
self.log_debug("Tag inheritance %s changed. Can't reuse." % tag)
return False
if inherit: if inherit:
inherit_tags = self.koji_proxy.getFullInheritance(tag, koji_event) inherit_tags = self.koji_proxy.getFullInheritance(tag, koji_event)
for t in inherit_tags: for t in inherit_tags:
changed = self.koji_proxy.queryHistory( changed = self.koji_proxy.queryHistory(
tables=["tag_listing"], tables=["tag_listing", "tag_inheritance"],
tag=t["name"], tag=t["name"],
afterEvent=old_koji_event, afterEvent=old_koji_event,
beforeEvent=koji_event + 1, beforeEvent=koji_event + 1,
@ -752,6 +757,9 @@ class KojiPackageSet(PackageSetBase):
% t["name"] % t["name"]
) )
return False return False
if changed["tag_inheritance"]:
self.log_debug("Tag inheritance %s changed. Can't reuse." % tag)
return False
repo_dir = compose.paths.work.pkgset_repo(tag, create_dir=False) repo_dir = compose.paths.work.pkgset_repo(tag, create_dir=False)
old_repo_dir = compose.paths.old_compose_path(repo_dir) old_repo_dir = compose.paths.old_compose_path(repo_dir)

View File

@ -632,7 +632,10 @@ class TestReuseKojiPkgset(helpers.PungiTestCase):
def test_reuse_build_under_tag_changed(self, mock_old_topdir): def test_reuse_build_under_tag_changed(self, mock_old_topdir):
mock_old_topdir.return_value = self.old_compose_dir mock_old_topdir.return_value = self.old_compose_dir
self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1]) self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1])
self.koji_wrapper.koji_proxy.queryHistory.return_value = {"tag_listing": [{}]} self.koji_wrapper.koji_proxy.queryHistory.return_value = {
"tag_listing": [{}],
"tag_inheritance": [],
}
self.pkgset.try_to_reuse(self.compose, self.tag) self.pkgset.try_to_reuse(self.compose, self.tag)
@ -652,8 +655,8 @@ class TestReuseKojiPkgset(helpers.PungiTestCase):
mock_old_topdir.return_value = self.old_compose_dir mock_old_topdir.return_value = self.old_compose_dir
self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1]) self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1])
self.koji_wrapper.koji_proxy.queryHistory.side_effect = [ self.koji_wrapper.koji_proxy.queryHistory.side_effect = [
{"tag_listing": []}, {"tag_listing": [], "tag_inheritance": []},
{"tag_listing": [{}]}, {"tag_listing": [{}], "tag_inheritance": []},
] ]
self.koji_wrapper.koji_proxy.getFullInheritance.return_value = [ self.koji_wrapper.koji_proxy.getFullInheritance.return_value = [
{"name": self.inherited_tag} {"name": self.inherited_tag}
@ -680,7 +683,10 @@ class TestReuseKojiPkgset(helpers.PungiTestCase):
def test_reuse_failed_load_reuse_file(self, mock_old_topdir, mock_exists): def test_reuse_failed_load_reuse_file(self, mock_old_topdir, mock_exists):
mock_old_topdir.return_value = self.old_compose_dir mock_old_topdir.return_value = self.old_compose_dir
self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1]) self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1])
self.koji_wrapper.koji_proxy.queryHistory.return_value = {"tag_listing": []} self.koji_wrapper.koji_proxy.queryHistory.return_value = {
"tag_listing": [],
"tag_inheritance": [],
}
self.koji_wrapper.koji_proxy.getFullInheritance.return_value = [] self.koji_wrapper.koji_proxy.getFullInheritance.return_value = []
self.pkgset.load_old_file_cache = mock.Mock( self.pkgset.load_old_file_cache = mock.Mock(
side_effect=Exception("unknown error") side_effect=Exception("unknown error")
@ -712,7 +718,10 @@ class TestReuseKojiPkgset(helpers.PungiTestCase):
def test_reuse_criteria_not_match(self, mock_old_topdir, mock_exists): def test_reuse_criteria_not_match(self, mock_old_topdir, mock_exists):
mock_old_topdir.return_value = self.old_compose_dir mock_old_topdir.return_value = self.old_compose_dir
self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1]) self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1])
self.koji_wrapper.koji_proxy.queryHistory.return_value = {"tag_listing": []} self.koji_wrapper.koji_proxy.queryHistory.return_value = {
"tag_listing": [],
"tag_inheritance": [],
}
self.koji_wrapper.koji_proxy.getFullInheritance.return_value = [] self.koji_wrapper.koji_proxy.getFullInheritance.return_value = []
self.pkgset.load_old_file_cache = mock.Mock( self.pkgset.load_old_file_cache = mock.Mock(
return_value={"allow_invalid_sigkeys": True} return_value={"allow_invalid_sigkeys": True}
@ -751,7 +760,10 @@ class TestReuseKojiPkgset(helpers.PungiTestCase):
def test_reuse_pkgset(self, mock_old_topdir, mock_exists, mock_copy_all): def test_reuse_pkgset(self, mock_old_topdir, mock_exists, mock_copy_all):
mock_old_topdir.return_value = self.old_compose_dir mock_old_topdir.return_value = self.old_compose_dir
self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1]) self.pkgset._get_koji_event_from_file = mock.Mock(side_effect=[3, 1])
self.koji_wrapper.koji_proxy.queryHistory.return_value = {"tag_listing": []} self.koji_wrapper.koji_proxy.queryHistory.return_value = {
"tag_listing": [],
"tag_inheritance": [],
}
self.koji_wrapper.koji_proxy.getFullInheritance.return_value = [] self.koji_wrapper.koji_proxy.getFullInheritance.return_value = []
self.pkgset.load_old_file_cache = mock.Mock( self.pkgset.load_old_file_cache = mock.Mock(
return_value={ return_value={