Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Revert "[ART-4753]: Complain when rhcos-es are from different openshi…
Browse files Browse the repository at this point in the history
…ft/os commits"
  • Loading branch information
joepvd committed Oct 14, 2022
1 parent bb4085a commit 9b919ec
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 53 deletions.
1 change: 0 additions & 1 deletion doozerlib/assembly.py
Expand Up @@ -22,7 +22,6 @@ class AssemblyIssueCode(Enum):
INCONSISTENT_RHCOS_RPMS = 5
MISSING_INHERITED_DEPENDENCY = 6
MISSING_RHCOS_CONTAINER = 7
INCONSISTENT_OS_COMMIT = 8


class AssemblyIssue:
Expand Down
30 changes: 1 addition & 29 deletions doozerlib/cli/release_gen_payload.py
Expand Up @@ -508,7 +508,6 @@ def detect_extend_payload_entry_issues(self, assembly_inspector: AssemblyInspect
raise DoozerFatalError(f"Unsupported PayloadEntry: {payload_entry}")

self.detect_rhcos_inconsistent_rpms(targeted_rhcos_builds) # across all arches
self.detect_rhcos_inconsistent_os_commit(targeted_rhcos_builds) # across all arches

def detect_rhcos_issues(self, payload_entry, assembly_inspector: AssemblyInspector):
"""
Expand Down Expand Up @@ -537,23 +536,11 @@ def detect_rhcos_inconsistent_rpms(self, targeted_rhcos_builds: Dict[bool, List[
rhcos_inconsistencies: Dict[str, List[str]] = PayloadGenerator.find_rhcos_build_rpm_inconsistencies(rhcos_builds)
if rhcos_inconsistencies:
self.assembly_issues.append(AssemblyIssue(
f"Found inconsistent rpms in RHCOS builds {rhcos_builds} "
f"Found RHCOS inconsistencies in builds {rhcos_builds} "
f"(private={privacy_mode}): {rhcos_inconsistencies}",
component="rhcos", code=AssemblyIssueCode.INCONSISTENT_RHCOS_RPMS
))

def detect_rhcos_inconsistent_os_commit(self, targeted_rhcos_builds: Dict[bool, List[RHCOSBuildInspector]]):
"""Generate assembly issues if RHCOS builds do not have matching openshift/os commits across arches."""
for privacy_mode in self.privacy_modes: # only for relevant modes
rhcos_builds = targeted_rhcos_builds[privacy_mode]
os_commit_inconsistencies: Dict[str, List[str]] = PayloadGenerator.find_rhcos_os_commit_inconsistencies(rhcos_builds)
if os_commit_inconsistencies:
self.assembly_issues.append(AssemblyIssue(
f"Found inconsistent openshift/os commits in RHCOS builds {rhcos_builds} "
f"(private={privacy_mode}): {os_commit_inconsistencies}",
component="rhcos", code=AssemblyIssueCode.INCONSISTENT_OS_COMMIT
))

def summarize_issue_permits(self, assembly_inspector: AssemblyInspector) -> (bool, Dict[str, Dict]):
"""
Check whether the issues found are permitted,
Expand Down Expand Up @@ -1125,21 +1112,6 @@ def find_rhcos_build_rpm_inconsistencies(rhcos_builds: List[RHCOSBuildInspector]
# Report back rpm name keys which were associated with more than one NVR in the set of RHCOS builds.
return {rpm_name: nvr_dict for rpm_name, nvr_dict in rpm_uses.items() if len(nvr_dict) > 1}

@staticmethod
def find_rhcos_os_commit_inconsistencies(rhcos_builds: List[RHCOSBuildInspector]) -> Dict[str, List[str]]:
"""
Looks through a set of RHCOS builds and finds if the commit of openshift/os it is based on is equal
among the arches.
:return: Dict of openshift/os commits to list of arch if more than one. Empty dict if consistent.
"""

os_commits = dict()
for rhcos_build in rhcos_builds:
os_commits.setdefault(rhcos_build.openshift_os_commit, []).append(rhcos_build.brew_arch)
if len(os_commits) == 1:
return {}
return os_commits

@staticmethod
def get_mirroring_destination(sha256: str, dest_repo: str) -> str:
"""
Expand Down
8 changes: 0 additions & 8 deletions doozerlib/rhcos.py
Expand Up @@ -220,7 +220,6 @@ def __init__(self, runtime, pullspec_for_tag: Dict[str, str], brew_arch: str):
self.brew_arch = brew_arch
self.pullspec_for_tag = pullspec_for_tag
self.build_id = None
self.openshift_os_commit: str = ''

# Remember the pullspec(s) provided in case it does not match what is in the releases.yaml.
# Because of an incident where we needed to repush RHCOS and get a new SHA for 4.10 GA,
Expand All @@ -235,13 +234,6 @@ def __init__(self, runtime, pullspec_for_tag: Dict[str, str], brew_arch: str):
if self.build_id and self.build_id != build_id:
raise Exception(f'Found divergent RHCOS build_id for {pullspec_for_tag}. {build_id} versus {self.build_id}')
self.build_id = build_id
try:
openshift_os_commit = str(image_info.config.config.Labels['com.coreos.redhat-coreos-commit'])
except AttributeError:
raise Exception(f'Unable to determine RHCOS openshift/os commit from tag {tag} pullspec {pullspec}. Retrieved image info: {image_info_str}')
if self.openshift_os_commit and self.openshift_os_commit != openshift_os_commit:
raise Exception(f'Inconsistent RHCOS openshift/os commits for {pullspec_for_tag}: {self.openshift_os_commit} vs {openshift_os_commit}')
self.openshift_os_commit = openshift_os_commit

# The first digits of the RHCOS build are the major.minor of the rhcos stream name.
# Which, near branch cut, might not match the actual release stream.
Expand Down
17 changes: 2 additions & 15 deletions tests/cli/test_gen_payload.py
@@ -1,4 +1,4 @@
import unittest
from unittest import TestCase, skip
from unittest.mock import MagicMock, Mock, patch
from flexmock import flexmock

Expand All @@ -15,7 +15,7 @@
from doozerlib import rhcos


class TestGenPayloadCli(unittest.TestCase):
class TestGenPayloadCli(TestCase):

def test_find_rhcos_payload_entries(self):
rhcos_build = MagicMock()
Expand Down Expand Up @@ -217,7 +217,6 @@ def test_detect_extend_payload_entry_issues(self):
gpcli.should_receive("detect_rhcos_issues").with_args(rhcosEntry, None).once()
gpcli.should_receive("detect_rhcos_inconsistent_rpms").once().with_args(
{False: ["rbi"], True: []})
gpcli.should_receive("detect_rhcos_inconsistent_os_commit").once()

gpcli.detect_extend_payload_entry_issues(None)
self.assertEqual(gpcli.assembly_issues, spamEntry.issues)
Expand Down Expand Up @@ -254,14 +253,6 @@ def test_detect_rhcos_inconsistent_rpms(self, pg_find_mock):
gpcli.detect_rhcos_inconsistent_rpms({False: ["rbi"], True: []})
self.assertEqual(gpcli.assembly_issues[0].code, AssemblyIssueCode.INCONSISTENT_RHCOS_RPMS)

@patch("doozerlib.cli.release_gen_payload.PayloadGenerator.find_rhcos_os_commit_inconsistencies")
def test_detect_rhcos_inconsistent_os_commit(self, pg_find_mock):
gpcli = rgp_cli.GenPayloadCli()
gpcli.privacy_modes = [True, False]
pg_find_mock.side_effect = [[], ["dummy1", "dummy2"]]
gpcli.detect_rhcos_inconsistent_os_commit({False: ["rbi"], True: []})
self.assertEqual(gpcli.assembly_issues[0].code, AssemblyIssueCode.INCONSISTENT_OS_COMMIT)

def test_summarize_issue_permits(self):
gpcli = rgp_cli.GenPayloadCli()
gpcli.assembly_issues = [
Expand Down Expand Up @@ -626,7 +617,3 @@ def test_apply_multi_imagestream_update(self, mar_mock):
self.assertIn(dict(name="spam2"), istream_apiobj.model.spec.tags, "not pruned")
self.assertEqual({"release.openshift.io/rewrite": "false"},
istream_apiobj.model.spec.tags[-1]["annotations"], "added")


if __name__ == '__main__':
unittest.main()

0 comments on commit 9b919ec

Please sign in to comment.